You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you for keeping this important project going!
So for some reason, if --watch 'some/file/glob' is specified for our monorepo, then the server schema generated from the graphql-modules preset can potentially generate using more files than it should be using.
In our monorepo, we have an older schemas folder with many .graphql files defining our schema, and a newer implementation using graphql-modules. We generate two schemas, one only from the graphql modules files, and one combining the older schema and the modules schema.
If --watch specifies all possible files (including the older schema), then the merging happens even in the output file that shouldn't contain the full schema.
My guess is that graphql-codegen or the modules preset is adding all possible files into an internal list, and reusing that list during generation instead of re-calculating for each generates key in the codegen file. So --watch basically augments schema, instead of only watching the specified files for changes and keeping schema the same.
For a workaround I'm going to try watching the glob manually with chokidar or watchman, and re-running graphql-codegen from scratch each time.
To Reproduce
Don't have time for a full reproduction project right now, sorry :(
(Abbreviated) codegen.yml:
schema:
- ./modules/**/*.module.ts:
noRequire: trueconfig:
onlyResolveTypeForInterfaces: trueuseTypeImports: truemaybeValue: 'T | null | undefined'omitOperationSuffix: truepreResolveTypes: falseskipTypeNameForRoot: truenamingConvention:
enumValues: keepscalars:
# many scalar definitionsmappers:
# many mapper definitionsgenerates:
# Generate server types and resolver types - modules../src/modules/:
preset: graphql-modulespresetConfig:
baseTypesPath: ../generated/server.tsfilename: generated/module-types.tsencapsulateModuleTypes: noneplugins:
- typescript
- typescript-resolvers# Generate server and resolver types - modules + legacy../src/generated/server-legacy.ts:
schema: ./schema/**/*.graphql # added to "schema" at rootplugins:
- typescript
- typescript-resolvers
Expected behavior --watch should watch the specified files, but the actual files used in each generates should not change.
Describe the bug
Thank you for keeping this important project going!
So for some reason, if
--watch 'some/file/glob'
is specified for our monorepo, then the server schema generated from thegraphql-modules
preset can potentially generate using more files than it should be using.In our monorepo, we have an older
schemas
folder with many.graphql
files defining our schema, and a newer implementation using graphql-modules. We generate two schemas, one only from the graphql modules files, and one combining the older schema and the modules schema.If
--watch
specifies all possible files (including the older schema), then the merging happens even in the output file that shouldn't contain the full schema.My guess is that graphql-codegen or the modules preset is adding all possible files into an internal list, and reusing that list during generation instead of re-calculating for each
generates
key in the codegen file. So--watch
basically augmentsschema
, instead of only watching the specified files for changes and keepingschema
the same.For a workaround I'm going to try watching the glob manually with chokidar or watchman, and re-running
graphql-codegen
from scratch each time.To Reproduce
Don't have time for a full reproduction project right now, sorry :(
(Abbreviated)
codegen.yml
:Expected behavior
--watch
should watch the specified files, but the actual files used in eachgenerates
should not change.Environment:
The text was updated successfully, but these errors were encountered: