@graphile-contrib/pg-many-to-many
Advanced tools
Comparing version 2.0.0-0.1 to 2.0.0-0.2
@@ -19,3 +19,3 @@ "use strict"; | ||
const { extend, sql, inflection, nullableIf } = build; | ||
const { scope: { isPgManyToManyEdgeType, pgManyToManyRelationship }, fieldWithHooks, } = context; | ||
const { scope: { isPgManyToManyEdgeType, pgManyToManyRelationship }, fieldWithHooks, Self, } = context; | ||
if (!isPgManyToManyEdgeType || !pgManyToManyRelationship) { | ||
@@ -30,3 +30,3 @@ return fields; | ||
} | ||
return extend(fields, Object.entries(junctionTable.codec.columns).reduce((memo, [columnName, column]) => { | ||
return extend(fields, Object.entries(junctionTable.codec.columns).reduce((memo, [columnName, column]) => build.recoverable(memo, () => { | ||
const behavior = build.pgGetBehavior(column.extensions); | ||
@@ -37,6 +37,8 @@ if (!build.behavior.matches(behavior, "select", "select")) { | ||
// Skip left and right key attributes | ||
if (junctionLeftKeyAttributeNames.includes(columnName)) | ||
if (junctionLeftKeyAttributeNames.includes(columnName)) { | ||
return memo; | ||
if (junctionRightKeyAttributeNames.includes(columnName)) | ||
} | ||
if (junctionRightKeyAttributeNames.includes(columnName)) { | ||
return memo; | ||
} | ||
const codec = column.codec; | ||
@@ -66,5 +68,5 @@ const fieldName = inflection.column({ | ||
})), | ||
}, `PgManyToMany adding edge field for '${columnName}'.`); | ||
}, `PgManyToMany adding edge field for '${junctionTable.name}.${columnName}' to ${Self.name}.`); | ||
return memo; | ||
}, {}), `Adding columns to '${junctionTable.name}'`); | ||
}), Object.create(null)), `Adding columns to '${junctionTable.name}'`); | ||
}, | ||
@@ -71,0 +73,0 @@ }, |
@@ -72,3 +72,3 @@ "use strict"; | ||
} | ||
fields = extend(fields, { | ||
fields = build.recoverable(fields, () => extend(fields, { | ||
[fieldName]: fieldWithHooks({ | ||
@@ -86,3 +86,3 @@ fieldName, | ||
: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(JunctionTableType))), | ||
args: {}, | ||
args: Object.create(null), | ||
plan($edge) { | ||
@@ -112,3 +112,3 @@ const $right = $edge.node(); | ||
})), | ||
}, `Many-to-many relation edge table (${isConnection ? "connection" : "simple collection"}) on ${Self.name} type for ${rightRelationName}.`); | ||
}, `Many-to-many relation edge table (${isConnection ? "connection" : "simple collection"}) on ${Self.name} type for ${rightRelationName}.`)); | ||
} | ||
@@ -115,0 +115,0 @@ const behavior = build.pgGetBehavior([ |
@@ -38,3 +38,3 @@ "use strict"; | ||
"string") { | ||
return junctionRightRelation.extensions?.tags.manyToManyFieldName; | ||
return junctionRightRelation.extensions.tags.manyToManyFieldName; | ||
} | ||
@@ -41,0 +41,0 @@ return this.camelCase(`${this.pluralize(this._singularizedCodecName(rightTable.codec))}-by-${this._singularizedCodecName(junctionTable.codec)}-${[ |
@@ -45,3 +45,3 @@ "use strict"; | ||
const relationships = (0, manyToManyRelationships_1.default)(leftTable, build); | ||
return extend(fields, relationships.reduce((memo, relationship) => { | ||
return extend(fields, relationships.reduce((memo, relationship) => build.recoverable(memo, () => { | ||
const { leftTable, leftRelationName, junctionTable, rightRelationName, rightTable, allowsMultipleEdgesToNode, } = relationship; | ||
@@ -72,3 +72,3 @@ const RightTableType = build.getGraphQLTypeByPgCodec(rightTable.codec, "output"); | ||
: inflection.manyToManyRelationByKeysSimple(relationship); | ||
memo = extend(memo, { | ||
memo = build.recoverable(memo, () => extend(memo, { | ||
[manyRelationFieldName]: fieldWithHooks({ | ||
@@ -86,3 +86,3 @@ fieldName: manyRelationFieldName, | ||
: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(RightTableType))), | ||
args: {}, | ||
args: Object.create(null), | ||
plan($left) { | ||
@@ -157,3 +157,3 @@ const $junctions = $left.manyRelation(leftRelationName); | ||
})), | ||
}, `Many-to-many relation field (${isConnection ? "connection" : "simple collection"}) on ${Self.name} type for ${leftRelationName} and ${rightRelationName}.`); | ||
}, `Many-to-many relation field (${isConnection ? "connection" : "simple collection"}) on ${Self.name} type for ${leftRelationName} and ${rightRelationName}.`)); | ||
} | ||
@@ -174,3 +174,3 @@ const behavior = build.pgGetBehavior([ | ||
return memo; | ||
}, {}), `Adding many-to-many relations for ${Self.name}`); | ||
}), Object.create(null)), `Adding many-to-many relations for ${Self.name}`); | ||
}, | ||
@@ -177,0 +177,0 @@ }, |
{ | ||
"name": "@graphile-contrib/pg-many-to-many", | ||
"version": "2.0.0-0.1", | ||
"version": "2.0.0-0.2", | ||
"description": "Add connection fields for many-to-many relations", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
77205
700