dotansimha / graphql-code-generator

A tool for generating code based on a GraphQL schema and GraphQL operations (query/mutation/subscription), with flexible support for custom plugins.
https://the-guild.dev/graphql/codegen/
MIT License
10.84k stars 1.33k forks source link

[TypeScript] Duplicate type generated if there is a field with the same name (but different case) #1225

Closed leighman closed 5 years ago

leighman commented 5 years ago

Describe the bug Duplicate type IdResolver is generated for fields id and ID.

To Reproduce

Expected behavior Generated types should be IdResolver and IDResolver? Is there any way to work around this other than manually editing the generated file?

Environment:

dotansimha commented 5 years ago

Hi @leighman , thank you for reporting this issue. We are trying to improve and find the best solution for naming, but that's not always easy. In general, I think naming a field with the same name might be confusing for developers who consume it. We currently does not have a proper solution for this case, but you can try to use namingConvention: none to avoid changing the names of the types.

leighman commented 5 years ago

@dotansimha Thanks. As far as I can see it looks like I could override namingConvention: typeNames: in ^0.16 but currently blocked from updating by the https://github.com/dotansimha/graphql-code-generator/pull/1194 regression

dotansimha commented 5 years ago

@leighman you can use the latest alpha to get this fix before we release it:

 - graphql-code-generator@0.17.0-alpha.fad8d485
 - graphql-codegen-core@0.17.0-alpha.fad8d485
 - codegen-templates-scripts@0.17.0-alpha.fad8d485
 - graphql-codegen-plugin-handlebars-helpers@0.17.0-alpha.fad8d485
 - graphql-codegen-plugin-helpers@0.17.0-alpha.fad8d485
 - graphql-codegen-add@0.17.0-alpha.fad8d485
 - graphql-codegen-flow-documents@0.17.0-alpha.fad8d485
 - graphql-codegen-flow-resolvers@0.17.0-alpha.fad8d485
 - graphql-codegen-flow@0.17.0-alpha.fad8d485
 - graphql-codegen-fragment-matcher@0.17.0-alpha.fad8d485
 - graphql-codegen-introspection@0.17.0-alpha.fad8d485
 - graphql-codegen-schema-ast@0.17.0-alpha.fad8d485
 - graphql-codegen-time@0.17.0-alpha.fad8d485
 - graphql-codegen-typescript-apollo-angular@0.17.0-alpha.fad8d485
 - graphql-codegen-typescript-client@0.17.0-alpha.fad8d485
 - graphql-codegen-typescript-common@0.17.0-alpha.fad8d485
 - graphql-codegen-typescript-graphql-files-modules@0.17.0-alpha.fad8d485
 - graphql-codegen-typescript-mongodb@0.17.0-alpha.fad8d485
 - graphql-codegen-typescript-react-apollo@0.17.0-alpha.fad8d485
 - graphql-codegen-typescript-resolvers@0.17.0-alpha.fad8d485
 - graphql-codegen-typescript-server@0.17.0-alpha.fad8d485
 - graphql-codegen-typescript-stencil-apollo@0.17.0-alpha.fad8d485
 - graphql-codegen-apollo-angular-template@0.17.0-alpha.fad8d485
 - graphql-codegen-graphql-files-typescript-modules@0.17.0-alpha.fad8d485
 - graphql-codegen-introspection-template@0.17.0-alpha.fad8d485
 - graphql-codegen-typescript-mongodb-template@0.17.0-alpha.fad8d485
 - graphql-codegen-typescript-react-apollo-template@0.17.0-alpha.fad8d485
 - graphql-codegen-typescript-resolvers-template@0.17.0-alpha.fad8d485
 - graphql-codegen-typescript-template@0.17.0-alpha.fad8d485
dotansimha commented 5 years ago

Fixed in 0.18.0 🎉