graphql-compose / graphql-compose/graphql-compose-elasticsearch

searchPagination won't work in ES > 7.0

Open
#96 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
584
Forks
76
PR merge metrics
No merged PRs in 30d

Description

There is breaking change in total hits so now graphql generates error:
```
Int cannot represent non-integer value: { value: 1364, relation: \"eq\" }"
```

I think this should be checked if it is object:

```
const itemCount = res.count || 0;
```
Here is link to this breaking change:

https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking-changes-7.0.html#hits-total-now-object-search-response

I think `itemCount` could be changed to something like this:

```
const itemCount = res.count.hasOwnProperty('value') && res.count.hasOwnProperty('relation') && res.count.relation == 'eq' ? res.count.value : res.count || 0;
```

Unfortunately this won't work if `hits_total` will be greater than 1000.
So maybe it would be better to set `track_total_hits` to `true`

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.