graphql-code-generator: Duplicate identifier error
Describe the bug Duplicate resolver type is generated.
To Reproduce
- Define field
category_sports: categoryas schema. (single underscore) - Define another field
category__sports: [category]as schema. (double underscore) - Run the following command:
gql-gen -s http://somewhere/graphql -t graphql-codegen-typescript-template -o ./src/resolvers/types.ts ./src/resolvers/query.ts - Run the following command:
tsc -p .src/resolvers/types.ts - error TS2300: Duplicate identifier ‘CategorySportsResolver’.
Expected behavior No error message.
Environment:
- OS: macOS High Sierra
- Codegen: graphql-code-generator v0.12.5, graphql-codegen-typescript-template@0.12.5
- Node: v8.12.0
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 9
- Comments: 15 (6 by maintainers)
Commits related to this issue
- Fix duplicate identifiers Ref https://github.com/dotansimha/graphql-code-generator/issues/642#issuecomment-495919863 — committed to glennreyes/glennreyes.com by glennreyes 7 years ago
@dotansimha @danbruegge, Faced the same problem.
It happens because
"pluginCreator___id"and"pluginCreatorId"usingchange-case#pascalCaseis transformed into the samePluginCreatorId.Changing the enum transformer name convention to
keepsolved the problem:Hi, looks like this error is back again? We have a simple GatsbyJS+StrapiJS stack.
This is what i get:
Do you need further infos?
It happens also for me when my schema contains both
_idandidfields. It generates twice the typeIdResolver@panzerdp nice, it works great. Thank you. 😃
It seems the duplicate resolver type is happening in in 0.15.2. I just upgraded from 0.13. I had resolvers turned off there but decided to give it a try after the upgrade but ran into Typescript build errors due to the duplicates. I have some types in my schema with legacy fields that are in snake_case (such as
brand_id) but have new fields in camelCase (brandId).I think I could use a custom
namingConventionto workaround but would be great If it was handled by the package.Btw, I love this project! Great work and thanks!