Improve merging of groups during @require handling #1732
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Query planning handles
@requires
by, when it needs to handle a fieldwith requires, computing a sub-plan to gather the requirements
(so-called "fetch groups") and then checking if those groups can be
merged into earlier groups to avoid needless fetches.
The test to check if we could merge into earlier groups was a bit
conservative in 2 small ways:
fetch group, one where all the selections were already parts of
its inputs. It was however possible to have a selection not strictly
included in the inputs, but just because of a few additional
__typename
. And those shouldn't prevent optimizing since we canalways move those to the parent of whichever group were were trying
to optimize away (
__typename
is essentially always resolved by allsubgraphs).
matching, but this was limiting merging when some nesting was
involved. The patch fixes this by always merging but ensuring we
properly concatenate path as needed to handle nesting.
Fixes #1725