[BUG][Federation Gateway]: GraphQLError when query union types containing field with same name but different type
See original GitHub issueTaking this schema example :
With this resolver for the Body
union type:
With this query:
I am getting the error "GraphQLError: Cannot query field \"url\" on type \"TextAttributes\""
even if we have inline fragments in the query ( ...on Text {}
, ...on Image {}
)
Obviously, that the issue here comes from attributes
field name which is defined for both types - Text
and Image
and seems that for some reason it looks for Image.attributes.url
in Text
type as well.
My question is : is that GraphQL Apollo Server union type limitation ( when union types contains same field name but with different type ) or I’m missing something and some piece of schema def is wrong ?
NOTE: if I rename the attributes
field name to be unique foe each union type, it works fine.
UPDATE : This issue is produced only when using Apollo Federation , the query is executed against the Apollo’s Gateway which expose the data from different underlying data services. If we send the same query agains the particular underlying service - it works fine without any errors.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:15
- Comments:5 (3 by maintainers)
Top GitHub Comments
Seems to have been patched in
@apollo/gateway: "0.14.0"
Any update on this? Also causing a problem here.
This is 100% an issue with apollo gateway. If you run the query on just your underlying data service it works fine with the unions. However, if you run it using federation and against the gateway it fails. It seems that the federated global graph is the issue.