Skip to content

fix(validation): keep argument defaults inside fragments - #4865

Open
SashaMIT wants to merge 1 commit into
graphql:17.x.xfrom
SashaMIT:fix/fragment-argument-default
Open

SashaMIT wants to merge 1 commit into
graphql:17.x.xfrom
SashaMIT:fix/fragment-argument-default

Conversation

@SashaMIT

@SashaMIT SashaMIT commented Oct 9, 2026

Copy link
Copy Markdown

Summary

A nullable variable used on a non-null argument is allowed when that argument has a default. Variable usages inside a fragment were recorded with no location default, so url(height: $h) inside a fragment was rejected while the same field inline was accepted.

The fragment usage now keeps the argument default from typeInfo.getDefaultValue(). An argument without a default is still rejected. A variable default of null is still rejected.

Test plan

  • npm run node:test -- src/validation/__tests__/VariablesInAllowedPositionRule-test.ts (38 passed)
  • Reverted the fragment default. The new case failed with Variable "$intVar" of type "Int" used in position expecting type "Int!".
  • Restored it. That case is valid, and Int => Int! within fragment still reports that error when the argument has no default.
  • eslint and prettier --check passed on the two files.

Fixes #4864

A nullable variable on a non-null argument is allowed when that argument has a default. Usages recorded from a fragment dropped the default, so the same query was rejected only in the fragment form.
@vercel

vercel Bot commented Oct 9, 2026

Copy link
Copy Markdown

@SashaMIT is attempting to deploy a commit to the The GraphQL Foundation Team on Vercel.

A member of the Team first needs to authorize it.

@linux-foundation-easycla

linux-foundation-easycla Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: SashaMIT / name: Sasha Mitchell (c8766c8)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VariablesInAllowedPositionRule ignores argument defaults for variables used inside fragments (v17 regression)

1 participant