From 17dae4073b6da3e43e0760e213b1b9830d2faabf Mon Sep 17 00:00:00 2001 From: Nathan Huesmann Date: Wed, 14 Apr 2021 13:38:21 -0700 Subject: [PATCH] fix: allow orderByRelation preview feature #1063 (#1070) --- src/builder.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/builder.ts b/src/builder.ts index 7a7ccc2f0..f7722ecc0 100644 --- a/src/builder.ts +++ b/src/builder.ts @@ -655,9 +655,13 @@ export class SchemaBuilder { if (publisherConfig.ordering) { const orderByTypeName = `${field.outputType.type}OrderByInput` + const orderByTypeNamePreviewFeature = `${field.outputType.type}OrderByWithRelationInput` const orderByArg = field.args.find( - (arg) => arg.inputType.type === orderByTypeName && arg.name === 'orderBy' - ) + (arg) => + (arg.inputType.type === orderByTypeName || + arg.inputType.type === orderByTypeNamePreviewFeature) && + arg.name === 'orderBy' + ); if (!orderByArg) { throw new Error(`Could not find ordering argument for ${typeName}.${field.name}`) @@ -665,7 +669,7 @@ export class SchemaBuilder { const inputType = this.handleInputObjectCustomization({ fieldWhitelist: publisherConfig.ordering, - inputTypeName: orderByTypeName, + inputTypeName: orderByArg.inputType.type, fieldName: field.name, graphQLTypeName: typeName, isWhereType: false,