Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix assertion error on some multi-field
@requires
dependencies (#2575)
When handling a `@requires`, the code gathers what it expected to be the set of "fetch groups" needed to fulfill the requirement, but in the rare cases, the same group can be added multiple times and in that case it was not de-duplicated. This duplication was unexpected by the rest of the code, ultimately leading to triggering an assertion. This would happen when a `@requires` was on multiple fields, and one of those field was also a condition (say a key) for another of the required field. Co-authored-by: Sylvain Lebresne <lebresene@gmail.com>
- Loading branch information
Sylvain Lebresne
and
Sylvain Lebresne
committed
May 15, 2023
1 parent
3f9a2c5
commit cb7f414
Showing
3 changed files
with
129 additions
and
6 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,11 @@ | ||
--- | ||
"@apollo/query-planner": patch | ||
--- | ||
|
||
Fix potential assertion error during query planning in some multi-field `@requires` case. This error could be triggered | ||
when a field in a `@requires` depended on another field that was also part of that same requires (for instance, if a | ||
field has a `@requires(fields: "id otherField")` and that `id` is also a key necessary to reach the subgraph providing | ||
`otherField`). | ||
|
||
The assertion error thrown in that case contained the message `Root groups (...) should have no remaining groups unhandled (...)` | ||
|
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