Repository navigation
Conversation
Add a `relational_items_type_label` function to the `polymorphic` fixture and a query test that reads computed fields through the relational interface, a relational implementation and the single-table interface. Update the schema snapshots with the expected fields. On main the fields do not exist on these types.
Computed fields (functions that accept a table's row) were not added to the interface of a polymorphic table (`mode:single` or `mode:relational`), only to its implementations - and for `mode:relational` not even to those, since the function accepts the root's row type rather than an implementation's. See the removed TODO about computed columns on polymorphic types. Add them to the interface, and for `mode:relational` also to each implementation: its plan follows the relation(s) from the implementation's row to the root's row, which the function accepts.
🦋 Changeset detectedLatest commit: 845dbe7 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 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.
Addresses #1951.
A function that takes a polymorphic table's row (a computed column) is not added to the table's interface, for
mode:singleandmode:relational. Formode:relationalit is not added to the implementations either, since the function takes the root's row type, not an implementation's.PgCustomTypeFieldPluginhas// TODO: remove this and fix issue where computed columns are not added to polymorphic typesand// TODO: factor in where computed column is added to mode:relational base (shared) table.Visible in the existing
polymorphictest schema:single_table_items_meaning_of_lifeis on the single-table implementations but not onSingleTableItem;relational_items_meaning_of_lifeis on no type.{ allRelationalItems { nodes { __typename meaningOfLife } } } # Cannot query field "meaningOfLife" on type "RelationalItem". { allRelationalPosts { nodes { meaningOfLife } } } # Cannot query field "meaningOfLife" on type "RelationalPost".Change (
PgCustomTypeFieldPlugin)modFieldsno longer returns early forsingle/relationalinterfaces (unioninterfaces still do).codec.extensions.relationalInterfaceCodecName(set byPgPolymorphismPlugin), at any depth.Performance: on a relational implementation the function is evaluated from the root row reached by a relation. Non-polymorphic tables are unchanged.
#3066 (
@applyToTypefor computed columns) touches the same file; the two are complementary and one will need a rebase.Commits
test(graphile-build-pg): addspolymorphic.relational_items_type_label(relational_items)to the fixture,__tests__/queries/polymorphic/computed-fields.test.graphqlwith snapshots (fields read through the relational interface, a relational implementation and the single-table interface; values checked against the root row), and the expected updates of four schema snapshots (meaningOfLifeandtypeLabelon both interfaces and on the five relational implementations). On main:fix(graphile-build-pg): the change above + changeset.Test Suites: 5 passed, 5 total; Tests: 16 passed, 16 total.Verification
Run on this branch against PostgreSQL 17 (UTF8):
postgraphile/postgraphilefulljest: 236 passed, 236 total, 804 passed, 804 total;yarn test:schema-exports: passes;EXPORT_SCHEMA=typeDefs jest __tests__/queries __tests__/mutations: 730 passed, 730 total;EXPORT_SCHEMA=graphql-js jest __tests__/queries/polymorphic __tests__/queries/refs: 163 passed, 163 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.