Skip to content

Commit 9e143c6

Browse files
yyyyaaaclaude
andcommitted
refactor: use raw codec names (snake_case) for relation targets in _meta
Reverts the PascalCase inflection applied in 6be9101. 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. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 14ec4d1 commit 9e143c6

3 files changed

Lines changed: 46 additions & 52 deletions

File tree

graphile/graphile-settings/__tests__/__snapshots__/meta-schema.test.ts.snap

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -554,9 +554,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult
554554
},
555555
],
556556
"references": {
557-
"name": "User",
557+
"name": "user",
558558
},
559-
"type": "User",
559+
"type": "user",
560560
},
561561
{
562562
"fieldName": "comment_post_fkey",
@@ -576,9 +576,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult
576576
},
577577
],
578578
"references": {
579-
"name": "Post",
579+
"name": "post",
580580
},
581-
"type": "Post",
581+
"type": "post",
582582
},
583583
],
584584
"has": [],
@@ -825,9 +825,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult
825825
},
826826
],
827827
"references": {
828-
"name": "User",
828+
"name": "user",
829829
},
830-
"type": "User",
830+
"type": "user",
831831
},
832832
],
833833
"has": [
@@ -849,9 +849,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult
849849
},
850850
],
851851
"referencedBy": {
852-
"name": "Comment",
852+
"name": "comment",
853853
},
854-
"type": "Comment",
854+
"type": "comment",
855855
},
856856
{
857857
"fieldName": "post_post_tags",
@@ -871,9 +871,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult
871871
},
872872
],
873873
"referencedBy": {
874-
"name": "PostTag",
874+
"name": "post_tag",
875875
},
876-
"type": "PostTag",
876+
"type": "post_tag",
877877
},
878878
],
879879
"hasMany": [
@@ -895,9 +895,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult
895895
},
896896
],
897897
"referencedBy": {
898-
"name": "Comment",
898+
"name": "comment",
899899
},
900-
"type": "Comment",
900+
"type": "comment",
901901
},
902902
{
903903
"fieldName": "post_post_tags",
@@ -917,9 +917,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult
917917
},
918918
],
919919
"referencedBy": {
920-
"name": "PostTag",
920+
"name": "post_tag",
921921
},
922-
"type": "PostTag",
922+
"type": "post_tag",
923923
},
924924
],
925925
"hasOne": [],
@@ -1031,7 +1031,7 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult
10311031
},
10321032
],
10331033
"junctionTable": {
1034-
"name": "PostTag",
1034+
"name": "post_tag",
10351035
},
10361036
"leftKeyAttributes": [
10371037
{
@@ -1062,9 +1062,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult
10621062
},
10631063
],
10641064
"rightTable": {
1065-
"name": "Tag",
1065+
"name": "tag",
10661066
},
1067-
"type": "Tag",
1067+
"type": "tag",
10681068
},
10691069
],
10701070
},
@@ -1396,9 +1396,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult
13961396
},
13971397
],
13981398
"references": {
1399-
"name": "Post",
1399+
"name": "post",
14001400
},
1401-
"type": "Post",
1401+
"type": "post",
14021402
},
14031403
{
14041404
"fieldName": "post_tag_tag_fkey",
@@ -1418,9 +1418,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult
14181418
},
14191419
],
14201420
"references": {
1421-
"name": "Tag",
1421+
"name": "tag",
14221422
},
1423-
"type": "Tag",
1423+
"type": "tag",
14241424
},
14251425
],
14261426
"has": [],
@@ -1606,9 +1606,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult
16061606
},
16071607
],
16081608
"referencedBy": {
1609-
"name": "PostTag",
1609+
"name": "post_tag",
16101610
},
1611-
"type": "PostTag",
1611+
"type": "post_tag",
16121612
},
16131613
],
16141614
"hasMany": [
@@ -1630,9 +1630,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult
16301630
},
16311631
],
16321632
"referencedBy": {
1633-
"name": "PostTag",
1633+
"name": "post_tag",
16341634
},
1635-
"type": "PostTag",
1635+
"type": "post_tag",
16361636
},
16371637
],
16381638
"hasOne": [],
@@ -1744,7 +1744,7 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult
17441744
},
17451745
],
17461746
"junctionTable": {
1747-
"name": "PostTag",
1747+
"name": "post_tag",
17481748
},
17491749
"leftKeyAttributes": [
17501750
{
@@ -1775,9 +1775,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult
17751775
},
17761776
],
17771777
"rightTable": {
1778-
"name": "Post",
1778+
"name": "post",
17791779
},
1780-
"type": "Post",
1780+
"type": "post",
17811781
},
17821782
],
17831783
},
@@ -1989,9 +1989,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult
19891989
},
19901990
],
19911991
"referencedBy": {
1992-
"name": "Comment",
1992+
"name": "comment",
19931993
},
1994-
"type": "Comment",
1994+
"type": "comment",
19951995
},
19961996
{
19971997
"fieldName": "user_posts",
@@ -2011,9 +2011,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult
20112011
},
20122012
],
20132013
"referencedBy": {
2014-
"name": "Post",
2014+
"name": "post",
20152015
},
2016-
"type": "Post",
2016+
"type": "post",
20172017
},
20182018
],
20192019
"hasMany": [
@@ -2035,9 +2035,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult
20352035
},
20362036
],
20372037
"referencedBy": {
2038-
"name": "Comment",
2038+
"name": "comment",
20392039
},
2040-
"type": "Comment",
2040+
"type": "comment",
20412041
},
20422042
{
20432043
"fieldName": "user_posts",
@@ -2057,9 +2057,9 @@ exports[`MetaSchemaPlugin snapshot scenarios produces stable metadata for a mult
20572057
},
20582058
],
20592059
"referencedBy": {
2060-
"name": "Post",
2060+
"name": "post",
20612061
},
2062-
"type": "Post",
2062+
"type": "post",
20632063
},
20642064
],
20652065
"hasOne": [],

graphile/graphile-settings/__tests__/meta-schema.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,8 +1560,8 @@ describe('MetaSchemaPlugin', () => {
15601560
expect(post.relations.manyToMany).toHaveLength(1);
15611561
expect(post.relations.manyToMany[0]).toMatchObject({
15621562
fieldName: 'tags',
1563-
type: 'Tag',
1564-
junctionTable: { name: 'PostTag' },
1563+
type: 'tag',
1564+
junctionTable: { name: 'post_tag' },
15651565
junctionLeftConstraint: {
15661566
name: 'post_post_tags',
15671567
referencedTable: 'post',
@@ -1572,7 +1572,7 @@ describe('MetaSchemaPlugin', () => {
15721572
referencedTable: 'tag',
15731573
referencedFields: ['id'],
15741574
},
1575-
rightTable: { name: 'Tag' },
1575+
rightTable: { name: 'tag' },
15761576
});
15771577
expect(post.relations.manyToMany[0].junctionLeftKeyAttributes.map((f: any) => f.name)).toEqual([
15781578
'postId',

graphile/graphile-settings/src/plugins/meta-schema/relation-meta-builders.ts

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { safeInflection } from './inflection-utils';
22
import {
33
buildForeignKeyConstraint,
44
} from './constraint-meta-builders';
5-
import { resolveTableType } from './name-meta-builders';
65
import { buildFieldList, type BuildContext } from './table-meta-context';
76
import {
87
getRelation,
@@ -45,14 +44,13 @@ export function buildBelongsToRelations(
4544
);
4645

4746
const remoteCodec = relation.remoteResource?.codec;
48-
const remoteTableType = remoteCodec ? resolveTableType(context.build, remoteCodec) : null;
4947

5048
belongsTo.push({
5149
fieldName: relationName,
5250
isUnique,
53-
type: remoteTableType || remoteCodec?.name || null,
51+
type: remoteCodec?.name || null,
5452
keys: buildFieldList(localAttributes, codec, attributes, context),
55-
references: { name: remoteTableType || remoteCodec?.name || 'unknown' },
53+
references: { name: remoteCodec?.name || 'unknown' },
5654
});
5755
}
5856

@@ -78,14 +76,13 @@ export function buildReverseRelations(
7876
);
7977

8078
const remoteCodec = relation.remoteResource?.codec;
81-
const remoteTableType = remoteCodec ? resolveTableType(context.build, remoteCodec) : null;
8279

8380
const meta: HasRelation = {
8481
fieldName: relationName,
8582
isUnique,
86-
type: remoteTableType || remoteCodec?.name || null,
83+
type: remoteCodec?.name || null,
8784
keys: buildFieldList(relation.localAttributes || [], codec, attributes, context),
88-
referencedBy: { name: remoteTableType || remoteCodec?.name || 'unknown' },
85+
referencedBy: { name: remoteCodec?.name || 'unknown' },
8986
};
9087

9188
if (isUnique) {
@@ -181,13 +178,10 @@ function buildManyToManyRelation(
181178
context,
182179
);
183180

184-
const rightTableType = resolveTableType(context.build, rightCodec);
185-
const junctionTableType = resolveTableType(context.build, junctionCodec);
186-
187181
return {
188182
fieldName: relationFieldName,
189-
type: rightTableType || rightCodec.name || null,
190-
junctionTable: { name: junctionTableType || junctionCodec.name || 'unknown' },
183+
type: rightCodec.name || null,
184+
junctionTable: { name: junctionCodec.name || 'unknown' },
191185
junctionLeftConstraint,
192186
junctionLeftKeyAttributes: buildFieldList(
193187
leftJunctionAttributes,
@@ -214,7 +208,7 @@ function buildManyToManyRelation(
214208
rightCodec.attributes,
215209
context,
216210
),
217-
rightTable: { name: rightTableType || rightCodec.name || 'unknown' },
211+
rightTable: { name: rightCodec.name || 'unknown' },
218212
};
219213
}
220214

0 commit comments

Comments
 (0)