Skip to content

fix(OverlappingFieldsCanMerge): fix var scope for fragment comparison cache - #4853

Merged
yaacovCR merged 1 commit into
graphql:17.x.xfrom
yaacovCR:fix-get-fragment-signature
Sep 4, 2026
Merged

fix(OverlappingFieldsCanMerge): fix var scope for fragment comparison cache#4853
yaacovCR merged 1 commit into
graphql:17.x.xfrom
yaacovCR:fix-get-fragment-signature

Conversation

@yaacovCR

@yaacovCR yaacovCR commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Previously, OverlappingFieldsCanMerge mistakenly used getFragmentSignature() while visiting a SelectionSet. getFragmentSignature() is a helper only populated while visiting a FragmentSpread to 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, OverlappingFieldsCanMerge would 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 by using getFragmentSignatureByName() while entering the enclosing FragmentDefinition and saving the current fragment.

… 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.
@vercel

vercel Bot commented Sep 4, 2026

Copy link
Copy Markdown

@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.

@yaacovCR yaacovCR added the PR: bug fix 🐞 requires increase of "patch" version number label Sep 4, 2026
@yaacovCR
yaacovCR merged commit 3b9d3d4 into graphql:17.x.x Sep 4, 2026
23 of 24 checks passed
@yaacovCR
yaacovCR deleted the fix-get-fragment-signature branch September 4, 2026 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: bug fix 🐞 requires increase of "patch" version number

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant