From 3357a30db224438c065c6efc47fb43e26ec73b04 Mon Sep 17 00:00:00 2001 From: nodkz Date: Mon, 18 Jul 2016 22:17:45 +0600 Subject: [PATCH] HotFix for operators' types in `filter` helper --- src/resolvers/helpers/filter.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/resolvers/helpers/filter.js b/src/resolvers/helpers/filter.js index 3d5aefc6..0a393d4c 100644 --- a/src/resolvers/helpers/filter.js +++ b/src/resolvers/helpers/filter.js @@ -166,15 +166,21 @@ export function addFieldsWithOperator( operators = availableOperators; } operators.forEach(operatorName => { + // unwrap from GraphQLNonNull and GraphQLList, if present const namedType = getNamedType(existedFields[fieldName].type); if (namedType) { if (operatorName.slice(-2) === '[]') { - fields[operatorName.slice(0, -2)] = { + // wrap with GraphQLList, if operator required this with `[]` + const newName = operatorName.slice(0, -2); + fields[newName] = { ...existedFields[fieldName], type: new GraphQLList(namedType), }; } else { - fields[operatorName] = namedType; + fields[operatorName] = { + ...existedFields[fieldName], + type: namedType, + }; } } });