Graphql-code-generator: Multiple queries importing the same fragment results in unique name error on the queries

Created on 10 Jan 2020  ·  6Comments  ·  Source: dotansimha/graphql-code-generator

Describe the bug

On 1.11.2 I'm getting errors generating my documents. In this simple example, I have a User query and a Users query. Each one imports a fragment from another file using the #import ... syntax. I'm getting a unique error on User even though it's declared in only one place. Something about the import must be declaring it twice?

  ✔ Parse configuration
  ❯ Generate outputs
    ❯ Generate types.ts
      ✔ Load GraphQL schemas
      ✔ Load GraphQL documents
      ✖ Generate
        → Not all operations have an unique name: User


 Found 1 error

  ✖ types.ts
    Not all operations have an unique name

    * User found in:

          - /sandbox/documents/user.graphql
          - /sandbox/documents/users.graphql
    Error: Not all operations have an unique name: User

This Worked fine on 1.9.1. I tried the latest 1.11.3 alphas and it's still broken.

To Reproduce

Sandbox: https://codesandbox.io/s/autumn-hooks-2627b

Expected behavior
It generates my document without errors.

Environment:

  • OS: macOS 11.15.2
  • @graphql-codegen/...: 1.11.2
  • NodeJS: 10.17
bug core

Most helpful comment

I am having the same problem, had to downgrade to v1.9.1

All 6 comments

You can disable GraphQL Codegen's import processing by passing skipGraphQLImport: true.

@ardatan I tried setting this config option and it made no difference?

I am having the same problem, had to downgrade to v1.9.1

@ashutoshrishi @dmarkow how did you pass skipGraphQLImport? can you share your config?

@dotansimha Yes, it didn't help. However, it looks like a newer issue was created after mine that's the same thing: #3326 -- as suggested there, 1.11.3-alpha-bb009c96.52 fixes the issue.

Cool, so I'm closing this and we can track it in https://github.com/dotansimha/graphql-code-generator/issues/3326

Thanks!

Was this page helpful?
0 / 5 - 0 ratings