Skip to content

Commit 7f0e956

Browse files
authored
fix: avoid assigning types with no fields (#63)
1 parent 3ae45f2 commit 7f0e956

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/PgConnectionArgFilterPlugin.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,22 @@ module.exports = function PgConnectionArgFilterPlugin(
324324
filterTypeName,
325325
source,
326326
sourceTypeName
327-
) =>
328-
connectionFilterTypesByTypeName[filterTypeName] ||
329-
newWithHooks(
327+
) => {
328+
const existingType = connectionFilterTypesByTypeName[filterTypeName];
329+
if (existingType) {
330+
if (
331+
typeof existingType._fields === "object" &&
332+
Object.keys(existingType._fields).length === 0
333+
) {
334+
// Existing type is fully defined and
335+
// there are no fields, so don't return a type
336+
return null;
337+
}
338+
// Existing type isn't fully defined or is
339+
// fully defined with fields, so return it
340+
return existingType;
341+
}
342+
return newWithHooks(
330343
GraphQLInputObjectType,
331344
{
332345
description: `A filter to be used against \`${sourceTypeName}\` object types. All fields are combined with a logical ‘and.’`,
@@ -338,6 +351,7 @@ module.exports = function PgConnectionArgFilterPlugin(
338351
},
339352
true
340353
);
354+
};
341355

342356
const escapeLikeWildcards = input => {
343357
if ("string" !== typeof input) {

0 commit comments

Comments
 (0)