From d1f51e09b2a25f15af3c3efc3a8150f6a218c909 Mon Sep 17 00:00:00 2001 From: David Baumgold Date: Tue, 7 Jan 2020 17:57:25 +0100 Subject: [PATCH] feat(pg): support non-scalar range values (#591) Co-authored-by: Benjie Gillam --- packages/graphile-build-pg/src/plugins/PgTypesPlugin.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/graphile-build-pg/src/plugins/PgTypesPlugin.ts b/packages/graphile-build-pg/src/plugins/PgTypesPlugin.ts index 944e8ff07f..f86d86ad25 100644 --- a/packages/graphile-build-pg/src/plugins/PgTypesPlugin.ts +++ b/packages/graphile-build-pg/src/plugins/PgTypesPlugin.ts @@ -817,10 +817,17 @@ export default (function PgTypesPlugin( subtype.id, typeModifier ); + const gqlRangeInputSubType = getGqlInputTypeByTypeIdAndModifier( + subtype.id, + typeModifier + ); if (!gqlRangeSubType || !isNamedType(gqlRangeSubType)) { throw new Error("Range of unsupported type"); } + if (!gqlRangeInputSubType || !isNamedType(gqlRangeInputSubType)) { + throw new Error("Range of unsupported input type"); + } const existingRange = getTypeByName( inflection.rangeType(gqlRangeSubType.name) ); @@ -874,7 +881,7 @@ export default (function PgTypesPlugin( fields: { value: { description: "The value at one end of our range.", - type: new GraphQLNonNull(gqlRangeSubType), + type: new GraphQLNonNull(gqlRangeInputSubType), }, inclusive: {