Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gateway query fails if a type is redefined #731

Closed
codeflyer opened this issue Feb 11, 2022 · 3 comments · Fixed by #734
Closed

Gateway query fails if a type is redefined #731

codeflyer opened this issue Feb 11, 2022 · 3 comments · Fixed by #734

Comments

@codeflyer
Copy link
Contributor

Hi,
I'm facing this issue using the gateway feature:

I've 2 nodes that declare the same type, it's a wrapper to normalise the return list:

    type PageInfo {
      edges: [User]
    }

The first node declare and resolve the User type

  extend type Query {
      me: User
    }

    type PageInfo {
      edges: [User]
    }

    type User @key(fields: "id") {
      id: ID!
      name: String
      username: String
    }

The second one has a query that return the list of the users:

    extend type Query {
      meWrap: PageInfo
      meWrapDifferentName: PageInfoRenamed
    }

    type PageInfoRenamed {
      edges: [User]
    }
    
    type PageInfo {
      edges: [User]
    }
    
    type User @key(fields: "id") @extends {
      id: ID! @external
    }

The query that uses the type with a diffrent name, works properly as expected:

   {
        meWrapDifferentName { edges { name }  }
   }

Instead the query that used the type that's declared in the other node as well fails:

   {
        meWrap { edges { name }  }
   }

with the error:

Cannot query field \"edges\" on type \"Query\".

A test file that replicate the issue is available here:

#730

@mcollina
Copy link
Collaborator

Can you please make a reproducible example?

I don't understand why you are redefining the type.

@mcollina
Copy link
Collaborator

Why are you not using the @external directive on edges?

@codeflyer
Copy link
Contributor Author

I-ve created a test in the PR in the comment, this the direct link to the file:
https://github.com/mercurius-js/mercurius/blob/c03f25657400323a93f0744ad13617db51f30300/test/gateway/type-redefined.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants