hasura / hasura/graphql-engine

Relay pagination: endcursor is null but should be of type non-null

Open
#10,030 0 comments 1 reaction 0 assignees View on GitHub
k/bug t/gql-services v2
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

### Version Information

Server Version:
CLI Version (for CLI related issue): 2.30.1

### Environment

Cloud

### What is the current behaviour?

We are using pagination with Hasura Relay.

According to schema, `startCursor` and `endCursor` should be of type.kind "Non Null".

However, when the query runs out of results at the end of the pagination, the response is:

```
"data": {
"query_connection": {
"edges": [],
"pageInfo": {
"hasNextPage": false,
"endCursor": null
}
}
}
}
```

Our frontend GraphQl client throws an error:

`Suppressed: com.apollographql.apollo3.exception.JsonDataException: Expected a string but was NULL at path data.getforyoupage_connection.pageInfo.endCursor`

### What is the expected behaviour?

According to schema, we should return a `null` value but rather an empty string.

How to solve this?

Contributor guide

Open the contributing guide

Research direction

No source file or test is named in the issue. Start by reproducing the Hasura Relay pagination query with no remaining results and inspect the pageInfo response. Done means the endCursor response matches the declared schema and no longer causes the reported GraphQL client error.

Written by the indexing model from the issue text.

Assessment

Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.