Title: Backport to 26.1: Fix covariance checks for SDL type extensions by andimarek · Pull Request #4444 · graphql-java/graphql-java · GitHub
Open Graph Title: Backport to 26.1: Fix covariance checks for SDL type extensions by andimarek · Pull Request #4444 · graphql-java/graphql-java
X Title: Backport to 26.1: Fix covariance checks for SDL type extensions by andimarek · Pull Request #4444 · graphql-java/graphql-java
Description: Backport of #4420 to the 26.x maintenance 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, Dog implements Pet through an extension. Returning Dog for a field declared as Pet is valid covariance: type Query { base: Base } interface Pet { id: ID } type Dog { id: ID } extend type Dog implements Pet type Base { foo: String } interface PetContainer { pet: Pet } extend type Base implements PetContainer { 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: type Query { base: Base } interface Pet { id: ID } interface WorkingPet { id: ID } extend interface WorkingPet implements Pet interface PetContainer { pet: Pet } type Base implements PetContainer { 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: type Query { base: Base } type Cat { id: ID } type Dog { id: ID } union Pets = Cat extend union Pets = Dog interface PetContainer { pet: Pets } type Base implements PetContainer { 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: type Query { base: Base } interface Pet { id: ID } type Dog { id: ID } extend type Dog implements Pet interface PetContainer { pets: [Pet]! } type Base implements PetContainer { 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: type Query { base: Base } interface Pet { id: ID } interface Vehicle { id: ID } type Car { id: ID } extend type Car implements Vehicle interface PetContainer { pet: Pet } type Base implements PetContainer { pet: Car } This schema is still rejected because Car implements Vehicle, not Pet.
Open Graph Description: Backport of #4420 to the 26.x maintenance branch. Problem GraphQL Java incorrectly rejected valid covariant field return types when the subtype relationship was introduced by an SDL extension rathe...
X Description: Backport of #4420 to the 26.x maintenance branch. Problem GraphQL Java incorrectly rejected valid covariant field return types when the subtype relationship was introduced by an SDL extension rathe...
Opengraph URL: https://github.com/graphql-java/graphql-java/pull/4444
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:93c81077-5649-f776-c1f4-96ecc34753f6 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | AD28:3EED53:E0E771:12C6D0D:6AED47C2 |
| html-safe-nonce | 8c88e7b206557a9f71f1e23b3ca138289e491a3eded62b7068d1da5daa3a27a9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRDI4OjNFRUQ1MzpFMEU3NzE6MTJDNkQwRDo2QUVENDdDMiIsInZpc2l0b3JfaWQiOiI1NjE2MDE1MjM0Mjg0MTI4MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a0c577c5cb54431cb86874b1137da212541d3975f89242092548e079fbbd858c |
| hovercard-subject-tag | pull_request:4317486832 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/graphql-java/graphql-java/pull/4444/files |
| twitter:image | https://avatars.githubusercontent.com/u/1706744?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/1706744?s=400&v=4 |
| og:image:alt | Backport of #4420 to the 26.x maintenance branch. Problem GraphQL Java incorrectly rejected valid covariant field return types when the subtype relationship was introduced by an SDL extension rathe... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 56fb42677ae87ed3e64410323d67980aa65d0485568a7858f874e7edfc6d1c11 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/graphql-java/graphql-java git https://github.com/graphql-java/graphql-java.git |
| octolytics-dimension-user_id | 14289921 |
| octolytics-dimension-user_login | graphql-java |
| octolytics-dimension-repository_id | 38602457 |
| octolytics-dimension-repository_nwo | graphql-java/graphql-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 38602457 |
| octolytics-dimension-repository_network_root_nwo | graphql-java/graphql-java |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9c9a37e2423ed382cf39f70b5aa4b4858b40a3b0 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width