Describe the bug
There are two, enum given numeric values in enumValues config options are generated as string and value 0 will not be converted at all
To Reproduce
Steps to reproduce the behavior:
give numeric values to map enum fields in enumValues config option
enum FooEnum {
FOO
BAR
}
no problems with operation, just with generated type, graphql will convert correctly
codegen.yml config file:overwrite: true
schema: './data/schema.graphql'
documents: null
generates:
packages/api/src/generated/schema.ts:
plugins:
- add: '/* istanbul ignore file */'
- typescript
- typescript-resolvers
config:
namingConvention:
enumValues: keep
enumValues:
FooEnum:
FOO: 1
BAR: 0
Expected behavior
The generated code should be
export enum FooEnum {
FOO = 1
BAR = 0
}
but it is
export enum FooEnum {
FOO = '1'
BAR = 'BAR'
}
https://codesandbox.io/s/graphql-codegen-issue-template-1lmxr
Environment:
@graphql-codegen/...: {
"@graphql-codegen/add": "^1.8.3",
"@graphql-codegen/cli": "^1.9.1",
"@graphql-codegen/introspection": "^1.9.1",
"@graphql-codegen/typescript": "^1.9.1",
"@graphql-codegen/typescript-resolvers": "^1.9.1",
}
Additional context
graphql will convert correctly because I have the enum resolver defined explicitly as
export const resolvers = {
FooEnum: {
FOO: 1,
BAR: 0,
},
};
@BigsonLvrocha I think I managed to fix that in: https://github.com/dotansimha/graphql-code-generator/pull/3187
Can you please try 1.9.2-alpha-4be25b2b.82?
Available in v1.10.0.
I was on a trip, got the computer now, it's fixed, thanks :)