fix(OverlappingFieldsCanMerge): fix var scope for fragment comparison cache - #4853
Merged
Merged
Conversation
… cache
Previously, OverlappingFieldsCanMerge mistakenly used getFragmentSignature() while visiting a SelectionSet, rather than using getFragmentSignatureByName() while entering the enclosing FragmentDefinition. getFragmentSignature() is only populated while visiting a FragmentSpread, so selection sets inside fragment definitions were processed without their fragment variable scope.
This could make the comparison cache confuse identical-looking spreads from a fragment definition and an operation. After checking the fragment, OverlappingFieldsCanMerge could incorrectly skip the operation's separate conflict. For example:
fragment Outer($x: Int, $y: Int) on Type {
...WithArgs(x: $x)
...WithArgs(x: $y)
}
fragment WithArgs($x: Int) on Type {
a(x: $x)
}
query Example($x: Int, $y: Int) {
...WithArgs(x: $x)
...WithArgs(x: $y)
}
Previously, the conflict in Outer was reported but the conflict in Example was not. This PR fixes that mistake.
|
@yaacovCR is attempting to deploy a commit to the The GraphQL Foundation Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Previously,
OverlappingFieldsCanMergemistakenly usedgetFragmentSignature()while visiting aSelectionSet.getFragmentSignature()is a helper only populated while visiting aFragmentSpreadto assist with argument validation. This mistake led to processing of selection sets inside fragment definitions without their fragment variable scope.Without the scope, the comparison cache confuses identical-looking spreads from a fragment definition and an operation. After checking the fragment,
OverlappingFieldsCanMergewould incorrectly skip the operation's separate conflict. For example:Previously, the conflict in
Outerwas reported but the conflict inExamplewas not. This PR fixes that mistake by usinggetFragmentSignatureByName()while entering the enclosingFragmentDefinitionand saving the current fragment.