From 20d251fd5dabd06f8d58ffcd5acec4dbd64ee515 Mon Sep 17 00:00:00 2001 From: James Mikrut Date: Mon, 23 May 2022 22:06:37 -0400 Subject: [PATCH] fix: #576, graphql where on hasMany relationship not working (#582) --- src/graphql/schema/buildWhereInputType.ts | 2 +- .../{fieldToSchemaMap.ts => fieldToWhereInputSchemaMap.ts} | 6 ------ src/graphql/schema/recursivelyBuildNestedPaths.ts | 2 +- 3 files changed, 2 insertions(+), 8 deletions(-) rename src/graphql/schema/{fieldToSchemaMap.ts => fieldToWhereInputSchemaMap.ts} (98%) diff --git a/src/graphql/schema/buildWhereInputType.ts b/src/graphql/schema/buildWhereInputType.ts index aecfc6571e1..2a6334d9904 100644 --- a/src/graphql/schema/buildWhereInputType.ts +++ b/src/graphql/schema/buildWhereInputType.ts @@ -15,7 +15,7 @@ import { import formatName from '../utilities/formatName'; import withOperators from './withOperators'; import operators from './operators'; -import fieldToSchemaMap from './fieldToSchemaMap'; +import fieldToSchemaMap from './fieldToWhereInputSchemaMap'; // buildWhereInputType is similar to buildObjectType and operates // on a field basis with a few distinct differences. diff --git a/src/graphql/schema/fieldToSchemaMap.ts b/src/graphql/schema/fieldToWhereInputSchemaMap.ts similarity index 98% rename from src/graphql/schema/fieldToSchemaMap.ts rename to src/graphql/schema/fieldToWhereInputSchemaMap.ts index 10b9040f6e8..4492f1f8368 100644 --- a/src/graphql/schema/fieldToSchemaMap.ts +++ b/src/graphql/schema/fieldToWhereInputSchemaMap.ts @@ -169,12 +169,6 @@ const fieldToSchemaMap: (parentName: string) => any = (parentName: string) => ({ }); } - if (field.hasMany) { - return { - type: new GraphQLList(type), - }; - } - return { type }; }, upload: (field: UploadField) => ({ diff --git a/src/graphql/schema/recursivelyBuildNestedPaths.ts b/src/graphql/schema/recursivelyBuildNestedPaths.ts index bca906b772f..68a00c0410e 100644 --- a/src/graphql/schema/recursivelyBuildNestedPaths.ts +++ b/src/graphql/schema/recursivelyBuildNestedPaths.ts @@ -4,7 +4,7 @@ import { fieldIsPresentationalOnly, FieldWithSubFields, } from '../../fields/config/types'; -import fieldToSchemaMap from './fieldToSchemaMap'; +import fieldToSchemaMap from './fieldToWhereInputSchemaMap'; const recursivelyBuildNestedPaths = (parentName: string, field: FieldWithSubFields & FieldAffectingData) => { const nestedPaths = field.fields.reduce((nestedFields, nestedField) => {