Repository navigation
Conversation
Add a `relational_root_refs` fixture (a relational polymorphic root with a `@ref` to another table) and a query test that reads the ref through the interface and through each implementation. On main the schema does not build: `Interface field Item.reviews expected but Book does not provide it`.
…ntations A `@ref` on the root of a relational polymorphic table becomes a field of the root's interface, but it was not copied to the implementations (only the root's relations were), so the schema build failed with `Interface field <Root>.<ref> expected but <Variant> does not provide it`. Copy the root's refs to each implementation, reached via the shared relation to the root, as is already done for the root's relations.
Add a `nested_polymorphism` fixture (a relational polymorphic table whose implementation is itself a relational polymorphic table) and a query test that reads it through each interface and through the leaf types. On main the schema does not build: `Interface field Truck.kind expected but BoxTruck does not provide it`.
A relational polymorphic table that is itself one of the types of another relational polymorphic table made the schema build fail (for example `Interface field Truck.kind expected but BoxTruck does not provide it`): attributes, relations and refs were only copied one level down, the leaves did not implement the outer interface, and a row was resolved using only the outermost type attribute. - Repeat the copy of attributes, relations and refs until nothing changes, so that a root's reach the leaves whatever order the tables are visited. - Only mark an attribute `identicalVia` when it is the implementation's own column, not one a previous pass copied there. - Every implementation (and every nested interface) implements the interface of each table above it. - Resolve a row to its leaf type by reading the type attribute of each root on the way down, and plan the leaf by following the relations to it.
🦋 Changeset detectedLatest commit: 4ab26b5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This was referenced Oct 15, 2026
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #3208.
Stacked on #3213 (
@refon a relational root). This branch contains that PR's two commits; the last two commits are this PR. Review withgit diff -wagainst #3213's head: about 550 raw diff lines are re-indentation from wrapping two loops in a fixpoint loop (-w: +259 / -28 inPgPolymorphismPlugin.ts).Problem
See #3208: a relational polymorphic table that is one of the
@types of another relational polymorphic table makes the schema build fail (Interface field Truck.type expected but BoxTruck does not provide it).Change (
PgPolymorphismPlugin)pgRegistry_PgRegistryBuilder_finalize) and the relation/ref copy (pgRegistry_PgRegistry) repeat until nothing changes, so a root's attributes, relations and refs reach its leaves regardless of visiting order. An attribute is markedidenticalViaonly when it is the implementation's own column (one copied on an earlier pass already hasvia).GraphQLObjectType_interfacesand a newGraphQLInterfaceType_interfaceshook declare the interface of every root above the type, transitively.planTypereads the type attribute of each root on the way down (through the relations from the base record) and resolves the row to its leaf type;planForTypefollows the relations to the leaf. For non-nested structures the existing code path is used.Performance: for a nested structure, resolving the type reads the discriminator of each nested table (one extra join per level). Non-nested structures are unchanged.
Commits (this PR)
test(graphile-build-pg):nested_polymorphismfixture (vehicles -> cars / trucks -> box_trucks / tankers, a relation on the root and one on the middle table) and__tests__/queries/polymorphic/nested.test.graphqlwith snapshots: reads throughVehicle,Truckand the leaf types with fragments at every level. On fix(graphile-build-pg): carry a relational root's refs to its implementations #3213's head:fix(graphile-build-pg): the change above + changeset.Tests: 15 passed, 15 total.Verification
Run on this branch against PostgreSQL 17 (UTF8):
postgraphile/postgraphilefulljest: 237 passed, 237 total, 818 passed, 818 total;yarn test:schema-exports: passes;EXPORT_SCHEMA=typeDefs jest __tests__/queries __tests__/mutations: 744 passed, 744 total;EXPORT_SCHEMA=graphql-js jest __tests__/queries/polymorphic __tests__/queries/refs: 177 passed, 177 total;graphile-build-pgyarn test: passes.prettier --checkandeslinton the changed files: clean. Baseline on main with the same setup: 235 suites / 792 tests, typeDefs 718, graphql-js 151, all passing. No existing snapshot changes.#3215 edits the same relation-copy loop that this PR re-indents; whichever merges second needs a trivial rebase.