-
Notifications
You must be signed in to change notification settings - Fork 254
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
__typename
rebasing for interface objects (#2886)
We should never query `__typename` from a subgraph for an object type marked `@interfaceObject`, as the value we get back will always be wrong. Normally, we prevent this by not having a `__typename` edge in the federated query graph. However, during the optimization where we try to reuse existing named fragments, we rebase them from the API schema onto the subgraph schemas. We usually ignore selections where this leads to invalidity (e.g. fields or types that don't exist in the subgraph schema), but the code doesn't currently view the `__typename` field being rebased onto an interface object as invalid. This has led to bugs where named fragments containing `__typename` accidentally cause it to be queried on interface objects in subgraph queries. This PR changes `Field.rebaseOn()` such that `__typename` being rebased onto a parent type that is an interface object is considered invalid. Additionally, if the parent type is an abstract type, and that abstract type could possibly be an interface object type at runtime, then this is additionally considered invalid.
- Loading branch information
1 parent
7b5b836
commit 74ca7dd
Showing
3 changed files
with
73 additions
and
2 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,5 @@ | ||
--- | ||
"@apollo/federation-internals": patch | ||
--- | ||
|
||
Fix query planning bug where `__typename` on interface object types in named fragments can cause query plan execution to fail. ([#2886](https://github.com/apollographql/federation/issues/2886)) |
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