Skip to content

fix(OneOf): fail coercion when two fields are provided "pre-coercion-only"#4716

Merged
yaacovCR merged 1 commit intographql:17.x.xfrom
yaacovCR:pre-coercion-one-of-error
May 5, 2026
Merged

fix(OneOf): fail coercion when two fields are provided "pre-coercion-only"#4716
yaacovCR merged 1 commit intographql:17.x.xfrom
yaacovCR:pre-coercion-one-of-error

Conversation

@yaacovCR
Copy link
Copy Markdown
Contributor

@yaacovCR yaacovCR commented May 5, 2026

this is a case when two variables are provided, but one is absent

extracted from #4195

@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 added the PR: bug fix 🐞 requires increase of "patch" version number label May 5, 2026
@yaacovCR yaacovCR changed the title fix(OneOf): fail one-of coercion when two literal fields are provided fix(OneOf): fail one-of coercion when two per-coercion fields are provided May 5, 2026
…e provided

i.e. two variables, one being absent, extracted from graphql#4195
@yaacovCR yaacovCR force-pushed the pre-coercion-one-of-error branch from 17496d7 to 79ecbc8 Compare May 5, 2026 10:31
@yaacovCR yaacovCR changed the title fix(OneOf): fail one-of coercion when two per-coercion fields are provided fix(OneOf): fail one-of coercion when two pre-coercion-only fields are provided May 5, 2026
@yaacovCR yaacovCR changed the title fix(OneOf): fail one-of coercion when two pre-coercion-only fields are provided fix(OneOf): fail coercion when two fields are provided "pre-coercion-only" May 5, 2026
@yaacovCR yaacovCR merged commit 147c7ea into graphql:17.x.x May 5, 2026
21 of 22 checks passed
@yaacovCR yaacovCR deleted the pre-coercion-one-of-error branch May 5, 2026 10:40
yaacovCR added a commit that referenced this pull request May 5, 2026
…provided by a default (#4719)

~~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.
- #4709

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!
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