-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix cases where fragment could be reused but weren't (#2541)
The main case that was handled properly was the case where a fragment that is on an abstract type is applied somewhere where the "current type" is an object type. In that case, some sub-parts (the one that don't match the "curren type") of the fragment are effectively "dead branches", but the code was still trying to matching those in the result, preventing some reuse of the fragment. Another smaller issue was that we sometimes weren't correctly reusing fragments at the very top of a "selection set". This didn't really matter too much for queries in practice, but this was also impacting some case where fragments where use at the top level of some other fragments, also preventing a few reuse. Lastly, fixing this highlighted the fact that the we were always using fragments from the original query, so against the API schema, even when building subgraph queries, and this was creating issues (the code was trying to compensate for this is a few places, but this was confusing and was not covering all cases correctly). So the patch clean this up too, and rebased fragments on subgraph before trying to use them for optimizing said subgraph fetches, ensuring that the code don't mix element from different schema.
- Loading branch information
Sylvain Lebresne
authored
May 3, 2023
1 parent
ec1ac9c
commit f6a8c1c
Showing
4 changed files
with
394 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
"@apollo/query-planner": patch | ||
"@apollo/federation-internals": patch | ||
--- | ||
|
||
Improves the heuristics used to try to reuse the query named fragments in subgraph fetches. Said fragment will be reused | ||
more often, which can lead to smaller subgraph queries (and hence overall faster processing). | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.