Skip to content

Fix non-null union field implements nullable union interface field - #4467

Open
tonyghita wants to merge 1 commit into
graphql-java:masterfrom
tonyghita:fix-interface-union-nullability
Open

Fix non-null union field implements nullable union interface field#4467
tonyghita wants to merge 1 commit into
graphql-java:masterfrom
tonyghita:fix-interface-union-nullability

Conversation

@tonyghita

@tonyghita tonyghita commented Aug 28, 2026

Copy link
Copy Markdown

According to the spec IsValidImplementationFieldType(), concrete type fields are able to strengthen the nullability guarantees made by an interface type field.

interface I { f: F }
type T implements I { f: F! }

This mostly happens except when the field is a Union type.

type A { a: ID }
union U = A
interface I { u: U }

type B implements I {
  u: U! # valid, but treated as invalid
}

schema { query: B }

This change adds a check for objectType instanceOf GraphQLObjectType so that non-null unions fall-through to the unwrap case first.

@tonyghita

Copy link
Copy Markdown
Author

Alternatively we could always unwrap non-null first?

@andimarek

Copy link
Copy Markdown
Member

Have not looked into it further, but what about nullability inside list and list of lists?

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