You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GraphQL Java incorrectly rejected valid covariant field return types when the subtype relationship was introduced by an SDL extension rather than declared on the base type.
Object extension example
In this schema, Dog implements Pet through an extension. Returning Dog for a field declared as Pet is valid covariance:
typeQuery {
base: Base
}
interfacePet {
id: ID
}
typeDog {
id: ID
}
extendtypeDogimplementsPettypeBase {
foo: String
}
interfacePetContainer {
pet: Pet
}
extendtypeBaseimplementsPetContainer {
pet: Dog
}
The schema was incorrectly rejected because the covariance check only inspected the base definition of Dog and did not see extend type Dog implements Pet.
Interface extension example
The same problem affected interfaces inheriting from other interfaces through extensions:
typeQuery {
base: Base
}
interfacePet {
id: ID
}
interfaceWorkingPet {
id: ID
}
extendinterfaceWorkingPetimplementsPetinterfacePetContainer {
pet: Pet
}
typeBaseimplementsPetContainer {
pet: WorkingPet
}
WorkingPet is a valid covariant return type for Pet, but the extension-based relationship was previously ignored.
Union extension example
Union members introduced through extensions were also missed:
typeQuery {
base: Base
}
typeCat {
id: ID
}
typeDog {
id: ID
}
unionPets = CatextendunionPets = DoginterfacePetContainer {
pet: Pets
}
typeBaseimplementsPetContainer {
pet: Dog
}
Dog is a valid subtype of Pets, but the previous check only inspected members declared on the base union.
Summary
TypeDefinitionRegistry stores base SDL definitions and extension definitions separately. This change makes the registry use the logical base-plus-extension relationships when:
checking whether an object or interface is a possible type of an interface
checking whether an object is a possible type of a union
checking covariant field return types, including nested list and non-null wrappers
finding object and interface implementations of an interface
This matches graphql-js behavior. graphql-js materializes extensions into its schema types before subtype checks; GraphQL Java retains separate AST definitions and now combines them when answering the equivalent registry queries.
Wrapped covariance
The same relationship is preserved while recursively checking list and non-null wrappers:
typeQuery {
base: Base
}
interfacePet {
id: ID
}
typeDog {
id: ID
}
extendtypeDogimplementsPetinterfacePetContainer {
pets: [Pet]!
}
typeBaseimplementsPetContainer {
pets: [Dog!]!
}
[Dog!]! remains a valid subtype of [Pet]!.
Unrelated types remain invalid
Extension relationships are matched by their declared interface and do not make unrelated types compatible:
typeQuery {
base: Base
}
interfacePet {
id: ID
}
interfaceVehicle {
id: ID
}
typeCar {
id: ID
}
extendtypeCarimplementsVehicleinterfacePetContainer {
pet: Pet
}
typeBaseimplementsPetContainer {
pet: Car
}
This schema is still rejected because Car implements Vehicle, not Pet.
andimarek
changed the title
Fix covariance checks for SDL type extensions
Backport to 26: Fix covariance checks for SDL type extensions
Aug 19, 2026
Full HTML report: build artifact jacoco-html-report
Updated: 2026-08-19 21:13:43 UTC
andimarek
changed the title
Backport to 26: Fix covariance checks for SDL type extensions
Backport to 26.1: Fix covariance checks for SDL type extensions
Aug 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #4420 to the
26.xmaintenance branch.Problem
GraphQL Java incorrectly rejected valid covariant field return types when the subtype relationship was introduced by an SDL extension rather than declared on the base type.
Object extension example
In this schema,
DogimplementsPetthrough an extension. ReturningDogfor a field declared asPetis valid covariance:The schema was incorrectly rejected because the covariance check only inspected the base definition of
Dogand did not seeextend type Dog implements Pet.Interface extension example
The same problem affected interfaces inheriting from other interfaces through extensions:
WorkingPetis a valid covariant return type forPet, but the extension-based relationship was previously ignored.Union extension example
Union members introduced through extensions were also missed:
Dogis a valid subtype ofPets, but the previous check only inspected members declared on the base union.Summary
TypeDefinitionRegistrystores base SDL definitions and extension definitions separately. This change makes the registry use the logical base-plus-extension relationships when:This matches graphql-js behavior. graphql-js materializes extensions into its schema types before subtype checks; GraphQL Java retains separate AST definitions and now combines them when answering the equivalent registry queries.
Wrapped covariance
The same relationship is preserved while recursively checking list and non-null wrappers:
[Dog!]!remains a valid subtype of[Pet]!.Unrelated types remain invalid
Extension relationships are matched by their declared interface and do not make unrelated types compatible:
This schema is still rejected because
CarimplementsVehicle, notPet.