Incorrect "Not all operations have an unique name" on 1.11.2

See original GitHub issue

Describe 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:

Screenshot_20200120_104824

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:closed
  • Created 4 years ago
  • Comments:32 (8 by maintainers)

github_iconTop GitHub Comments

4reactions
dotansimhacommented, Jan 28, 2020

Fixed in v1.12.0

3reactions
benjiecommented, Dec 12, 2022

🤷

Read more comments on GitHub >

github_iconTop Results From Across the Web

Incorrect "Not all operations have an unique name" on 1.11.2 -
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.
Read more >
Graphql - what constitutes an operation having a unique name?
I am having trouble making my code generator run. The reason given is that Not all operations have an unique name: AllIssueGroups.
Read more >
Unity Addressable Asset system | Addressables | 1.11.2
Making an asset "Addressable" allows you to use that asset's unique address to call it from anywhere. Whether that asset resides in the...
Read more >
Chapter 1. Troubleshooting Red Hat Advanced Cluster ...
Identifying the problem: Cluster with pending import status. Run the following command on the managed cluster to view the Kubernetes pod names that...
Read more >
Troubleshooting Oracle Internet Directory
This section contains a list of all the Oracle directory server error messages that you can ... The client does not have access...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found