Skip to content

Commit 3357a30

Browse files
committed
HotFix for operators' types in filter helper
1 parent 3c048a1 commit 3357a30

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/resolvers/helpers/filter.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,21 @@ export function addFieldsWithOperator(
166166
operators = availableOperators;
167167
}
168168
operators.forEach(operatorName => {
169+
// unwrap from GraphQLNonNull and GraphQLList, if present
169170
const namedType = getNamedType(existedFields[fieldName].type);
170171
if (namedType) {
171172
if (operatorName.slice(-2) === '[]') {
172-
fields[operatorName.slice(0, -2)] = {
173+
// wrap with GraphQLList, if operator required this with `[]`
174+
const newName = operatorName.slice(0, -2);
175+
fields[newName] = {
173176
...existedFields[fieldName],
174177
type: new GraphQLList(namedType),
175178
};
176179
} else {
177-
fields[operatorName] = namedType;
180+
fields[operatorName] = {
181+
...existedFields[fieldName],
182+
type: namedType,
183+
};
178184
}
179185
}
180186
});

0 commit comments

Comments
 (0)