graphql-compose-elasticsearch
graphql-compose-elasticsearch copied to clipboard
Per Page returns default when 0 is passed in for Search Pagination
On Agg calls, not interested in any of the hits items.
Example.
{
users(aggs:{
key:"my_agg",
value: {
terms: {field:firstName, size:1000}
}
},
perPage: 0)
{
aggregations
items {
...
}
}
}
The above will still return 20 items
Think problem coming from here
possible solution:
const perPage = parseInt(args.perPage ) !== NaN ? args.perPage : 20;
Argument perPage
already parsed by graphql. And if it is non-integer - then the client got an error.
Why do you want to pass 0
value for perPage?
If you want to fix this you may send the following PR
- const perPage = args.perPage || 20;
+ const perPage = args.perPage ?? 20;
and add nullish-coalescing-operator to the babel config.
Passing 0 because doing an Agg call.