-
Notifications
You must be signed in to change notification settings - Fork 257
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
Querying fragments result in incorrect downstream requests #2092
Comments
Thanks for reporting this! This may be an upstream bug as it aligns with an update to our federation v2.1.0 query planner. I'm going to check with another set of people and circle back to this. |
I've transferred this to the |
That was indeed an issue with the query planner code, and more precisely due to an issue with #1911. Tl;dr, that earlier PR make it so that we now re-use query fragments in subgraph fetches when it make sense, so the fact that the |
The code from apollographql#1911 ensures that named fragments from the user query are reused in subgraph query "when appropriate", but there were some code path where a fragment that was reused (correctly) could end up be "re-expanded" (due to an existing method not handling spreads properly). The resulting subgraph query ended up with the fragment definition existing but never being used, which is invalid in graphQL. This patch ensures that a reused fragment is not mistakenly re-expanded by the code (and thus avoids a query with unused fragments). Fixes apollographql#2092
The code from #1911 ensures that named fragments from the user query are reused in subgraph query "when appropriate", but there were some code path where a fragment that was reused (correctly) could end up be "re-expanded" (due to an existing method not handling spreads properly). The resulting subgraph query ended up with the fragment definition existing but never being used, which is invalid in graphQL. This patch ensures that a reused fragment is not mistakenly re-expanded by the code (and thus avoids a query with unused fragments). Fixes #2092
Describe the bug
It appears that while fragments in queries are resolved correctly, they are substituted inside the query while the fragment is still sent to the downstream service. This will result in an
UnusedFragment
validation error in the downstream service.This appears to be a regression in Apollo Router 0.16.0, as the problem does not occur with 0.15.1.
To Reproduce
Steps to reproduce the behavior:
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: