Skip to content

fix(OneOf): fail coercion for OneOf is the single field is invalidly provided by a default#4719

Merged
yaacovCR merged 1 commit intographql:17.x.xfrom
yaacovCR:count-defined
May 5, 2026
Merged

fix(OneOf): fail coercion for OneOf is the single field is invalidly provided by a default#4719
yaacovCR merged 1 commit intographql:17.x.xfrom
yaacovCR:count-defined

Conversation

@yaacovCR
Copy link
Copy Markdown
Contributor

@yaacovCR yaacovCR commented May 5, 2026

This PR is This PR was part of a larger effort to standardize across the codebase our treatment of JS-specific value undefined as equivalent to absence of the value.

But then it turns out that because #4716 only applied to coerceInputLiteral, coerceInputValue only checked the post-coercion key number, so the distinction between omitted and undefined didn't matter. But there is a case where it does matter, if we choose to -- and we should -- fail coercion if a OneOf provides no keys but has a single default. This is an invalid case, as defaults are not allowed for OneOf, because they will all be filled in, but we should still fail coercion by checking the pre-coercion number of keys, which would be 0. And once we do that, we should treat undefined the same as omitted!

@yaacovCR yaacovCR added the PR: bug fix 🐞 requires increase of "patch" version number label May 5, 2026
@vercel
Copy link
Copy Markdown

vercel Bot commented May 5, 2026

@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 changed the title Ignore undefined one-of fields in runtime maps fix: ignore undefined one-of fields in runtime maps May 5, 2026
@yaacovCR yaacovCR changed the title fix: ignore undefined one-of fields in runtime maps fix(OneOf): fail coercion for OneOf is the single field is invalidly provided by a default May 5, 2026
Coercion should fail if there are fewer than one keys pre-coercion.

The scenario is a post-coercion single key secondary to a default. Defaults are invalid for OneOf, but this should still fail coercion.
@yaacovCR yaacovCR merged commit 5042e18 into graphql:17.x.x May 5, 2026
21 of 22 checks passed
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