Skip to content

Commit

Permalink
fix: allow orderByRelation preview feature #1063 (#1070)
Browse files Browse the repository at this point in the history
  • Loading branch information
nhuesmann authored Apr 14, 2021
1 parent 577ec8f commit 17dae40
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -655,17 +655,21 @@ 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}`)
}

const inputType = this.handleInputObjectCustomization({
fieldWhitelist: publisherConfig.ordering,
inputTypeName: orderByTypeName,
inputTypeName: orderByArg.inputType.type,
fieldName: field.name,
graphQLTypeName: typeName,
isWhereType: false,
Expand Down

0 comments on commit 17dae40

Please sign in to comment.