-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cli] Add watchPattern to generates config (#9151)
- release-1741347583945
- release-1740342549291
- release-1739976344714
- release-1739457179435
- release-1739021915957
- release-1738338767180
- release-1738065376043
- release-1732308151614
- release-1730117942954
- release-1728313341014
- release-1722174286560
- release-1719908762705
- release-1719728462307
- release-1719561390108
- release-1718272997249
- release-1715941655817
- release-1711538187754
- release-1708631078793
- release-1708451740568
- release-1707231464907
- release-1707228662764
- release-1690276829878
- release-1687159967878
- release-1685631366501
- release-1684916162003
- release-1682170994048
- release-1680576611161
- @graphql-codegen/visitor-plugin-common@5.7.1
- @graphql-codegen/visitor-plugin-common@5.7.0
- @graphql-codegen/visitor-plugin-common@5.6.1
- @graphql-codegen/visitor-plugin-common@5.6.0
- @graphql-codegen/visitor-plugin-common@5.5.0
- @graphql-codegen/visitor-plugin-common@5.4.0
- @graphql-codegen/visitor-plugin-common@5.3.1
- @graphql-codegen/visitor-plugin-common@5.3.0
- @graphql-codegen/visitor-plugin-common@5.2.0
- @graphql-codegen/visitor-plugin-common@5.1.0
- @graphql-codegen/visitor-plugin-common@5.0.0
- @graphql-codegen/visitor-plugin-common@4.1.2
- @graphql-codegen/visitor-plugin-common@4.1.1
- @graphql-codegen/visitor-plugin-common@4.0.1
- @graphql-codegen/visitor-plugin-common@4.0.0
- @graphql-codegen/visitor-plugin-common@3.1.1
- @graphql-codegen/visitor-plugin-common@3.1.0
- @graphql-codegen/typescript-resolvers@4.4.4
- @graphql-codegen/typescript-resolvers@4.4.3
- @graphql-codegen/typescript-resolvers@4.4.2
- @graphql-codegen/typescript-resolvers@4.4.1
- @graphql-codegen/typescript-resolvers@4.4.0
- @graphql-codegen/typescript-resolvers@4.3.0
- @graphql-codegen/typescript-resolvers@4.2.1
- @graphql-codegen/typescript-resolvers@4.2.0
- @graphql-codegen/typescript-resolvers@4.1.0
- @graphql-codegen/typescript-resolvers@4.0.6
- @graphql-codegen/typescript-resolvers@4.0.5
- @graphql-codegen/typescript-resolvers@4.0.4
- @graphql-codegen/typescript-resolvers@4.0.3
- @graphql-codegen/typescript-resolvers@4.0.1
- @graphql-codegen/typescript-resolvers@4.0.0
- @graphql-codegen/typescript-resolvers@3.2.1
- @graphql-codegen/typescript-resolvers@3.2.0
- @graphql-codegen/typescript-operations@4.5.1
- @graphql-codegen/typescript-operations@4.5.0
- @graphql-codegen/typescript-operations@4.4.1
- @graphql-codegen/typescript-operations@4.4.0
- @graphql-codegen/typescript-operations@4.3.1
- @graphql-codegen/typescript-operations@4.3.0
- @graphql-codegen/typescript-operations@4.2.3
- @graphql-codegen/typescript-operations@4.2.2
- @graphql-codegen/typescript-operations@4.2.1
- @graphql-codegen/typescript-operations@4.2.0
- @graphql-codegen/typescript-operations@4.1.3
- @graphql-codegen/typescript-operations@4.1.2
- @graphql-codegen/typescript-operations@4.1.1
- @graphql-codegen/typescript-operations@4.0.1
- @graphql-codegen/typescript-operations@4.0.0
- @graphql-codegen/typescript-operations@3.0.4
- @graphql-codegen/typescript-operations@3.0.3
- @graphql-codegen/typescript-document-nodes@4.0.15
- @graphql-codegen/typescript-document-nodes@4.0.14
- @graphql-codegen/typescript-document-nodes@4.0.13
- @graphql-codegen/typescript-document-nodes@4.0.12
- @graphql-codegen/typescript-document-nodes@4.0.11
- @graphql-codegen/typescript-document-nodes@4.0.10
- @graphql-codegen/typescript-document-nodes@4.0.9
- @graphql-codegen/typescript-document-nodes@4.0.8
- @graphql-codegen/typescript-document-nodes@4.0.7
- @graphql-codegen/typescript-document-nodes@4.0.6
- @graphql-codegen/typescript-document-nodes@4.0.5
- @graphql-codegen/typescript-document-nodes@4.0.4
- @graphql-codegen/typescript-document-nodes@4.0.3
- @graphql-codegen/typescript-document-nodes@4.0.1
- @graphql-codegen/typescript-document-nodes@4.0.0
- @graphql-codegen/typescript-document-nodes@3.0.4
- @graphql-codegen/typescript-document-nodes@3.0.3
- @graphql-codegen/typescript@4.1.5
- @graphql-codegen/typescript@4.1.4
- @graphql-codegen/typescript@4.1.3
- @graphql-codegen/typescript@4.1.2
- @graphql-codegen/typescript@4.1.1
- @graphql-codegen/typescript@4.1.0
- @graphql-codegen/typescript@4.0.9
- @graphql-codegen/typescript@4.0.8
- @graphql-codegen/typescript@4.0.7
- @graphql-codegen/typescript@4.0.6
- @graphql-codegen/typescript@4.0.5
- @graphql-codegen/typescript@4.0.4
- @graphql-codegen/typescript@4.0.3
- @graphql-codegen/typescript@4.0.1
- @graphql-codegen/typescript@4.0.0
- @graphql-codegen/typescript@3.0.4
- @graphql-codegen/typescript@3.0.3
- @graphql-codegen/typed-document-node@5.1.0
- @graphql-codegen/typed-document-node@5.0.15
- @graphql-codegen/typed-document-node@5.0.14
- @graphql-codegen/typed-document-node@5.0.13
- @graphql-codegen/typed-document-node@5.0.12
- @graphql-codegen/typed-document-node@5.0.11
- @graphql-codegen/typed-document-node@5.0.10
- @graphql-codegen/typed-document-node@5.0.9
- @graphql-codegen/typed-document-node@5.0.8
- @graphql-codegen/typed-document-node@5.0.7
- @graphql-codegen/typed-document-node@5.0.6
- @graphql-codegen/typed-document-node@5.0.5
- @graphql-codegen/typed-document-node@5.0.4
- @graphql-codegen/typed-document-node@5.0.3
- @graphql-codegen/typed-document-node@5.0.1
- @graphql-codegen/typed-document-node@5.0.0
- @graphql-codegen/typed-document-node@4.0.1
- @graphql-codegen/typed-document-node@4.0.0
- @graphql-codegen/time@5.0.1
- @graphql-codegen/time@5.0.0
- @graphql-codegen/testing@3.0.4
- @graphql-codegen/testing@3.0.3
- @graphql-codegen/testing@3.0.2
- @graphql-codegen/testing@3.0.0
- @graphql-codegen/testing@2.0.2
- @graphql-codegen/schema-ast@4.1.0
- @graphql-codegen/schema-ast@4.0.2
- @graphql-codegen/schema-ast@4.0.0
- @graphql-codegen/plugin-helpers@5.1.0
- @graphql-codegen/plugin-helpers@5.0.4
- @graphql-codegen/plugin-helpers@5.0.3
- @graphql-codegen/plugin-helpers@5.0.1
- @graphql-codegen/plugin-helpers@5.0.0
- @graphql-codegen/plugin-helpers@4.2.0
- @graphql-codegen/introspection@4.0.3
- @graphql-codegen/introspection@4.0.2
- @graphql-codegen/introspection@4.0.0
- @graphql-codegen/graphql-modules-preset@4.0.15
- @graphql-codegen/graphql-modules-preset@4.0.14
- @graphql-codegen/graphql-modules-preset@4.0.13
- @graphql-codegen/graphql-modules-preset@4.0.12
- @graphql-codegen/graphql-modules-preset@4.0.11
- @graphql-codegen/graphql-modules-preset@4.0.10
- @graphql-codegen/graphql-modules-preset@4.0.9
- @graphql-codegen/graphql-modules-preset@4.0.8
- @graphql-codegen/graphql-modules-preset@4.0.7
- @graphql-codegen/graphql-modules-preset@4.0.6
- @graphql-codegen/graphql-modules-preset@4.0.5
- @graphql-codegen/graphql-modules-preset@4.0.4
- @graphql-codegen/graphql-modules-preset@4.0.3
- @graphql-codegen/graphql-modules-preset@4.0.1
- @graphql-codegen/graphql-modules-preset@4.0.0
- @graphql-codegen/graphql-modules-preset@3.1.3
- @graphql-codegen/graphql-modules-preset@3.1.2
- @graphql-codegen/gql-tag-operations@4.0.16
- @graphql-codegen/gql-tag-operations@4.0.15
- @graphql-codegen/gql-tag-operations@4.0.14
- @graphql-codegen/gql-tag-operations@4.0.13
- @graphql-codegen/gql-tag-operations@4.0.12
- @graphql-codegen/gql-tag-operations@4.0.11
- @graphql-codegen/gql-tag-operations@4.0.10
- @graphql-codegen/gql-tag-operations@4.0.9
- @graphql-codegen/gql-tag-operations@4.0.8
- @graphql-codegen/gql-tag-operations@4.0.7
- @graphql-codegen/gql-tag-operations@4.0.6
- @graphql-codegen/gql-tag-operations@4.0.5
- @graphql-codegen/gql-tag-operations@4.0.4
- @graphql-codegen/gql-tag-operations@4.0.3
- @graphql-codegen/gql-tag-operations@4.0.1
- @graphql-codegen/gql-tag-operations@4.0.0
- @graphql-codegen/gql-tag-operations@3.0.1
- @graphql-codegen/gql-tag-operations@3.0.0
- @graphql-codegen/fragment-matcher@5.1.0
- @graphql-codegen/fragment-matcher@5.0.2
- @graphql-codegen/fragment-matcher@5.0.0
- @graphql-codegen/core@4.0.2
- @graphql-codegen/core@4.0.0
- @graphql-codegen/client-preset@4.7.0
- @graphql-codegen/client-preset@4.6.4
- @graphql-codegen/client-preset@4.6.3
- @graphql-codegen/client-preset@4.6.2
- @graphql-codegen/client-preset@4.6.1
- @graphql-codegen/client-preset@4.6.0
- @graphql-codegen/client-preset@4.5.1
- @graphql-codegen/client-preset@4.5.0
- @graphql-codegen/client-preset@4.4.0
- @graphql-codegen/client-preset@4.3.3
- @graphql-codegen/client-preset@4.3.2
- @graphql-codegen/client-preset@4.3.1
- @graphql-codegen/client-preset@4.3.0
- @graphql-codegen/client-preset@4.2.6
- @graphql-codegen/client-preset@4.2.5
- @graphql-codegen/client-preset@4.2.4
- @graphql-codegen/client-preset@4.2.3
- @graphql-codegen/client-preset@4.2.2
- @graphql-codegen/client-preset@4.2.1
- @graphql-codegen/client-preset@4.1.0
- @graphql-codegen/client-preset@4.0.1
- @graphql-codegen/client-preset@4.0.0
- @graphql-codegen/client-preset@3.0.1
- @graphql-codegen/client-preset@3.0.0
- @graphql-codegen/cli@5.0.5
- @graphql-codegen/cli@5.0.4
- @graphql-codegen/cli@5.0.3
- @graphql-codegen/cli@5.0.2
- @graphql-codegen/cli@5.0.0
- @graphql-codegen/cli@4.0.1
- @graphql-codegen/cli@4.0.0
- @graphql-codegen/cli@3.3.1
- @graphql-codegen/cli@3.3.0
- @graphql-codegen/add@5.0.3
- @graphql-codegen/add@5.0.2
- @graphql-codegen/add@5.0.0
Showing
3 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
'@graphql-codegen/plugin-helpers': minor | ||
'@graphql-codegen/cli': minor | ||
--- | ||
|
||
Add `watchPattern` config option for `generates` sections. | ||
|
||
By default, `watch` mode automatically watches all GraphQL schema and document files. This means when a change is detected, Codegen CLI is run. | ||
|
||
A user may want to run Codegen CLI when non-schema and non-document files are changed. Each `generates` section now has a `watchPattern` option to allow more file patterns to be added to the list of patterns to watch. | ||
|
||
In the example below, mappers are exported from `schema.mappers.ts` files. We want to re-run Codegen if the content of `*.mappers.ts` files change because they change the generated types file. To solve this, we can add mapper file patterns to watch using the glob pattern used for schema and document files. | ||
|
||
```ts | ||
// codegen.ts | ||
const config: CodegenConfig = { | ||
schema: 'src/schema/**/*.graphql', | ||
generates: { | ||
'src/schema/types.ts': { | ||
plugins: ['typescript', 'typescript-resolvers'], | ||
config: { | ||
mappers: { | ||
User: './user/schema.mappers#UserMapper', | ||
Book: './book/schema.mappers#BookMapper', | ||
}, | ||
} | ||
watchPattern: 'src/schema/**/*.mappers.ts', // Watches mapper files in `watch` mode. Use an array for multiple patterns e.g. `['src/*.pattern1.ts','src/*.pattern2.ts']` | ||
}, | ||
}, | ||
}; | ||
``` | ||
|
||
Then, run Codegen CLI in `watch` mode: | ||
|
||
```shell | ||
yarn graphql-codegen --watch | ||
``` | ||
|
||
Now, updating `*.mappers.ts` files re-runs Codegen! 🎉 | ||
|
||
Note: `watchPattern` is only used in `watch` mode i.e. running CLI with `--watch` flag. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters