-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[experimental-graphql-modules] no config in generation for enums #5242
Comments
Hi! In this new preset, we generate main types file with everything in it, and then generate types file per graphql-module, with the contribution of it to the result schema. Since TypeScript enums are nominal types, we can define the entire enum in the main file, and the pick specific values from it. Do you think there is another way to solve that? |
No not really unfortunately. I hope to work on it next year since now i only have three working days left :) |
I don't understand why.. just importing typescript enum from main file to module file, like what P.S. |
Workaround for other folks until the issue is resolved.You can generate typescript overwrite: true
generates:
./src/generated/graphql/self-enum.ts:
schema:
- ./src/graphql/module/*/*.graphql:
commentDescriptions: true
plugins:
- typescript
config:
typesPrefix: Gql
./src/graphql/module:
schema:
- ./src/graphql/module/*/*.graphql:
commentDescriptions: true
preset: graphql-modules
presetConfig:
baseTypesPath: ../../generated/graphql/self.ts # Where to create the complete schema types
filename: generated.ts # Where to create each module types
plugins:
- typescript
- typescript-resolvers
config:
typesPrefix: Gql
# enumsAsTypes: false # This does not work with graphql-modules preset.
enumValues:
foo: ./self-enum#GqlFoo
bar: ./self-enum#GqlBar And you can import enum types independently. import { YourModule } from './generated'
import { GqlFooEnum, GqlBarEnum } from '../../../generated/garphql/self-enum'
// the enums are compatible with graphql-modules' generated enums. |
Im using the new experimental graphql-module creation. In the old schema creation we had this config:
Now the new graphql-modules option creates the complete schema but i cant set any config. So i lost all my enums basically (which follow TS spec, also saw it with DTS generator). I can create the other as well, but why having two schemas :)
example new situation:
example old situation:
btw really cool to see the progress on the suite!
The text was updated successfully, but these errors were encountered: