From 028064c9f52f03f2130b7331fba3620e279ae2c5 Mon Sep 17 00:00:00 2001 From: David Baumgold Date: Tue, 5 Nov 2019 13:48:49 +0100 Subject: [PATCH] Implement junction filters --- .../schema/__snapshots__/b.test.js.snap | 29 +++ .../schema/__snapshots__/c.test.js.snap | 26 ++ .../schema/__snapshots__/d.test.js.snap | 32 +++ .../schema/__snapshots__/g.test.js.snap | 32 +++ .../p.simpleCollectionsBoth.test.js.snap | 26 ++ .../schema/__snapshots__/p.test.js.snap | 26 ++ .../schema/__snapshots__/t.test.js.snap | 38 +++ __tests__/schemas/b/schema.sql | 7 +- index.js | 1 + src/PgManyToManyRelationFilterPlugin.js | 236 ++++++++++++++++++ src/PgManyToManyRelationInflectionPlugin.js | 26 ++ src/PgManyToManyRelationPlugin.js | 9 + 12 files changed, 486 insertions(+), 2 deletions(-) create mode 100644 src/PgManyToManyRelationFilterPlugin.js diff --git a/__tests__/integration/schema/__snapshots__/b.test.js.snap b/__tests__/integration/schema/__snapshots__/b.test.js.snap index 7ebb22d..033487d 100644 --- a/__tests__/integration/schema/__snapshots__/b.test.js.snap +++ b/__tests__/integration/schema/__snapshots__/b.test.js.snap @@ -16,6 +16,11 @@ type Bar implements Node { """Only read the first \`n\` values of the set.""" first: Int + """ + A condition to be used in determining which values should be returned by the collection. + """ + junctionCondition: BarFoosByJunctionJBarIdAndJFooIdManyToManyCondition + """Only read the last \`n\` values of the set.""" last: Int @@ -59,6 +64,14 @@ type Bar implements Node { nodeId: ID! } +""" +A condition to be used against \`Foo\` object types. All fields are tested for equality and combined with a logical ‘and.’ +""" +input BarFoosByJunctionJBarIdAndJFooIdManyToManyCondition { + """Checks for equality with the \`Junction\` object’s \`createdAt\` field.""" + createdAt: Datetime +} + """A connection to a list of \`Foo\` values, with data from \`Junction\`.""" type BarFoosByJunctionJBarIdAndJFooIdManyToManyConnection { """ @@ -142,6 +155,11 @@ type Foo implements Node { """Read all values in the set before (above) this cursor.""" before: Cursor + """ + A condition to be used in determining which values should be returned by the collection. + """ + condition: FooBarsByJunctionJFooIdAndJBarIdManyToManyCondition + """Only read the first \`n\` values of the set.""" first: Int @@ -190,6 +208,17 @@ type Foo implements Node { nodeId: ID! } +""" +A condition to be used against \`Bar\` object types. All fields are tested for equality and combined with a logical ‘and.’ +""" +input FooBarsByJunctionJFooIdAndJBarIdManyToManyCondition { + """Checks for equality with the \`Bar\` object’s \`barName\` field.""" + barName: String + + """Checks for equality with the \`Junction\` object’s \`createdAt\` field.""" + createdAt: Datetime +} + """A connection to a list of \`Bar\` values, with data from \`Junction\`.""" type FooBarsByJunctionJFooIdAndJBarIdManyToManyConnection { """ diff --git a/__tests__/integration/schema/__snapshots__/c.test.js.snap b/__tests__/integration/schema/__snapshots__/c.test.js.snap index 8dbadf4..46d961c 100644 --- a/__tests__/integration/schema/__snapshots__/c.test.js.snap +++ b/__tests__/integration/schema/__snapshots__/c.test.js.snap @@ -16,6 +16,11 @@ type Bar implements Node { """Only read the first \`n\` values of the set.""" first: Int + """ + A condition to be used in determining which values should be returned by the collection. + """ + junctionCondition: BarFoosByJunctionJBarIdAndJFooIdManyToManyCondition + """Only read the last \`n\` values of the set.""" last: Int @@ -59,6 +64,14 @@ type Bar implements Node { nodeId: ID! } +""" +A condition to be used against \`Foo\` object types. All fields are tested for equality and combined with a logical ‘and.’ +""" +input BarFoosByJunctionJBarIdAndJFooIdManyToManyCondition { + """Checks for equality with the \`Junction\` object’s \`id\` field.""" + id: Int +} + """A connection to a list of \`Foo\` values, with data from \`Junction\`.""" type BarFoosByJunctionJBarIdAndJFooIdManyToManyConnection { """ @@ -161,6 +174,11 @@ type Foo implements Node { """Only read the first \`n\` values of the set.""" first: Int + """ + A condition to be used in determining which values should be returned by the collection. + """ + junctionCondition: FooBarsByJunctionJFooIdAndJBarIdManyToManyCondition + """Only read the last \`n\` values of the set.""" last: Int @@ -206,6 +224,14 @@ type Foo implements Node { nodeId: ID! } +""" +A condition to be used against \`Bar\` object types. All fields are tested for equality and combined with a logical ‘and.’ +""" +input FooBarsByJunctionJFooIdAndJBarIdManyToManyCondition { + """Checks for equality with the \`Junction\` object’s \`id\` field.""" + id: Int +} + """A connection to a list of \`Bar\` values, with data from \`Junction\`.""" type FooBarsByJunctionJFooIdAndJBarIdManyToManyConnection { """ diff --git a/__tests__/integration/schema/__snapshots__/d.test.js.snap b/__tests__/integration/schema/__snapshots__/d.test.js.snap index 1e7238a..68a90cb 100644 --- a/__tests__/integration/schema/__snapshots__/d.test.js.snap +++ b/__tests__/integration/schema/__snapshots__/d.test.js.snap @@ -16,6 +16,11 @@ type Bar implements Node { """Only read the first \`n\` values of the set.""" first: Int + """ + A condition to be used in determining which values should be returned by the collection. + """ + junctionCondition: BarFoosByJunctionJBarIdAndJFooIdManyToManyCondition + """Only read the last \`n\` values of the set.""" last: Int @@ -59,6 +64,17 @@ type Bar implements Node { nodeId: ID! } +""" +A condition to be used against \`Foo\` object types. All fields are tested for equality and combined with a logical ‘and.’ +""" +input BarFoosByJunctionJBarIdAndJFooIdManyToManyCondition { + """Checks for equality with the \`Junction\` object’s \`createdAt\` field.""" + createdAt: Datetime + + """Checks for equality with the \`Junction\` object’s \`id\` field.""" + id: Int +} + """A connection to a list of \`Foo\` values, with data from \`Junction\`.""" type BarFoosByJunctionJBarIdAndJFooIdManyToManyConnection { """ @@ -167,6 +183,11 @@ type Foo implements Node { """Only read the first \`n\` values of the set.""" first: Int + """ + A condition to be used in determining which values should be returned by the collection. + """ + junctionCondition: FooBarsByJunctionJFooIdAndJBarIdManyToManyCondition + """Only read the last \`n\` values of the set.""" last: Int @@ -212,6 +233,17 @@ type Foo implements Node { nodeId: ID! } +""" +A condition to be used against \`Bar\` object types. All fields are tested for equality and combined with a logical ‘and.’ +""" +input FooBarsByJunctionJFooIdAndJBarIdManyToManyCondition { + """Checks for equality with the \`Junction\` object’s \`createdAt\` field.""" + createdAt: Datetime + + """Checks for equality with the \`Junction\` object’s \`id\` field.""" + id: Int +} + """A connection to a list of \`Bar\` values, with data from \`Junction\`.""" type FooBarsByJunctionJFooIdAndJBarIdManyToManyConnection { """ diff --git a/__tests__/integration/schema/__snapshots__/g.test.js.snap b/__tests__/integration/schema/__snapshots__/g.test.js.snap index 7dcc31c..b0cb6d3 100644 --- a/__tests__/integration/schema/__snapshots__/g.test.js.snap +++ b/__tests__/integration/schema/__snapshots__/g.test.js.snap @@ -50,6 +50,11 @@ type Post implements Node { """Only read the first \`n\` values of the set.""" first: Int + """ + A condition to be used in determining which values should be returned by the collection. + """ + junctionCondition: PostAuthorsManyToManyCondition + """Only read the last \`n\` values of the set.""" last: Int @@ -135,6 +140,17 @@ type PostAuthorsEdge { node: PostAuthor } +""" +A condition to be used against \`User\` object types. All fields are tested for equality and combined with a logical ‘and.’ +""" +input PostAuthorsManyToManyCondition { + """Checks for equality with the \`PostAuthor\` object’s \`createdAt\` field.""" + createdAt: Datetime + + """Checks for equality with the \`PostAuthor\` object’s \`id\` field.""" + id: UUID +} + """A connection to a list of \`User\` values, with data from \`PostAuthor\`.""" type PostAuthorsManyToManyConnection { """ @@ -417,6 +433,11 @@ type User implements Node { """Only read the first \`n\` values of the set.""" first: Int + """ + A condition to be used in determining which values should be returned by the collection. + """ + junctionCondition: UserPostsByPostAuthorUserIdAndPostIdManyToManyCondition + """Only read the last \`n\` values of the set.""" last: Int @@ -439,6 +460,17 @@ input UserCondition { id: UUID } +""" +A condition to be used against \`Post\` object types. All fields are tested for equality and combined with a logical ‘and.’ +""" +input UserPostsByPostAuthorUserIdAndPostIdManyToManyCondition { + """Checks for equality with the \`PostAuthor\` object’s \`createdAt\` field.""" + createdAt: Datetime + + """Checks for equality with the \`PostAuthor\` object’s \`id\` field.""" + id: UUID +} + """A connection to a list of \`Post\` values, with data from \`PostAuthor\`.""" type UserPostsByPostAuthorUserIdAndPostIdManyToManyConnection { """ diff --git a/__tests__/integration/schema/__snapshots__/p.simpleCollectionsBoth.test.js.snap b/__tests__/integration/schema/__snapshots__/p.simpleCollectionsBoth.test.js.snap index 66e9385..d1d32c8 100644 --- a/__tests__/integration/schema/__snapshots__/p.simpleCollectionsBoth.test.js.snap +++ b/__tests__/integration/schema/__snapshots__/p.simpleCollectionsBoth.test.js.snap @@ -680,6 +680,11 @@ type Person implements Node { """Only read the first \`n\` values of the set.""" first: Int + """ + A condition to be used in determining which values should be returned by the collection. + """ + junctionCondition: PersonTeamsByMembershipPersonIdAndTeamIdManyToManyCondition + """Only read the last \`n\` values of the set.""" last: Int @@ -705,6 +710,14 @@ input PersonCondition { personName: String } +""" +A condition to be used against \`Team\` object types. All fields are tested for equality and combined with a logical ‘and.’ +""" +input PersonTeamsByMembershipPersonIdAndTeamIdManyToManyCondition { + """Checks for equality with the \`Membership\` object’s \`createdAt\` field.""" + createdAt: Datetime +} + """A connection to a list of \`Team\` values, with data from \`Membership\`.""" type PersonTeamsByMembershipPersonIdAndTeamIdManyToManyConnection { """ @@ -1169,6 +1182,11 @@ type Team implements Node { """Only read the first \`n\` values of the set.""" first: Int + """ + A condition to be used in determining which values should be returned by the collection. + """ + junctionCondition: TeamMembersManyToManyCondition + """Only read the last \`n\` values of the set.""" last: Int @@ -1246,6 +1264,14 @@ input TeamCondition { teamName: String } +""" +A condition to be used against \`Person\` object types. All fields are tested for equality and combined with a logical ‘and.’ +""" +input TeamMembersManyToManyCondition { + """Checks for equality with the \`Membership\` object’s \`createdAt\` field.""" + createdAt: Datetime +} + """ A connection to a list of \`Person\` values, with data from \`Membership\`. """ diff --git a/__tests__/integration/schema/__snapshots__/p.test.js.snap b/__tests__/integration/schema/__snapshots__/p.test.js.snap index 6bf1096..038c810 100644 --- a/__tests__/integration/schema/__snapshots__/p.test.js.snap +++ b/__tests__/integration/schema/__snapshots__/p.test.js.snap @@ -578,6 +578,11 @@ type Person implements Node { """Only read the first \`n\` values of the set.""" first: Int + """ + A condition to be used in determining which values should be returned by the collection. + """ + junctionCondition: PersonTeamsByMembershipPersonIdAndTeamIdManyToManyCondition + """Only read the last \`n\` values of the set.""" last: Int @@ -603,6 +608,14 @@ input PersonCondition { personName: String } +""" +A condition to be used against \`Team\` object types. All fields are tested for equality and combined with a logical ‘and.’ +""" +input PersonTeamsByMembershipPersonIdAndTeamIdManyToManyCondition { + """Checks for equality with the \`Membership\` object’s \`createdAt\` field.""" + createdAt: Datetime +} + """A connection to a list of \`Team\` values, with data from \`Membership\`.""" type PersonTeamsByMembershipPersonIdAndTeamIdManyToManyConnection { """ @@ -965,6 +978,11 @@ type Team implements Node { """Only read the first \`n\` values of the set.""" first: Int + """ + A condition to be used in determining which values should be returned by the collection. + """ + junctionCondition: TeamMembersManyToManyCondition + """Only read the last \`n\` values of the set.""" last: Int @@ -1025,6 +1043,14 @@ input TeamCondition { teamName: String } +""" +A condition to be used against \`Person\` object types. All fields are tested for equality and combined with a logical ‘and.’ +""" +input TeamMembersManyToManyCondition { + """Checks for equality with the \`Membership\` object’s \`createdAt\` field.""" + createdAt: Datetime +} + """ A connection to a list of \`Person\` values, with data from \`Membership\`. """ diff --git a/__tests__/integration/schema/__snapshots__/t.test.js.snap b/__tests__/integration/schema/__snapshots__/t.test.js.snap index c51a98f..02e25b5 100644 --- a/__tests__/integration/schema/__snapshots__/t.test.js.snap +++ b/__tests__/integration/schema/__snapshots__/t.test.js.snap @@ -207,6 +207,11 @@ type Person implements Node { """Only read the first \`n\` values of the set.""" first: Int + """ + A condition to be used in determining which values should be returned by the collection. + """ + junctionCondition: PersonTeamsByMembershipPersonIdAndTeamIdManyToManyCondition + """Only read the last \`n\` values of the set.""" last: Int @@ -232,6 +237,20 @@ input PersonCondition { personName: String } +""" +A condition to be used against \`Team\` object types. All fields are tested for equality and combined with a logical ‘and.’ +""" +input PersonTeamsByMembershipPersonIdAndTeamIdManyToManyCondition { + """Checks for equality with the \`Membership\` object’s \`endAt\` field.""" + endAt: Datetime + + """Checks for equality with the \`Membership\` object’s \`id\` field.""" + id: Int + + """Checks for equality with the \`Membership\` object’s \`startAt\` field.""" + startAt: Datetime +} + """A connection to a list of \`Team\` values, with data from \`Membership\`.""" type PersonTeamsByMembershipPersonIdAndTeamIdManyToManyConnection { """ @@ -436,6 +455,11 @@ type Team implements Node { """Only read the first \`n\` values of the set.""" first: Int + """ + A condition to be used in determining which values should be returned by the collection. + """ + junctionCondition: TeamMembersManyToManyCondition + """Only read the last \`n\` values of the set.""" last: Int @@ -496,6 +520,20 @@ input TeamCondition { teamName: String } +""" +A condition to be used against \`Person\` object types. All fields are tested for equality and combined with a logical ‘and.’ +""" +input TeamMembersManyToManyCondition { + """Checks for equality with the \`Membership\` object’s \`endAt\` field.""" + endAt: Datetime + + """Checks for equality with the \`Membership\` object’s \`id\` field.""" + id: Int + + """Checks for equality with the \`Membership\` object’s \`startAt\` field.""" + startAt: Datetime +} + """ A connection to a list of \`Person\` values, with data from \`Membership\`. """ diff --git a/__tests__/schemas/b/schema.sql b/__tests__/schemas/b/schema.sql index 33e684d..481a62f 100644 --- a/__tests__/schemas/b/schema.sql +++ b/__tests__/schemas/b/schema.sql @@ -16,8 +16,11 @@ create table b.bar ( ); create table b.junction ( - j_foo_id integer references b.foo (foo_id), + j_foo_id integer constraint junction_j_foo_id_fkey references b.foo (foo_id), j_bar_id integer references b.bar (bar_id), created_at timestamptz not null, primary key (j_foo_id, j_bar_id) -); \ No newline at end of file +); + +comment on constraint junction_j_foo_id_fkey on b.junction is + E'@manyToManyCombinedConditionArg'; diff --git a/index.js b/index.js index dea06fe..9dad7e0 100644 --- a/index.js +++ b/index.js @@ -31,4 +31,5 @@ module.exports = function PgManyToManyPlugin(builder, options) { require("./src/PgManyToManyRelationPlugin.js")(builder, options); require("./src/PgManyToManyRelationEdgeColumnsPlugin.js")(builder, options); require("./src/PgManyToManyRelationEdgeTablePlugin.js")(builder, options); + require("./src/PgManyToManyRelationFilterPlugin.js")(builder, options); }; diff --git a/src/PgManyToManyRelationFilterPlugin.js b/src/PgManyToManyRelationFilterPlugin.js new file mode 100644 index 0000000..efa3fc1 --- /dev/null +++ b/src/PgManyToManyRelationFilterPlugin.js @@ -0,0 +1,236 @@ +function createJunctionConditionType( + build, + context, + combineJunctionWithRightTable = false, + leftKeyAttributes, + junctionLeftKeyAttributes, + junctionRightKeyAttributes, + rightKeyAttributes, + junctionTable, + rightTable, + junctionLeftConstraint, + junctionRightConstraint, + leftTableType +) { + const { + newWithHooks, + graphql: { GraphQLInputObjectType, GraphQLString }, + pgGetGqlInputTypeByTypeIdAndModifier, + pgColumnFilter, + inflection, + extend, + pgOmit: omit, + describePgEntity, + } = build; + const junctionKeyAttributeNums = [ + ...junctionLeftKeyAttributes.map(attr => attr.num), + ...junctionRightKeyAttributes.map(attr => attr.num), + ]; + const relevantAttributes = junctionTable.attributes + .filter( + attr => + !junctionKeyAttributeNums.includes(attr.num) && + pgColumnFilter(attr, build, context) && + !omit(attr, "filter") + ) + .map(attr => ({ attr, onJunction: true })); + if (combineJunctionWithRightTable) { + const rightKeyAttributeNums = rightKeyAttributes.map(attr => attr.num); + const rightFilterableAttributes = rightTable.attributes + .filter( + attr => + !rightKeyAttributeNums.includes(attr.num) && + pgColumnFilter(attr, build, context) && + !omit(attr, "filter") + ) + .map(attr => ({ attr, onJunction: false })); + relevantAttributes.push(...rightFilterableAttributes); + } + + const junctionTableTypeName = inflection.tableType(junctionTable); + const rightTableTypeName = inflection.tableType(rightTable); + + return newWithHooks( + GraphQLInputObjectType, + { + description: `A condition to be used against \`${rightTableTypeName}\` object types. All fields are tested for equality and combined with a logical ‘and.’`, + name: inflection.manyToManyRelationConditionType( + leftKeyAttributes, + junctionLeftKeyAttributes, + junctionRightKeyAttributes, + rightKeyAttributes, + junctionTable, + rightTable, + junctionLeftConstraint, + junctionRightConstraint, + leftTableType.name + ), + fields: context => { + const { fieldWithHooks } = context; + return relevantAttributes.reduce((memo, { attr, onJunction }) => { + const fieldName = inflection.column(attr); + const objectTypeName = onJunction + ? junctionTableTypeName + : rightTableTypeName; + memo = extend( + memo, + { + [fieldName]: fieldWithHooks( + fieldName, + { + description: `Checks for equality with the \`${objectTypeName}\` object’s \`${fieldName}\` field.`, + type: + pgGetGqlInputTypeByTypeIdAndModifier( + attr.typeId, + attr.typeModifier + ) || GraphQLString, + }, + { + isPgConnectionConditionInputField: true, + } + ), + }, + `Adding condition argument for ${describePgEntity(attr)}` + ); + return memo; + }, {}); + }, + }, + { + isPgCondition: true, + } + ); +} + +module.exports = function PgManyToManyRelationFilterPlugin(builder) { + builder.hook( + "GraphQLObjectType:fields:field:args", + (args, build, context) => { + const { + pgSql: sql, + gql2pg, + extend, + pgColumnFilter, + inflection, + pgOmit: omit, + } = build; + const { + scope: { + fieldName, + isPgManyToManyRelationField, + isPgFieldConnection, + pgManyToManyLeftKeyAttributes: leftKeyAttributes, + pgManyToManyJunctionLeftKeyAttributes: junctionLeftKeyAttributes, + pgManyToManyJunctionRightKeyAttributes: junctionRightKeyAttributes, + pgManyToManyRightKeyAttributes: rightKeyAttributes, + pgManyToManyJunctionTable: junctionTable, + pgManyToManyRightTable: rightTable, + pgManyToManyJunctionLeftConstraint: junctionLeftConstraint, + pgManyToManyJunctionRightConstraint: junctionRightConstraint, + }, + addArgDataGenerator, + Self, + } = context; + if (!isPgManyToManyRelationField || !isPgFieldConnection) { + return args; + } + const junctionKeyAttributeNums = [ + ...junctionLeftKeyAttributes.map(attr => attr.num), + ...junctionRightKeyAttributes.map(attr => attr.num), + ]; + const junctionFilterableAttributes = junctionTable.attributes.filter( + attr => + !junctionKeyAttributeNums.includes(attr.num) && + pgColumnFilter(attr, build, context) && + !omit(attr, "filter") + ); + if (junctionFilterableAttributes.length === 0) { + return args; + } + + const shouldCombineConditions = !!junctionLeftConstraint.tags + .manyToManyCombinedConditionArg; + + const JunctionConditionType = createJunctionConditionType( + build, + context, + shouldCombineConditions, + leftKeyAttributes, + junctionLeftKeyAttributes, + junctionRightKeyAttributes, + rightKeyAttributes, + junctionTable, + rightTable, + junctionLeftConstraint, + junctionRightConstraint, + Self + ); + + addArgDataGenerator(function connectionConditionJunction({ condition }) { + return { + pgQuery: queryBuilder => { + if (condition != null) { + const subqueryName = inflection.manyToManyRelationSubqueryName( + leftKeyAttributes, + junctionLeftKeyAttributes, + junctionRightKeyAttributes, + rightKeyAttributes, + junctionTable, + rightTable, + junctionLeftConstraint, + junctionRightConstraint + ); + const subQueryBuilder = queryBuilder.getNamedChild(subqueryName); + if (!subQueryBuilder) { + throw new Error( + `Could not find child query builder named ${subqueryName}` + ); + } + junctionFilterableAttributes.forEach(attr => { + const fieldName = inflection.column(attr); + const val = condition[fieldName]; + if (val != null) { + subQueryBuilder.addLiveCondition(() => record => + record[attr.name] === val + ); + subQueryBuilder.where( + sql.fragment`${subQueryBuilder.getTableAlias()}.${sql.identifier( + attr.name + )} = ${gql2pg(val, attr.type, attr.typeModifier)}` + ); + } else if (val === null) { + subQueryBuilder.addLiveCondition(() => record => + record[attr.name] == null + ); + subQueryBuilder.where( + sql.fragment`${subQueryBuilder.getTableAlias()}.${sql.identifier( + attr.name + )} IS NULL` + ); + } + }); + } + }, + }; + }); + + const argName = shouldCombineConditions + ? "condition" + : "junctionCondition"; + if (shouldCombineConditions) { + delete args.condition; + } + return extend( + args, + { + [argName]: { + description: + "A condition to be used in determining which values should be returned by the collection.", + type: JunctionConditionType, + }, + }, + `Adding junction condition to connection field '${fieldName}' of '${Self.name}'` + ); + } + ); +}; diff --git a/src/PgManyToManyRelationInflectionPlugin.js b/src/PgManyToManyRelationInflectionPlugin.js index 3a54ec2..2b17f89 100644 --- a/src/PgManyToManyRelationInflectionPlugin.js +++ b/src/PgManyToManyRelationInflectionPlugin.js @@ -100,6 +100,32 @@ module.exports = function PgManyToManyRelationInflectionPlugin(builder) { `${leftTableTypeName}-${relationName}-many-to-many-connection` ); }, + manyToManyRelationConditionType( + leftKeyAttributes, + junctionLeftKeyAttributes, + junctionRightKeyAttributes, + rightKeyAttributes, + junctionTable, + rightTable, + junctionLeftConstraint, + junctionRightConstraint, + leftTableTypeName + ) { + const relationName = inflection.manyToManyRelationByKeys( + leftKeyAttributes, + junctionLeftKeyAttributes, + junctionRightKeyAttributes, + rightKeyAttributes, + junctionTable, + rightTable, + junctionLeftConstraint, + junctionRightConstraint, + leftTableTypeName + ); + return this.upperCamelCase( + `${leftTableTypeName}-${relationName}-many-to-many-condition` + ); + }, /* eslint-disable no-unused-vars */ manyToManyRelationSubqueryName( leftKeyAttributes, diff --git a/src/PgManyToManyRelationPlugin.js b/src/PgManyToManyRelationPlugin.js index 6b4dddd..8def908 100644 --- a/src/PgManyToManyRelationPlugin.js +++ b/src/PgManyToManyRelationPlugin.js @@ -214,6 +214,15 @@ module.exports = function PgManyToManyRelationPlugin(builder, options) { isPgFieldSimpleCollection: !isConnection, isPgManyToManyRelationField: true, pgFieldIntrospection: rightTable, + + pgManyToManyLeftKeyAttributes: leftKeyAttributes, + pgManyToManyJunctionLeftKeyAttributes: junctionLeftKeyAttributes, + pgManyToManyJunctionRightKeyAttributes: junctionRightKeyAttributes, + pgManyToManyRightKeyAttributes: rightKeyAttributes, + pgManyToManyJunctionTable: junctionTable, + pgManyToManyRightTable: rightTable, + pgManyToManyJunctionLeftConstraint: junctionLeftConstraint, + pgManyToManyJunctionRightConstraint: junctionRightConstraint, } ), },