Thanks to visit codestin.com
Credit goes to github.com

Skip to content

OneOf Inhabitability#4564

Open
jbellenger wants to merge 2 commits intographql:nextfrom
jbellenger:jbellenger-oneof-inhabitability
Open

OneOf Inhabitability#4564
jbellenger wants to merge 2 commits intographql:nextfrom
jbellenger:jbellenger-oneof-inhabitability

Conversation

@jbellenger
Copy link
Contributor

@jbellenger jbellenger commented Feb 17, 2026

This PR implements the validation described at graphql/graphql-spec#1211

More discussion is at the link above, but the core issue is around uninhabited OneOf types -- the property that a type can be defined in a way that a value cannot be generated for it.

The simplest example of an uninhabited type is this recursive OneOf:

input A @oneOf { a:A }

While this type definition is currently valid by the rules of OneOf types and circular input types, it violates the spirit of the Circular References because it does not allow construction of a finite value.

This PR updates the existing cycle validation to consider OneOf types. I've tried to follow the existing conventions, though I'm also new here and might have missed something. Any feedback on style or substance is welcome.

@vercel
Copy link

vercel bot commented Feb 17, 2026

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

A member of the Team first needs to authorize it.

@jbellenger jbellenger changed the base branch from 16.x.x to v17-alpha February 17, 2026 12:29
@jbellenger jbellenger changed the base branch from v17-alpha to next February 17, 2026 12:35
@jbellenger jbellenger marked this pull request as ready for review February 17, 2026 13:29
@jbellenger jbellenger requested a review from a team as a code owner February 17, 2026 13:29
@jbellenger jbellenger force-pushed the jbellenger-oneof-inhabitability branch from 64e8899 to bd3e1bf Compare February 26, 2026 20:27
Copy link
Member

@benjie benjie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great tests! (It's 10:30pm so I've not tried to review the code... 😅)

Rework the circular references validation to detect input object types
that cannot be provided a finite value. This covers:

- Self-recursive OneOf types (e.g. input A @OneOf { a: A })
- Mixed OneOf/non-OneOf cycles with no escape path
- Standard non-null circular references (existing behavior preserved)

Rename algorithms to match spec terminology:
- InputObjectHasUnbreakableCycle (was InputObjectCanBeProvidedAFiniteValue)
- InputFieldTypeHasUnbreakableCycle (was FieldTypeCanBeProvidedAFiniteValue)
@jbellenger jbellenger force-pushed the jbellenger-oneof-inhabitability branch from bd3e1bf to ba19546 Compare February 28, 2026 12:51
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.

2 participants