Incorrect "Not all operations have an unique name" on 1.11.2
See original GitHub issueDescribe the bug
1.11.2 is incorrectly stating “Not all operations have an unique name” when I attempt to run codegen; 1.8.3 was working fine.
To Reproduce
Codegen works fine on the Graphile Starter codegen-fine branch: https://github.com/graphile/starter/tree/codegen-fine
However, when we upgrade graphql-codegen from 1.8.3 to 1.11.2 we get the aforementioned error; see: https://github.com/graphile/starter/tree/codegen-bad which is one commit ahead of codegen-fine.
I’ve dug into this further; see “Additional context”
Running graphql-codegen results in:
✔ Parse configuration
❯ Generate outputs
❯ Generate index.tsx
✔ Load GraphQL schemas
✔ Load GraphQL documents
✖ Generate
→ Not all operations have an unique name: AddEmail
Found 1 error
✖ index.tsx
Not all operations have an unique name
* AddEmail found in:
- /home/benjie/Dev/starter/@app/client/src/graphql/AddEmail.graphql
- /home/benjie/Dev/starter/@app/client/src/graphql/DeleteEmail.graphql
- /home/benjie/Dev/starter/@app/client/src/graphql/EmailsForm_User.graphql
- /home/benjie/Dev/starter/@app/client/src/graphql/SettingsEmails.graphql
- /home/benjie/Dev/starter/@app/client/src/graphql/SettingsProfile.graphql
Error: Not all operations have an unique name: AddEmail
at validateDuplicateDocuments (/home/benjie/Dev/starter/node_modules/@graphql-codegen/core/index.cjs.js:200:1
5)
at Object.codegen (/home/benjie/Dev/starter/node_modules/@graphql-codegen/core/index.cjs.js:59:9)
at process (/home/benjie/Dev/starter/node_modules/@graphql-codegen/cli/bin.js:783:67)
at Array.map (<anonymous>)
at /home/benjie/Dev/starter/node_modules/@graphql-codegen/cli/bin.js:790:63
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Task.task (/home/benjie/Dev/starter/node_modules/@graphql-codegen/cli/bin.js:582:17)
Error: Not all operations have an unique name: AddEmail
at validateDuplicateDocuments (/home/benjie/Dev/starter/node_modules/@graphql-codegen/core/index.cjs.js:200:1
5)
at Object.codegen (/home/benjie/Dev/starter/node_modules/@graphql-codegen/core/index.cjs.js:59:9)
at process (/home/benjie/Dev/starter/node_modules/@graphql-codegen/cli/bin.js:783:67)
at Array.map (<anonymous>)
at /home/benjie/Dev/starter/node_modules/@graphql-codegen/cli/bin.js:790:63
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Task.task (/home/benjie/Dev/starter/node_modules/@graphql-codegen/cli/bin.js:582:17)
Expected behavior
Codegen should run as expected (since all my operations are uniquely named)
Environment:
- OS:
Ubuntu 18.04.3 LTS - NodeJS:
v12.13.1
"@graphql-codegen/add": "^1.11.2",
"@graphql-codegen/cli": "^1.11.2",
"@graphql-codegen/typescript": "^1.11.2",
"@graphql-codegen/typescript-operations": "^1.11.2",
"@graphql-codegen/typescript-react-apollo": "1.11.2"
Additional context
I investigated further using the Node debugger because this issue is bizarre. I ended up here:

Note that the rawSDL value for this entry has an import and mutation DeleteEmail; however the definitions entry contains an operation and a fragment, the operation is named AddEmail which is not sourced from this file. The imported fragment can be seen here but doesn’t contain any operations:
fragment EmailsForm_UserEmail on UserEmail {
id
email
isVerified
isPrimary
createdAt
}
Interestingly this fragment IS used by the AddEmail operation, so it looks like the re-used fragment is causing the file/operations to be interpretted incorrectly.
Issue Analytics
- State:
- Created 4 years ago
- Comments:32 (8 by maintainers)
Top Related StackOverflow Question
Fixed in
v1.12.0🤷