From fbc4429648cbdec3aefa97f645a41c376aa8a5cd Mon Sep 17 00:00:00 2001 From: James Date: Thu, 24 Sep 2020 09:36:21 -0400 Subject: [PATCH] fixes bug with combining AND clauses, extends graphql id operations --- src/collections/operations/find.js | 7 ++++++- src/graphql/schema/buildWhereInputType.js | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/collections/operations/find.js b/src/collections/operations/find.js index 85359c0777..3201ac8827 100644 --- a/src/collections/operations/find.js +++ b/src/collections/operations/find.js @@ -25,10 +25,15 @@ async function find(args) { const queryToBuild = {}; if (where) { + let and = []; + + if (Array.isArray(where.and)) and = where.and; + if (Array.isArray(where.AND)) and = where.AND; + queryToBuild.where = { ...where, and: [ - ...(Array.isArray(where.and) ? where.and : []), + ...and, ], }; } diff --git a/src/graphql/schema/buildWhereInputType.js b/src/graphql/schema/buildWhereInputType.js index f685e546d6..81bcc6f129 100644 --- a/src/graphql/schema/buildWhereInputType.js +++ b/src/graphql/schema/buildWhereInputType.js @@ -292,7 +292,7 @@ const buildWhereInputType = (name, fields, parentName) => { 'id', GraphQLString, parentName, - ['equals', 'not_equals'], + ['equals', 'not_equals', 'in', 'not_in'], ), };