Skip to content

Commit

Permalink
deprecate old configs and update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
saihaj committed Feb 20, 2023
1 parent 18c8688 commit e01f01d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 2 additions & 0 deletions packages/utils/plugins-helpers/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,8 @@ export namespace Types {
*/
watch?: boolean | string | string[];
/**
* @deprecated this is not necessary since we are using `@parcel/watcher` instead of `chockidar`.
*
* @description Allows overriding the behavior of watch to use stat polling over native file watching support.
*
* Config fields have the same defaults and sematics as the identically named ones for chokidar.
Expand Down
5 changes: 3 additions & 2 deletions website/public/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@
"anyOf": [{ "type": "array", "items": { "type": "string" } }, { "type": ["string", "boolean"] }]
},
"watchConfig": {
"description": "Allows overriding the behavior of watch to use stat polling over native file watching support.\n\nConfig fields have the same defaults and sematics as the identically named ones for chokidar.\n\nFor more details: https://graphql-code-generator.com/docs/getting-started/development-workflow#watch-mode",
"description": "This field is deprecated and will be removed in next major release. Allows overriding the behavior of watch to use stat polling over native file watching support.\n\nConfig fields have the same defaults and sematics as the identically named ones for chokidar.\n\nFor more details: https://graphql-code-generator.com/docs/getting-started/development-workflow#watch-mode",
"type": "object",
"properties": { "usePolling": { "type": "boolean" }, "interval": { "type": "number" } }
"properties": { "usePolling": { "type": "boolean" }, "interval": { "type": "number" } },
"deprecated": "true"
},
"ignoreNoDocuments": {
"description": "A flag to suppress non-zero exit code when there are no documents to generate.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,15 @@ yarn graphql-codegen --watch "src/**/*.js"

Use this when you are loading your schema or documents from a single code file that depends on other files internally because codegen can't tell that you're using those files automatically.

By default, watch mode uses the system's native support to listen for file change events. This can be configured in the settings file to use a stat polling method instead of in unusual cases where system support is unavailable.
We use [`@parcel/watcher`](https://github.com/parcel-bundler/watcher) which supports subscribing to realtime notifications of changes in a directory. It works recursively, so changes in sub-directories will also be emitted.

```ts {6-10}
import { CodegenConfig } from '@graphql-codegen/cli'

const config: CodegenConfig = {
schema: 'http://localhost:4000/graphql',
// ...
watch: true,
watchConfig: {
// Passed directly through to chokidar's file watch configuration
usePolling: true,
interval: 1000
}
watch: true
}

export default config
Expand Down

0 comments on commit e01f01d

Please sign in to comment.