|
| 1 | +diff --git a/node_modules/graphile-build-pg/dist/plugins/PgAttributesPlugin.js b/node_modules/graphile-build-pg/dist/plugins/PgAttributesPlugin.js |
| 2 | +index 88c6973..e523ea1 100644 |
| 3 | +--- a/node_modules/graphile-build-pg/dist/plugins/PgAttributesPlugin.js |
| 4 | ++++ b/node_modules/graphile-build-pg/dist/plugins/PgAttributesPlugin.js |
| 5 | +@@ -120,21 +120,25 @@ exports.PgAttributesPlugin = { |
| 6 | + add: { |
| 7 | + _attributeName(options, { attributeName, codec }) { |
| 8 | + const attribute = codec.attributes[attributeName]; |
| 9 | +- return this.coerceToGraphQLName(attribute.extensions?.tags?.name || attributeName); |
| 10 | ++ const name = attribute.extensions?.tags?.name || attributeName |
| 11 | ++ // Avoid conflict with 'id' field used for Relay. |
| 12 | ++ const nonconflictName = |
| 13 | ++ name === "id" && !codec.isAnonymous |
| 14 | ++ ? "row_id" |
| 15 | ++ : name; |
| 16 | ++ return this.coerceToGraphQLName( |
| 17 | ++ nonconflictName |
| 18 | ++ ); |
| 19 | + }, |
| 20 | + _joinAttributeNames(options, codec, names) { |
| 21 | + return names |
| 22 | + .map((attributeName) => { |
| 23 | +- return this.attribute({ attributeName, codec }); |
| 24 | ++ return this._attributeName({ attributeName, codec }); |
| 25 | + }) |
| 26 | + .join("-and-"); |
| 27 | + }, |
| 28 | + attribute(options, details) { |
| 29 | +- const attributeFieldName = this.camelCase(this._attributeName(details)); |
| 30 | +- // Avoid conflict with 'id' field used for Relay. |
| 31 | +- return attributeFieldName === "id" && !details.codec.isAnonymous |
| 32 | +- ? "rowId" |
| 33 | +- : attributeFieldName; |
| 34 | ++ return this.camelCase(this._attributeName(details)); |
| 35 | + }, |
| 36 | + }, |
| 37 | + }, |
| 38 | +diff --git a/node_modules/graphile-build-pg/dist/plugins/PgRelationsPlugin.d.ts b/node_modules/graphile-build-pg/dist/plugins/PgRelationsPlugin.d.ts |
| 39 | +index 04ed8f0..2620bb0 100644 |
| 40 | +--- a/node_modules/graphile-build-pg/dist/plugins/PgRelationsPlugin.d.ts |
| 41 | ++++ b/node_modules/graphile-build-pg/dist/plugins/PgRelationsPlugin.d.ts |
| 42 | +@@ -45,6 +45,8 @@ declare global { |
| 43 | + }): string; |
| 44 | + singleRelation(this: Inflection, details: PgRelationsPluginRelationDetails): string; |
| 45 | + singleRelationBackwards(this: Inflection, details: PgRelationsPluginRelationDetails): string; |
| 46 | ++ _singleRelationRaw(this: Inflection, details: PgRelationsPluginRelationDetails): string; |
| 47 | ++ _singleRelationBackwardsRaw(this: Inflection, details: PgRelationsPluginRelationDetails): string; |
| 48 | + _manyRelation(this: Inflection, details: PgRelationsPluginRelationDetails): string; |
| 49 | + manyRelationConnection(this: Inflection, details: PgRelationsPluginRelationDetails): string; |
| 50 | + manyRelationList(this: Inflection, details: PgRelationsPluginRelationDetails): string; |
| 51 | +diff --git a/node_modules/graphile-build-pg/dist/plugins/PgRelationsPlugin.js b/node_modules/graphile-build-pg/dist/plugins/PgRelationsPlugin.js |
| 52 | +index 117fc39..85d19fc 100644 |
| 53 | +--- a/node_modules/graphile-build-pg/dist/plugins/PgRelationsPlugin.js |
| 54 | ++++ b/node_modules/graphile-build-pg/dist/plugins/PgRelationsPlugin.js |
| 55 | +@@ -42,7 +42,7 @@ exports.PgRelationsPlugin = { |
| 56 | + const attributeNames = attributes.map((col) => col.attname); |
| 57 | + return this.camelCase(`${isUnique ? remoteName : this.pluralize(remoteName)}-by-${isReferencee ? "their" : "my"}-${attributeNames.join("-and-")}`); |
| 58 | + }, |
| 59 | +- singleRelation(options, details) { |
| 60 | ++ _singleRelationRaw(options, details) { |
| 61 | + const { registry, codec, relationName } = details; |
| 62 | + const relation = registry.pgRelations[codec.name]?.[relationName]; |
| 63 | + //const codec = relation.remoteResource.codec; |
| 64 | +@@ -52,9 +52,12 @@ exports.PgRelationsPlugin = { |
| 65 | + // E.g. posts(author_id) references users(id) |
| 66 | + const remoteType = this.tableType(relation.remoteResource.codec); |
| 67 | + const localAttributes = relation.localAttributes; |
| 68 | +- return this.camelCase(`${remoteType}-by-${this._joinAttributeNames(codec, localAttributes)}`); |
| 69 | ++ return (`${remoteType}-by-${this._joinAttributeNames(codec, localAttributes)}`); |
| 70 | + }, |
| 71 | +- singleRelationBackwards(options, details) { |
| 72 | ++ singleRelation(options, details) { |
| 73 | ++ return this.camelCase(this._singleRelationRaw(details)) |
| 74 | ++ }, |
| 75 | ++ _singleRelationBackwardsRaw(options, details) { |
| 76 | + const { registry, codec, relationName } = details; |
| 77 | + const relation = registry.pgRelations[codec.name]?.[relationName]; |
| 78 | + if (typeof relation.extensions?.tags.foreignSingleFieldName === "string") { |
| 79 | +@@ -66,9 +69,12 @@ exports.PgRelationsPlugin = { |
| 80 | + // E.g. posts(author_id) references users(id) |
| 81 | + const remoteType = this.tableType(relation.remoteResource.codec); |
| 82 | + const remoteAttributes = relation.remoteAttributes; |
| 83 | +- return this.camelCase(`${remoteType}-by-${this._joinAttributeNames(relation.remoteResource.codec, remoteAttributes)}`); |
| 84 | ++ return (`${remoteType}-by-${this._joinAttributeNames(relation.remoteResource.codec, remoteAttributes)}`); |
| 85 | + }, |
| 86 | +- _manyRelation(options, details) { |
| 87 | ++ singleRelationBackwards(options, details) { |
| 88 | ++ return this.camelCase(this._singleRelationBackwardsRaw(details)) |
| 89 | ++ }, |
| 90 | ++ _manyRelationRaw(options, details) { |
| 91 | + const { registry, codec, relationName } = details; |
| 92 | + const relation = registry.pgRelations[codec.name]?.[relationName]; |
| 93 | + const baseOverride = relation.extensions?.tags.foreignFieldName; |
| 94 | +@@ -78,7 +84,10 @@ exports.PgRelationsPlugin = { |
| 95 | + // E.g. users(id) references posts(author_id) |
| 96 | + const remoteType = this.tableType(relation.remoteResource.codec); |
| 97 | + const remoteAttributes = relation.remoteAttributes; |
| 98 | +- return this.camelCase(`${this.pluralize(remoteType)}-by-${this._joinAttributeNames(relation.remoteResource.codec, remoteAttributes)}`); |
| 99 | ++ return (`${this.pluralize(remoteType)}-by-${this._joinAttributeNames(relation.remoteResource.codec, remoteAttributes)}`); |
| 100 | ++ }, |
| 101 | ++ _manyRelation(options, details) { |
| 102 | ++ return this.camelCase(this._manyRelationRaw(details)) |
| 103 | + }, |
| 104 | + manyRelationConnection(options, details) { |
| 105 | + const { registry, codec, relationName } = details; |
0 commit comments