Skip to content

Commit

Permalink
HotFix for operators' types in filter helper
Browse files Browse the repository at this point in the history
  • Loading branch information
nodkz committed Jul 18, 2016
1 parent 3c048a1 commit 3357a30
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/resolvers/helpers/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}
}
});
Expand Down

0 comments on commit 3357a30

Please sign in to comment.