Skip to content

Commit dce40ed

Browse files
rohit-gohrisaihaj
andauthored
Allow disabling watch from cli (#7781)
* Allow disabling watch from cli * add tests * add changeset Co-authored-by: Saihajpreet Singh <saihajpreet.singh@gmail.com>
1 parent e7870ac commit dce40ed

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@graphql-codegen/cli': patch
3+
---
4+
5+
Allow to disable watch mode from CLI to overwrite the config. Now you can do:
6+
7+
```bash
8+
$ graphql-codegen --watch=false
9+
```

packages/graphql-codegen-cli/src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ export function updateContextWithCliFlags(context: CodegenContext, cliFlags: Yam
265265
configFilePath: context.filepath,
266266
};
267267

268-
if (cliFlags.watch) {
268+
if (cliFlags.watch !== undefined) {
269269
config.watch = cliFlags.watch;
270270
}
271271

packages/graphql-codegen-cli/tests/cli-flags.spec.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ describe('CLI Flags', () => {
9292
expect(config.overwrite).not.toBeTruthy();
9393
});
9494

95-
it('Should overwrite watch config using cli flags', async () => {
95+
it('Should overwrite watch config using cli flag to true', async () => {
9696
mockConfig(`
9797
schema: schema.graphql
9898
watch: false
@@ -106,6 +106,20 @@ describe('CLI Flags', () => {
106106
expect(config.watch).toBeTruthy();
107107
});
108108

109+
it('Should overwrite watch config using cli flags to false', async () => {
110+
mockConfig(`
111+
schema: schema.graphql
112+
watch: true
113+
generates:
114+
file.ts:
115+
- plugin
116+
`);
117+
const args = createArgv('--watch=false');
118+
const context = await createContext(parseArgv(args));
119+
const config = context.getConfig();
120+
expect(config.watch).toBeFalsy();
121+
});
122+
109123
it('Should set --overwrite with new YML api', async () => {
110124
mockConfig(`
111125
schema: schema.graphql

0 commit comments

Comments
 (0)