-
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(query-planner): handle multiple __typename selections (#3164)
### Problem The sibling typename optimization treated `__typename` and `__typename @Skip(if:$X)` interchangeably. Thus, one could become a sibling of the other, depending on the order they appear in query. That is problematic, since sibling typename should not have directives or aliases. Also, there was another bug in `selectionsInPrintOrder` function where some __typename selections with directives could be dropped unexpectedly if there are multiple __typename selections in the same selection set. ### Fix Summary - fixed sibling typename optimization to only fold plain __typename without alias/directives. - fixed `selectionsInPrintOrder` to not drop duplicate __typename selections with directives.
- Loading branch information
Showing
4 changed files
with
88 additions
and
4 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/federation-internals": patch | ||
"@apollo/query-planner": patch | ||
--- | ||
|
||
Fixed a bug that `__typename` with applied directives gets lost in fetch operations. | ||
|
||
The sibling typename optimization used by query planner simplifies operations by folding `__typename` selections into their sibling selections. However, that optimization does not account for directives or aliases. The bug was applying the optimization even if the `__typename` has directives on it, which caused the selection to lose its directives. Now, `__typename` with directives (or aliases) are excluded from the optimization. |
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
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
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