From dfa0e2182e694ddd3a87a32493adc82ac13d2e8f Mon Sep 17 00:00:00 2001 From: antoniopresto Date: Tue, 21 Jan 2020 04:54:24 -0300 Subject: [PATCH] fix: disable default required type for mongoose conditional required fields (#204) --- src/resolvers/createMany.js | 2 +- src/resolvers/createOne.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/resolvers/createMany.js b/src/resolvers/createMany.js index ff1b912c..20db5d7d 100644 --- a/src/resolvers/createMany.js +++ b/src/resolvers/createMany.js @@ -41,7 +41,7 @@ export default function createMany( for (const field in tree) { if (tree.hasOwnProperty(field)) { const fieldOptions = tree[field]; - if (fieldOptions.required) { + if (fieldOptions.required && typeof fieldOptions.required !== 'function') { requiredFields.push(field); } } diff --git a/src/resolvers/createOne.js b/src/resolvers/createOne.js index 4df7c3d5..907577e8 100644 --- a/src/resolvers/createOne.js +++ b/src/resolvers/createOne.js @@ -26,7 +26,7 @@ export default function createOne( for (const field in tree) { if (tree.hasOwnProperty(field)) { const fieldOptions = tree[field]; - if (fieldOptions.required) { + if (fieldOptions.required && typeof fieldOptions.required !== 'function') { requiredFields.push(field); } }