From 7a1f64fe0f9f37557df662db18a13513a1656c93 Mon Sep 17 00:00:00 2001 From: Brendan McKenzie Date: Wed, 26 May 2021 15:06:29 +1000 Subject: [PATCH] bug fix virtual constraint --- src/PostgraphileNestedTypesPlugin.js | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/PostgraphileNestedTypesPlugin.js b/src/PostgraphileNestedTypesPlugin.js index 16ecacc..facd8f0 100644 --- a/src/PostgraphileNestedTypesPlugin.js +++ b/src/PostgraphileNestedTypesPlugin.js @@ -263,18 +263,20 @@ module.exports = function PostGraphileNestedTypesPlugin( type: GraphQLBoolean, }; } - pgNestedTableConnectorFields[foreignTable.id].forEach( - ({ field, fieldName: connectorFieldName }) => { - operations[connectorFieldName] = { - description: `The primary key(s) for \`${foreignTableName}\` for the far side of the relationship.`, - type: isForward - ? field - : isUnique - ? field - : new GraphQLList(new GraphQLNonNull(field)), - }; - }, - ); + if (pgNestedTableConnectorFields[foreignTable.id]) { + pgNestedTableConnectorFields[foreignTable.id].forEach( + ({ field, fieldName: connectorFieldName }) => { + operations[connectorFieldName] = { + description: `The primary key(s) for \`${foreignTableName}\` for the far side of the relationship.`, + type: isForward + ? field + : isUnique + ? field + : new GraphQLList(new GraphQLNonNull(field)), + }; + }, + ); + } if (deleteable) { pgNestedTableDeleterFields[foreignTable.id].forEach( ({ field, fieldName: deleterFieldName }) => {