Skip to content

Commit b31279d

Browse files
committed
guard creating updater fields where constraint isnt available
1 parent e0ad7ab commit b31279d

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/PostgraphileNestedTypesPlugin.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -288,18 +288,20 @@ module.exports = function PostGraphileNestedTypesPlugin(
288288
},
289289
);
290290
}
291-
pgNestedTableUpdaterFields[table.id][constraint.id].forEach(
292-
({ field, fieldName: updaterFieldName }) => {
293-
operations[updaterFieldName] = {
294-
description: `The primary key(s) and patch data for \`${foreignTableName}\` for the far side of the relationship.`,
295-
type: isForward
296-
? field
297-
: isUnique
298-
? field
299-
: new GraphQLList(new GraphQLNonNull(field)),
300-
};
301-
},
302-
);
291+
if (pgNestedTableUpdaterFields[table.id][constraint.id]) {
292+
pgNestedTableUpdaterFields[table.id][constraint.id].forEach(
293+
({ field, fieldName: updaterFieldName }) => {
294+
operations[updaterFieldName] = {
295+
description: `The primary key(s) and patch data for \`${foreignTableName}\` for the far side of the relationship.`,
296+
type: isForward
297+
? field
298+
: isUnique
299+
? field
300+
: new GraphQLList(new GraphQLNonNull(field)),
301+
};
302+
},
303+
);
304+
}
303305
if (creatable) {
304306
const createInputType = newWithHooks(
305307
GraphQLInputObjectType,

0 commit comments

Comments
 (0)