graphql-compose-mongoose icon indicating copy to clipboard operation
graphql-compose-mongoose copied to clipboard

$or operator for filtering

Open jfcieslak opened this issue 7 years ago • 4 comments

There seems to be no defined way to use $or operators in filters. Can you suggest the proper way of adding a resolver for such case? I imagine that the resulting graphQL schema should look sth. like this:

input filterInput {
    OR: [filterInput!]! 
}

jfcieslak avatar Feb 19 '18 09:02 jfcieslak

Good feature request. Added in 3.1.0

All filter arguments now get AND and OR fields, where you may provide complex nested sub-queries. Affected filter arguments in the following resolvers: findOne, findMany, updateOne, updateMany, removeOne, removeMany.

Live Demo

Current test case: https://github.com/graphql-compose/graphql-compose-mongoose/blob/6abef5fcfed5c4132c84ee74f02fb93273ce70c0/src/tests/github-issues-test.js#L156-L190

nodkz avatar Feb 19 '18 13:02 nodkz

WOW. That was a fast turnaround for a feature request. Thanks!

jfcieslak avatar Feb 19 '18 17:02 jfcieslak

I gave this a try and it works great when using field filters, but custom filter arguments, ones added with resolver.addFilterArg, aren't being picked up when used inside an OR/AND

bakuzan avatar Feb 22 '18 10:02 bakuzan

@bakuzan I opened a new issue with your problem: https://github.com/graphql-compose/graphql-compose-mongoose/issues/95 Lets discuss it there separately.

nodkz avatar Feb 23 '18 04:02 nodkz