$or operator does not work with resolver.addFilterArg()
@bakuzan wrote in #93:
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
Yep, it does not work yet. I need to think how to integrate it to filter logic.
Internally resolver.addFilterArg() wraps underlying resolver and prepare resolveParams.rawQuery argument. And it cannot be pick up inside an OR/AND. For now, I don't know how to properly alive this logic. It quite complex task and cannot be solved quickly. Need to think.
As a workaround
- If you have a simple argument which needs to be added to
filter(without custom processing of provided argument viaaddFilterArg). You may just add a new arg directly toResolverandargvalue from request will be picked up.
Resolver.getArgTC('filter').setField('myArg', { type: 'String', defaultValue: 20, description: 'My simple argument' })
- Or write your custom resolver where you describe
argsandresolvemanually.
Unfortunately my filter isn't simple. For now I guess I'll write a custom resolver!
Yep, with something complex is better to write own resolver.
At the same time you will know how tediously do it by hands and how resolver generation by graphql-compose-mongoose makes live easier.