-
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.
Browse files
Browse the repository at this point in the history
When an `@interfaceObject` type has a field with a `@requires` and the query requests that field only for some specific implementations of the corresponding interface, then the generated query plan was sometimes invalid and could result in an invalid query to a subgraph (against a subgraph that rely on `@apollo/subgraph`, this lead the subgraph to produce an error message looking like `"The _entities resolver tried to load an entity for type X, but no object or interface type of that name was found in the schema"`). The underlying reason is that the plan was mistakenly requesting the required fields for any object of the interface (corresponding to the `@interfaceObject` in question), instead of only requesting them only for only the implementation types it needed to. Not only is that inefficient in principle, but this lead to invalid fetches because the "rewrite" logic used to fixup the `__typename` for `@interfaceObject` under the hood was only rewriting the types of the implementation types in question (only expecting those to need rewrite, which technically was correct) but was mistakenly getting values for other implementation types.
- Loading branch information
Sylvain Lebresne
authored
Apr 12, 2023
1 parent
449351d
commit 179b460
Showing
4 changed files
with
299 additions
and
50 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,13 @@ | ||
--- | ||
"@apollo/query-planner": patch | ||
"@apollo/federation-internals": patch | ||
"@apollo/gateway": patch | ||
--- | ||
|
||
Fix potential bug when an `@interfaceObject` type has a `@requires`. When an `@interfaceObject` type has a field with a | ||
`@requires` and the query requests that field only for some specific implementations of the corresponding interface, | ||
then the generated query plan was sometimes invalid and could result in an invalid query to a subgraph (against a | ||
subgraph that rely on `@apollo/subgraph`, this lead the subgraph to produce an error message looking like `"The | ||
_entities resolver tried to load an entity for type X, but no object or interface type of that name was found in the | ||
schema"`). | ||
|
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
Oops, something went wrong.