You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When we use a fragment in a query, in the subquery that the router builds the fragment is replaced by the selected keys and is removed from the query.
However, if the fragment refers to one of the options of a union, the router does not remove the fragment from the query after replacing it, which triggers a GRAPHQL_VALIDATION_FAILED error in the subgraph because of an unused fragment.
To Reproduce
Setup a service with the followed schema
type Employee {
job_name: String!
}
type Student {
school_name: String!
}
union UserType = Student | Employee
type User {
id: Int!
type: UserType!
}
type Query {
user: User
}
Submit request
fragment employeeFragment on Employe {
__typename
job_name
}
fragment userFragment on User {
__typename
id
type {
...employeeFragment
__typename
}
}
query test {
user {
__typename
...userFragment
}
}
See error
The generated subgraph request is supposed to be :
query test__servicea__0 {
user {
__typename
id
type {
__typename
... on Employee {
job_name
}
}
}
}
But instead the query generated for the subgraph is :
query test__servicea__0 {
user {
__typename
id
type {
__typename
... on Employee {
job_name
}
}
}
}
fragment employeeFragment on Employe {
__typename
job_name
}
This generated the error GRAPHQL_VALIDATION_FAILED on the subgraph with the message : Fragment "employeeFragment" is never used.
Desktop (please complete the following information):
OS: [e.g. iOS]
Version [e.g. 22]
Also sorry about the title of the issue, I had a hard time putting it into a sentence.
The text was updated successfully, but these errors were encountered:
Thanks for reporting this! This is a duplicate of apollographql/federation#2092 and it'll be fixed in an upcoming release that brings in the updated query planner from that other repository. You can track #1546 for the issue that will eventually bring it in.
Hello
Describe the bug
When we use a fragment in a query, in the subquery that the router builds the fragment is replaced by the selected keys and is removed from the query.
However, if the fragment refers to one of the options of a union, the router does not remove the fragment from the query after replacing it, which triggers a GRAPHQL_VALIDATION_FAILED error in the subgraph because of an unused fragment.
To Reproduce
The generated subgraph request is supposed to be :
But instead the query generated for the subgraph is :
This generated the error GRAPHQL_VALIDATION_FAILED on the subgraph with the message : Fragment "employeeFragment" is never used.
Desktop (please complete the following information):
Also sorry about the title of the issue, I had a hard time putting it into a sentence.
The text was updated successfully, but these errors were encountered: