From 194cb57813ccb37347436466673e652aa0aa6f8c Mon Sep 17 00:00:00 2001 From: yyyyaaa Date: Wed, 25 Mar 2026 10:07:01 +0700 Subject: [PATCH 1/7] fix: emit inflected PascalCase names for all relation targets in _meta --- .../meta-schema/relation-meta-builders.ts | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/graphile/graphile-settings/src/plugins/meta-schema/relation-meta-builders.ts b/graphile/graphile-settings/src/plugins/meta-schema/relation-meta-builders.ts index d35d99547..0d65326d4 100644 --- a/graphile/graphile-settings/src/plugins/meta-schema/relation-meta-builders.ts +++ b/graphile/graphile-settings/src/plugins/meta-schema/relation-meta-builders.ts @@ -2,6 +2,7 @@ import { safeInflection } from './inflection-utils'; import { buildForeignKeyConstraint, } from './constraint-meta-builders'; +import { resolveTableType } from './name-meta-builders'; import { buildFieldList, type BuildContext } from './table-meta-context'; import { getRelation, @@ -43,12 +44,15 @@ export function buildBelongsToRelations( sameAttributes(unique.attributes, localAttributes), ); + const remoteCodec = relation.remoteResource?.codec; + const remoteTableType = remoteCodec ? resolveTableType(context.build, remoteCodec) : null; + belongsTo.push({ fieldName: relationName, isUnique, - type: relation.remoteResource?.codec?.name || null, + type: remoteTableType || remoteCodec?.name || null, keys: buildFieldList(localAttributes, codec, attributes, context), - references: { name: relation.remoteResource?.codec?.name || 'unknown' }, + references: { name: remoteTableType || remoteCodec?.name || 'unknown' }, }); } @@ -73,12 +77,15 @@ export function buildReverseRelations( sameAttributes(unique.attributes, remoteAttributes), ); + const remoteCodec = relation.remoteResource?.codec; + const remoteTableType = remoteCodec ? resolveTableType(context.build, remoteCodec) : null; + const meta: HasRelation = { fieldName: relationName, isUnique, - type: relation.remoteResource?.codec?.name || null, + type: remoteTableType || remoteCodec?.name || null, keys: buildFieldList(relation.localAttributes || [], codec, attributes, context), - referencedBy: { name: relation.remoteResource?.codec?.name || 'unknown' }, + referencedBy: { name: remoteTableType || remoteCodec?.name || 'unknown' }, }; if (isUnique) { @@ -174,10 +181,13 @@ function buildManyToManyRelation( context, ); + const rightTableType = resolveTableType(context.build, rightCodec); + const junctionTableType = resolveTableType(context.build, junctionCodec); + return { fieldName: relationFieldName, - type: rightCodec.name || null, - junctionTable: { name: junctionCodec.name || 'unknown' }, + type: rightTableType || rightCodec.name || null, + junctionTable: { name: junctionTableType || junctionCodec.name || 'unknown' }, junctionLeftConstraint, junctionLeftKeyAttributes: buildFieldList( leftJunctionAttributes, @@ -204,7 +214,7 @@ function buildManyToManyRelation( rightCodec.attributes, context, ), - rightTable: { name: rightCodec.name || 'unknown' }, + rightTable: { name: rightTableType || rightCodec.name || 'unknown' }, }; } From 662824dd747a3a66a02ba0e30ad9e43a5a267dcf Mon Sep 17 00:00:00 2001 From: yyyyaaa Date: Wed, 25 Mar 2026 10:07:13 +0700 Subject: [PATCH 2/7] fix: add case-insensitive fallback for relation table name matching --- .../query/src/generators/field-selector.ts | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/graphql/query/src/generators/field-selector.ts b/graphql/query/src/generators/field-selector.ts index 6aa295d3f..ae2ec71b4 100644 --- a/graphql/query/src/generators/field-selector.ts +++ b/graphql/query/src/generators/field-selector.ts @@ -293,11 +293,23 @@ function getRelatedTableScalarFields( return {}; } - // Find the related table in allTables - const relatedTable = allTables.find((t) => t.name === referencedTableName); + // Find the related table in allTables. + // PostGraphile v5 uses different inflections in different contexts: + // - table.name: PascalCase tableType (e.g., "Shipment", "DriverVehicleAssignment") + // - relation referencedBy.name: raw codec name (e.g., "shipments", "driverVehicleAssignments") + // Try exact match first, then case-insensitive match with optional trailing 's' for plural. + const nameLower = referencedTableName.toLowerCase(); + const nameBase = nameLower.endsWith('s') ? nameLower.slice(0, -1) : nameLower; + const relatedTable = + allTables.find((t) => t.name === referencedTableName) ?? + allTables.find((t) => { + const tLower = t.name.toLowerCase(); + return tLower === nameLower || tLower === nameBase; + }); if (!relatedTable) { - // Related table not found in schema - return empty selection - return {}; + // Related table not found in schema — return fallback { __typename: true } + // so the query remains valid (nodes need at least one subfield). + return { __typename: true }; } // Get ALL scalar fields from the related table (non-relational fields) From 661e977fccb5904d0c67c928047256349589aa43 Mon Sep 17 00:00:00 2001 From: yyyyaaa Date: Wed, 25 Mar 2026 10:07:25 +0700 Subject: [PATCH 3/7] chore: add explicit exports to graphql-query for Turbopack sub-path resolution --- graphql/query/package.json | 152 +++++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) diff --git a/graphql/query/package.json b/graphql/query/package.json index b86052b91..960ac0821 100644 --- a/graphql/query/package.json +++ b/graphql/query/package.json @@ -6,6 +6,158 @@ "main": "index.js", "module": "esm/index.js", "types": "index.d.ts", + "exports": { + ".": { + "import": "./esm/index.js", + "require": "./index.js", + "types": "./index.d.ts" + }, + "./ast": { + "import": "./esm/ast.js", + "require": "./ast.js", + "types": "./ast.d.ts" + }, + "./custom-ast": { + "import": "./esm/custom-ast.js", + "require": "./custom-ast.js", + "types": "./custom-ast.d.ts" + }, + "./executor": { + "import": "./esm/executor.js", + "require": "./executor.js", + "types": "./executor.d.ts" + }, + "./query-builder": { + "import": "./esm/query-builder.js", + "require": "./query-builder.js", + "types": "./query-builder.d.ts" + }, + "./utils": { + "import": "./esm/utils.js", + "require": "./utils.js", + "types": "./utils.d.ts" + }, + "./client": { + "import": "./esm/client/index.js", + "require": "./client/index.js", + "types": "./client/index.d.ts" + }, + "./client/error": { + "import": "./esm/client/error.js", + "require": "./client/error.js", + "types": "./client/error.d.ts" + }, + "./client/execute": { + "import": "./esm/client/execute.js", + "require": "./client/execute.js", + "types": "./client/execute.d.ts" + }, + "./client/typed-document": { + "import": "./esm/client/typed-document.js", + "require": "./client/typed-document.js", + "types": "./client/typed-document.d.ts" + }, + "./generators": { + "import": "./esm/generators/index.js", + "require": "./generators/index.js", + "types": "./generators/index.d.ts" + }, + "./generators/field-selector": { + "import": "./esm/generators/field-selector.js", + "require": "./generators/field-selector.js", + "types": "./generators/field-selector.d.ts" + }, + "./generators/mutations": { + "import": "./esm/generators/mutations.js", + "require": "./generators/mutations.js", + "types": "./generators/mutations.d.ts" + }, + "./generators/naming-helpers": { + "import": "./esm/generators/naming-helpers.js", + "require": "./generators/naming-helpers.js", + "types": "./generators/naming-helpers.d.ts" + }, + "./generators/select": { + "import": "./esm/generators/select.js", + "require": "./generators/select.js", + "types": "./generators/select.d.ts" + }, + "./introspect": { + "import": "./esm/introspect/index.js", + "require": "./introspect/index.js", + "types": "./introspect/index.d.ts" + }, + "./introspect/infer-tables": { + "import": "./esm/introspect/infer-tables.js", + "require": "./introspect/infer-tables.js", + "types": "./introspect/infer-tables.d.ts" + }, + "./introspect/schema-query": { + "import": "./esm/introspect/schema-query.js", + "require": "./introspect/schema-query.js", + "types": "./introspect/schema-query.d.ts" + }, + "./introspect/transform-schema": { + "import": "./esm/introspect/transform-schema.js", + "require": "./introspect/transform-schema.js", + "types": "./introspect/transform-schema.d.ts" + }, + "./introspect/transform": { + "import": "./esm/introspect/transform.js", + "require": "./introspect/transform.js", + "types": "./introspect/transform.d.ts" + }, + "./meta-object": { + "import": "./esm/meta-object/index.js", + "require": "./meta-object/index.js", + "types": "./meta-object/index.d.ts" + }, + "./meta-object/convert": { + "import": "./esm/meta-object/convert.js", + "require": "./meta-object/convert.js", + "types": "./meta-object/convert.d.ts" + }, + "./meta-object/validate": { + "import": "./esm/meta-object/validate.js", + "require": "./meta-object/validate.js", + "types": "./meta-object/validate.d.ts" + }, + "./types": { + "import": "./esm/types/index.js", + "require": "./types/index.js", + "types": "./types/index.d.ts" + }, + "./types/core": { + "import": "./esm/types/core.js", + "require": "./types/core.js", + "types": "./types/core.d.ts" + }, + "./types/introspection": { + "import": "./esm/types/introspection.js", + "require": "./types/introspection.js", + "types": "./types/introspection.d.ts" + }, + "./types/mutation": { + "import": "./esm/types/mutation.js", + "require": "./types/mutation.js", + "types": "./types/mutation.d.ts" + }, + "./types/query": { + "import": "./esm/types/query.js", + "require": "./types/query.js", + "types": "./types/query.d.ts" + }, + "./types/schema": { + "import": "./esm/types/schema.js", + "require": "./types/schema.js", + "types": "./types/schema.d.ts" + }, + "./types/selection": { + "import": "./esm/types/selection.js", + "require": "./types/selection.js", + "types": "./types/selection.d.ts" + } + }, "homepage": "https://github.com/constructive-io/constructive", "license": "MIT", "publishConfig": { From b67a24eef48c25419b4934e4d274c8c506ba06e6 Mon Sep 17 00:00:00 2001 From: yyyyaaa Date: Wed, 25 Mar 2026 10:35:58 +0700 Subject: [PATCH 4/7] test: update assertions and snapshots for inflected relation target names --- .../__snapshots__/meta-schema.test.ts.snap | 72 +++++++++---------- .../__tests__/meta-schema.test.ts | 6 +- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/graphile/graphile-settings/__tests__/__snapshots__/meta-schema.test.ts.snap b/graphile/graphile-settings/__tests__/__snapshots__/meta-schema.test.ts.snap index 404948ef4..3b00a9d0b 100644 --- a/graphile/graphile-settings/__tests__/__snapshots__/meta-schema.test.ts.snap +++ b/graphile/graphile-settings/__tests__/__snapshots__/meta-schema.test.ts.snap @@ -554,9 +554,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "references": { - "name": "user", + "name": "User", }, - "type": "user", + "type": "User", }, { "fieldName": "comment_post_fkey", @@ -576,9 +576,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "references": { - "name": "post", + "name": "Post", }, - "type": "post", + "type": "Post", }, ], "has": [], @@ -825,9 +825,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "references": { - "name": "user", + "name": "User", }, - "type": "user", + "type": "User", }, ], "has": [ @@ -849,9 +849,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "referencedBy": { - "name": "comment", + "name": "Comment", }, - "type": "comment", + "type": "Comment", }, { "fieldName": "post_post_tags", @@ -871,9 +871,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "referencedBy": { - "name": "post_tag", + "name": "PostTag", }, - "type": "post_tag", + "type": "PostTag", }, ], "hasMany": [ @@ -895,9 +895,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "referencedBy": { - "name": "comment", + "name": "Comment", }, - "type": "comment", + "type": "Comment", }, { "fieldName": "post_post_tags", @@ -917,9 +917,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "referencedBy": { - "name": "post_tag", + "name": "PostTag", }, - "type": "post_tag", + "type": "PostTag", }, ], "hasOne": [], @@ -1031,7 +1031,7 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "junctionTable": { - "name": "post_tag", + "name": "PostTag", }, "leftKeyAttributes": [ { @@ -1062,9 +1062,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "rightTable": { - "name": "tag", + "name": "Tag", }, - "type": "tag", + "type": "Tag", }, ], }, @@ -1396,9 +1396,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "references": { - "name": "post", + "name": "Post", }, - "type": "post", + "type": "Post", }, { "fieldName": "post_tag_tag_fkey", @@ -1418,9 +1418,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "references": { - "name": "tag", + "name": "Tag", }, - "type": "tag", + "type": "Tag", }, ], "has": [], @@ -1606,9 +1606,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "referencedBy": { - "name": "post_tag", + "name": "PostTag", }, - "type": "post_tag", + "type": "PostTag", }, ], "hasMany": [ @@ -1630,9 +1630,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "referencedBy": { - "name": "post_tag", + "name": "PostTag", }, - "type": "post_tag", + "type": "PostTag", }, ], "hasOne": [], @@ -1744,7 +1744,7 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "junctionTable": { - "name": "post_tag", + "name": "PostTag", }, "leftKeyAttributes": [ { @@ -1775,9 +1775,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "rightTable": { - "name": "post", + "name": "Post", }, - "type": "post", + "type": "Post", }, ], }, @@ -1989,9 +1989,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "referencedBy": { - "name": "comment", + "name": "Comment", }, - "type": "comment", + "type": "Comment", }, { "fieldName": "user_posts", @@ -2011,9 +2011,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "referencedBy": { - "name": "post", + "name": "Post", }, - "type": "post", + "type": "Post", }, ], "hasMany": [ @@ -2035,9 +2035,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "referencedBy": { - "name": "comment", + "name": "Comment", }, - "type": "comment", + "type": "Comment", }, { "fieldName": "user_posts", @@ -2057,9 +2057,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "referencedBy": { - "name": "post", + "name": "Post", }, - "type": "post", + "type": "Post", }, ], "hasOne": [], diff --git a/graphile/graphile-settings/__tests__/meta-schema.test.ts b/graphile/graphile-settings/__tests__/meta-schema.test.ts index 6ad52365b..58f972824 100644 --- a/graphile/graphile-settings/__tests__/meta-schema.test.ts +++ b/graphile/graphile-settings/__tests__/meta-schema.test.ts @@ -1560,8 +1560,8 @@ describe('MetaSchemaPlugin', () => { expect(post.relations.manyToMany).toHaveLength(1); expect(post.relations.manyToMany[0]).toMatchObject({ fieldName: 'tags', - type: 'tag', - junctionTable: { name: 'post_tag' }, + type: 'Tag', + junctionTable: { name: 'PostTag' }, junctionLeftConstraint: { name: 'post_post_tags', referencedTable: 'post', @@ -1572,7 +1572,7 @@ describe('MetaSchemaPlugin', () => { referencedTable: 'tag', referencedFields: ['id'], }, - rightTable: { name: 'tag' }, + rightTable: { name: 'Tag' }, }); expect(post.relations.manyToMany[0].junctionLeftKeyAttributes.map((f: any) => f.name)).toEqual([ 'postId', From fa8b5cf02bd400699a70f59269b7617a3b586f28 Mon Sep 17 00:00:00 2001 From: yyyyaaa Date: Wed, 25 Mar 2026 10:44:45 +0700 Subject: [PATCH 5/7] refactor: use raw codec names (snake_case) for relation targets in _meta Reverts the PascalCase inflection applied in 6be9101b. Relation target names in _meta (type, junctionTable.name, rightTable.name, referencedBy.name, references.name) now consistently use the raw PostGraphile codec name (e.g. post_tag, tag) rather than inflected GraphQL type names (PostTag, Tag). This keeps naming uniform across the entire _meta schema and ensures the dashboard phantom-column junction filter can directly compare junctionTable.name from manyToMany entries against referencedBy.name from hasMany entries without any case normalisation. --- .../__snapshots__/meta-schema.test.ts.snap | 72 +++++++++---------- .../__tests__/meta-schema.test.ts | 6 +- .../meta-schema/relation-meta-builders.ts | 20 ++---- 3 files changed, 46 insertions(+), 52 deletions(-) diff --git a/graphile/graphile-settings/__tests__/__snapshots__/meta-schema.test.ts.snap b/graphile/graphile-settings/__tests__/__snapshots__/meta-schema.test.ts.snap index 3b00a9d0b..404948ef4 100644 --- a/graphile/graphile-settings/__tests__/__snapshots__/meta-schema.test.ts.snap +++ b/graphile/graphile-settings/__tests__/__snapshots__/meta-schema.test.ts.snap @@ -554,9 +554,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "references": { - "name": "User", + "name": "user", }, - "type": "User", + "type": "user", }, { "fieldName": "comment_post_fkey", @@ -576,9 +576,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "references": { - "name": "Post", + "name": "post", }, - "type": "Post", + "type": "post", }, ], "has": [], @@ -825,9 +825,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "references": { - "name": "User", + "name": "user", }, - "type": "User", + "type": "user", }, ], "has": [ @@ -849,9 +849,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "referencedBy": { - "name": "Comment", + "name": "comment", }, - "type": "Comment", + "type": "comment", }, { "fieldName": "post_post_tags", @@ -871,9 +871,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "referencedBy": { - "name": "PostTag", + "name": "post_tag", }, - "type": "PostTag", + "type": "post_tag", }, ], "hasMany": [ @@ -895,9 +895,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "referencedBy": { - "name": "Comment", + "name": "comment", }, - "type": "Comment", + "type": "comment", }, { "fieldName": "post_post_tags", @@ -917,9 +917,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "referencedBy": { - "name": "PostTag", + "name": "post_tag", }, - "type": "PostTag", + "type": "post_tag", }, ], "hasOne": [], @@ -1031,7 +1031,7 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "junctionTable": { - "name": "PostTag", + "name": "post_tag", }, "leftKeyAttributes": [ { @@ -1062,9 +1062,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "rightTable": { - "name": "Tag", + "name": "tag", }, - "type": "Tag", + "type": "tag", }, ], }, @@ -1396,9 +1396,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "references": { - "name": "Post", + "name": "post", }, - "type": "Post", + "type": "post", }, { "fieldName": "post_tag_tag_fkey", @@ -1418,9 +1418,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "references": { - "name": "Tag", + "name": "tag", }, - "type": "Tag", + "type": "tag", }, ], "has": [], @@ -1606,9 +1606,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "referencedBy": { - "name": "PostTag", + "name": "post_tag", }, - "type": "PostTag", + "type": "post_tag", }, ], "hasMany": [ @@ -1630,9 +1630,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "referencedBy": { - "name": "PostTag", + "name": "post_tag", }, - "type": "PostTag", + "type": "post_tag", }, ], "hasOne": [], @@ -1744,7 +1744,7 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "junctionTable": { - "name": "PostTag", + "name": "post_tag", }, "leftKeyAttributes": [ { @@ -1775,9 +1775,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "rightTable": { - "name": "Post", + "name": "post", }, - "type": "Post", + "type": "post", }, ], }, @@ -1989,9 +1989,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "referencedBy": { - "name": "Comment", + "name": "comment", }, - "type": "Comment", + "type": "comment", }, { "fieldName": "user_posts", @@ -2011,9 +2011,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "referencedBy": { - "name": "Post", + "name": "post", }, - "type": "Post", + "type": "post", }, ], "hasMany": [ @@ -2035,9 +2035,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "referencedBy": { - "name": "Comment", + "name": "comment", }, - "type": "Comment", + "type": "comment", }, { "fieldName": "user_posts", @@ -2057,9 +2057,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult }, ], "referencedBy": { - "name": "Post", + "name": "post", }, - "type": "Post", + "type": "post", }, ], "hasOne": [], diff --git a/graphile/graphile-settings/__tests__/meta-schema.test.ts b/graphile/graphile-settings/__tests__/meta-schema.test.ts index 58f972824..6ad52365b 100644 --- a/graphile/graphile-settings/__tests__/meta-schema.test.ts +++ b/graphile/graphile-settings/__tests__/meta-schema.test.ts @@ -1560,8 +1560,8 @@ describe('MetaSchemaPlugin', () => { expect(post.relations.manyToMany).toHaveLength(1); expect(post.relations.manyToMany[0]).toMatchObject({ fieldName: 'tags', - type: 'Tag', - junctionTable: { name: 'PostTag' }, + type: 'tag', + junctionTable: { name: 'post_tag' }, junctionLeftConstraint: { name: 'post_post_tags', referencedTable: 'post', @@ -1572,7 +1572,7 @@ describe('MetaSchemaPlugin', () => { referencedTable: 'tag', referencedFields: ['id'], }, - rightTable: { name: 'Tag' }, + rightTable: { name: 'tag' }, }); expect(post.relations.manyToMany[0].junctionLeftKeyAttributes.map((f: any) => f.name)).toEqual([ 'postId', diff --git a/graphile/graphile-settings/src/plugins/meta-schema/relation-meta-builders.ts b/graphile/graphile-settings/src/plugins/meta-schema/relation-meta-builders.ts index 0d65326d4..1b4a798f4 100644 --- a/graphile/graphile-settings/src/plugins/meta-schema/relation-meta-builders.ts +++ b/graphile/graphile-settings/src/plugins/meta-schema/relation-meta-builders.ts @@ -2,7 +2,6 @@ import { safeInflection } from './inflection-utils'; import { buildForeignKeyConstraint, } from './constraint-meta-builders'; -import { resolveTableType } from './name-meta-builders'; import { buildFieldList, type BuildContext } from './table-meta-context'; import { getRelation, @@ -45,14 +44,13 @@ export function buildBelongsToRelations( ); const remoteCodec = relation.remoteResource?.codec; - const remoteTableType = remoteCodec ? resolveTableType(context.build, remoteCodec) : null; belongsTo.push({ fieldName: relationName, isUnique, - type: remoteTableType || remoteCodec?.name || null, + type: remoteCodec?.name || null, keys: buildFieldList(localAttributes, codec, attributes, context), - references: { name: remoteTableType || remoteCodec?.name || 'unknown' }, + references: { name: remoteCodec?.name || 'unknown' }, }); } @@ -78,14 +76,13 @@ export function buildReverseRelations( ); const remoteCodec = relation.remoteResource?.codec; - const remoteTableType = remoteCodec ? resolveTableType(context.build, remoteCodec) : null; const meta: HasRelation = { fieldName: relationName, isUnique, - type: remoteTableType || remoteCodec?.name || null, + type: remoteCodec?.name || null, keys: buildFieldList(relation.localAttributes || [], codec, attributes, context), - referencedBy: { name: remoteTableType || remoteCodec?.name || 'unknown' }, + referencedBy: { name: remoteCodec?.name || 'unknown' }, }; if (isUnique) { @@ -181,13 +178,10 @@ function buildManyToManyRelation( context, ); - const rightTableType = resolveTableType(context.build, rightCodec); - const junctionTableType = resolveTableType(context.build, junctionCodec); - return { fieldName: relationFieldName, - type: rightTableType || rightCodec.name || null, - junctionTable: { name: junctionTableType || junctionCodec.name || 'unknown' }, + type: rightCodec.name || null, + junctionTable: { name: junctionCodec.name || 'unknown' }, junctionLeftConstraint, junctionLeftKeyAttributes: buildFieldList( leftJunctionAttributes, @@ -214,7 +208,7 @@ function buildManyToManyRelation( rightCodec.attributes, context, ), - rightTable: { name: rightTableType || rightCodec.name || 'unknown' }, + rightTable: { name: rightCodec.name || 'unknown' }, }; } From 6c9175e772ae26ffa80baca24208b2b5624a18e0 Mon Sep 17 00:00:00 2001 From: yyyyaaa Date: Wed, 25 Mar 2026 16:18:01 +0700 Subject: [PATCH 6/7] Revert "chore: add explicit exports to graphql-query for Turbopack sub-path resolution" This reverts commit e802f9b7a78e190bfc98cf79516794412081e6c7. --- graphql/query/package.json | 152 ------------------------------------- 1 file changed, 152 deletions(-) diff --git a/graphql/query/package.json b/graphql/query/package.json index 960ac0821..b86052b91 100644 --- a/graphql/query/package.json +++ b/graphql/query/package.json @@ -6,158 +6,6 @@ "main": "index.js", "module": "esm/index.js", "types": "index.d.ts", - "exports": { - ".": { - "import": "./esm/index.js", - "require": "./index.js", - "types": "./index.d.ts" - }, - "./ast": { - "import": "./esm/ast.js", - "require": "./ast.js", - "types": "./ast.d.ts" - }, - "./custom-ast": { - "import": "./esm/custom-ast.js", - "require": "./custom-ast.js", - "types": "./custom-ast.d.ts" - }, - "./executor": { - "import": "./esm/executor.js", - "require": "./executor.js", - "types": "./executor.d.ts" - }, - "./query-builder": { - "import": "./esm/query-builder.js", - "require": "./query-builder.js", - "types": "./query-builder.d.ts" - }, - "./utils": { - "import": "./esm/utils.js", - "require": "./utils.js", - "types": "./utils.d.ts" - }, - "./client": { - "import": "./esm/client/index.js", - "require": "./client/index.js", - "types": "./client/index.d.ts" - }, - "./client/error": { - "import": "./esm/client/error.js", - "require": "./client/error.js", - "types": "./client/error.d.ts" - }, - "./client/execute": { - "import": "./esm/client/execute.js", - "require": "./client/execute.js", - "types": "./client/execute.d.ts" - }, - "./client/typed-document": { - "import": "./esm/client/typed-document.js", - "require": "./client/typed-document.js", - "types": "./client/typed-document.d.ts" - }, - "./generators": { - "import": "./esm/generators/index.js", - "require": "./generators/index.js", - "types": "./generators/index.d.ts" - }, - "./generators/field-selector": { - "import": "./esm/generators/field-selector.js", - "require": "./generators/field-selector.js", - "types": "./generators/field-selector.d.ts" - }, - "./generators/mutations": { - "import": "./esm/generators/mutations.js", - "require": "./generators/mutations.js", - "types": "./generators/mutations.d.ts" - }, - "./generators/naming-helpers": { - "import": "./esm/generators/naming-helpers.js", - "require": "./generators/naming-helpers.js", - "types": "./generators/naming-helpers.d.ts" - }, - "./generators/select": { - "import": "./esm/generators/select.js", - "require": "./generators/select.js", - "types": "./generators/select.d.ts" - }, - "./introspect": { - "import": "./esm/introspect/index.js", - "require": "./introspect/index.js", - "types": "./introspect/index.d.ts" - }, - "./introspect/infer-tables": { - "import": "./esm/introspect/infer-tables.js", - "require": "./introspect/infer-tables.js", - "types": "./introspect/infer-tables.d.ts" - }, - "./introspect/schema-query": { - "import": "./esm/introspect/schema-query.js", - "require": "./introspect/schema-query.js", - "types": "./introspect/schema-query.d.ts" - }, - "./introspect/transform-schema": { - "import": "./esm/introspect/transform-schema.js", - "require": "./introspect/transform-schema.js", - "types": "./introspect/transform-schema.d.ts" - }, - "./introspect/transform": { - "import": "./esm/introspect/transform.js", - "require": "./introspect/transform.js", - "types": "./introspect/transform.d.ts" - }, - "./meta-object": { - "import": "./esm/meta-object/index.js", - "require": "./meta-object/index.js", - "types": "./meta-object/index.d.ts" - }, - "./meta-object/convert": { - "import": "./esm/meta-object/convert.js", - "require": "./meta-object/convert.js", - "types": "./meta-object/convert.d.ts" - }, - "./meta-object/validate": { - "import": "./esm/meta-object/validate.js", - "require": "./meta-object/validate.js", - "types": "./meta-object/validate.d.ts" - }, - "./types": { - "import": "./esm/types/index.js", - "require": "./types/index.js", - "types": "./types/index.d.ts" - }, - "./types/core": { - "import": "./esm/types/core.js", - "require": "./types/core.js", - "types": "./types/core.d.ts" - }, - "./types/introspection": { - "import": "./esm/types/introspection.js", - "require": "./types/introspection.js", - "types": "./types/introspection.d.ts" - }, - "./types/mutation": { - "import": "./esm/types/mutation.js", - "require": "./types/mutation.js", - "types": "./types/mutation.d.ts" - }, - "./types/query": { - "import": "./esm/types/query.js", - "require": "./types/query.js", - "types": "./types/query.d.ts" - }, - "./types/schema": { - "import": "./esm/types/schema.js", - "require": "./types/schema.js", - "types": "./types/schema.d.ts" - }, - "./types/selection": { - "import": "./esm/types/selection.js", - "require": "./types/selection.js", - "types": "./types/selection.d.ts" - } - }, "homepage": "https://github.com/constructive-io/constructive", "license": "MIT", "publishConfig": { From 57c2d5b1c5c154a1b8cd895c350a7f7a60388943 Mon Sep 17 00:00:00 2001 From: yyyyaaa Date: Wed, 25 Mar 2026 23:07:41 +0700 Subject: [PATCH 7/7] fix: add fuzzy table name matching for v5 camelCase codec relation targets --- graphql/query/src/generators/field-selector.ts | 4 ++-- graphql/query/src/generators/select.ts | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/graphql/query/src/generators/field-selector.ts b/graphql/query/src/generators/field-selector.ts index ae2ec71b4..033e8a373 100644 --- a/graphql/query/src/generators/field-selector.ts +++ b/graphql/query/src/generators/field-selector.ts @@ -298,12 +298,12 @@ function getRelatedTableScalarFields( // - table.name: PascalCase tableType (e.g., "Shipment", "DriverVehicleAssignment") // - relation referencedBy.name: raw codec name (e.g., "shipments", "driverVehicleAssignments") // Try exact match first, then case-insensitive match with optional trailing 's' for plural. - const nameLower = referencedTableName.toLowerCase(); + const nameLower = referencedTableName.toLowerCase().replace(/_/g, ''); const nameBase = nameLower.endsWith('s') ? nameLower.slice(0, -1) : nameLower; const relatedTable = allTables.find((t) => t.name === referencedTableName) ?? allTables.find((t) => { - const tLower = t.name.toLowerCase(); + const tLower = t.name.toLowerCase().replace(/_/g, ''); return tLower === nameLower || tLower === nameBase; }); if (!relatedTable) { diff --git a/graphql/query/src/generators/select.ts b/graphql/query/src/generators/select.ts index 9f158da40..72167bc71 100644 --- a/graphql/query/src/generators/select.ts +++ b/graphql/query/src/generators/select.ts @@ -788,7 +788,18 @@ function findRelatedTable( } // Find the related table in allTables - return allTables.find((tbl) => tbl.name === referencedTableName) || null; + const exactMatch = allTables.find((tbl) => tbl.name === referencedTableName); + if (exactMatch) return exactMatch; + + // Fuzzy match: case-insensitive, strip underscores, optional trailing 's'. + // Needed because relation target names from _meta use snake_case codec names + // (e.g. "routes", "delivery_zone") while allTables[].name is PascalCase (e.g. "Route", "DeliveryZone"). + const nameLower = referencedTableName.toLowerCase().replace(/_/g, ''); + const nameBase = nameLower.endsWith('s') ? nameLower.slice(0, -1) : nameLower; + return allTables.find((tbl) => { + const tLower = tbl.name.toLowerCase().replace(/_/g, ''); + return tLower === nameLower || tLower === nameBase; + }) || null; } /**