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

Per Page returns default when 0 is passed in for Search Pagination

Open pcasa opened this issue 5 years ago • 3 comments

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

pcasa avatar Feb 23 '20 14:02 pcasa

Think problem coming from here

possible solution: const perPage = parseInt(args.perPage ) !== NaN ? args.perPage : 20;

pcasa avatar Feb 23 '20 14:02 pcasa

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.

nodkz avatar Feb 23 '20 16:02 nodkz

Passing 0 because doing an Agg call.

pcasa avatar Feb 23 '20 16:02 pcasa