Skip to content

fix: detect default-value changes on input object fields#4832

Merged
yaacovCR merged 1 commit into
graphql:17.x.xfrom
spokodev:fix/input-field-default-value-change
Jul 3, 2026
Merged

fix: detect default-value changes on input object fields#4832
yaacovCR merged 1 commit into
graphql:17.x.xfrom
spokodev:fix/input-field-default-value-change

Conversation

@spokodev

@spokodev spokodev commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

findSchemaChanges, findDangerousChanges and findBreakingChanges detect a default-value change on a field argument and on a directive argument, but not on an input object field. Changing the default value of an input-object field is a dangerous change: a client that omits that field gets different behavior after the change. Tooling and CI gates that rely on these functions (schema registries, the graphql-inspector action, custom "is this change safe" checks) ship such a change with no warning.

Cause

src/utilities/findSchemaChanges.ts, findInputObjectTypeChanges compares the field type and description but never compares the default value, unlike the sibling findArgChanges. The gap is long-standing (v16 has the same omission).

Fix

Compare the input-field default value the same way findArgChanges does (via getDefaultValue, which runs sortValueNode so object-field reordering is ignored), and report:

  • INPUT_FIELD_DEFAULT_VALUE_CHANGE (dangerous) when a default is changed or removed,
  • INPUT_FIELD_DEFAULT_VALUE_ADDED (safe) when a default is added.

These are new members alongside the existing REQUIRED_INPUT_FIELD_ADDED / OPTIONAL_INPUT_FIELD_ADDED, so an input-field change is reported under an input-field type rather than reusing the argument type.

Added a test in findBreakingChanges-test.ts covering a removed, changed, and list default. It fails before this change (the input-field changes are not reported); the findBreakingChanges and findSchemaChanges suites (55) stay green, and tsc, eslint and prettier pass.

findSchemaChanges, findDangerousChanges and findBreakingChanges detect a
default-value change on a field argument and a directive argument, but not
on an input object field. Changing an input-field default is a dangerous
change: a client that omits the field gets different behavior afterward, so
schema-evolution checks that rely on these functions miss it.

Compare the input-field default the same way findArgChanges does and report
INPUT_FIELD_DEFAULT_VALUE_CHANGE (dangerous) on change or removal and
INPUT_FIELD_DEFAULT_VALUE_ADDED (safe) on addition, alongside the existing
REQUIRED_INPUT_FIELD_ADDED / OPTIONAL_INPUT_FIELD_ADDED members.
@vercel

vercel Bot commented Jul 2, 2026

Copy link
Copy Markdown

@spokodev 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 Jul 2, 2026

Copy link
Copy Markdown

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

  • ✅ login: spokodev / name: Yarchik (ac64565)

@yaacovCR yaacovCR added the PR: bug fix 🐞 requires increase of "patch" version number label Jul 3, 2026
@yaacovCR

yaacovCR commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Thanks so much for contributing. Will merge this as a bug-fix.

@yaacovCR yaacovCR merged commit 101de34 into graphql:17.x.x Jul 3, 2026
23 of 24 checks passed
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Jul 3, 2026
## v17.0.2 (2026-07-03)

#### Bug Fix 🐞
* [graphql#4832](graphql#4832) fix: detect default-value changes on input object fields ([@spokodev](https://github.com/spokodev))

#### Polish 💅
* [graphql#4829](graphql#4829) fix(mapSchemaConfig): fix context for schema argument mapper ([@yaacovCR](https://github.com/yaacovCR))

#### Committers: 2
* null([@spokodev](https://github.com/spokodev))
* Yaacov Rydzinski ([@yaacovCR](https://github.com/yaacovCR))
@yaacovCR yaacovCR mentioned this pull request Jul 3, 2026
yaacovCR added a commit that referenced this pull request Jul 3, 2026
## v17.0.2 (2026-07-03)

#### Bug Fix 🐞
* [#4832](#4832) fix: detect default-value changes on input object fields ([@spokodev](https://github.com/spokodev))

#### Polish 💅
* [#4829](#4829) fix(mapSchemaConfig): fix context for schema argument mapper ([@yaacovCR](https://github.com/yaacovCR))

#### Committers: 2
* null([@spokodev](https://github.com/spokodev))
* Yaacov Rydzinski ([@yaacovCR](https://github.com/yaacovCR))
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.

2 participants