facebook / facebook/relay

The connection handler does not properly handle null endCursor

Open
#4,040 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
19k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

https://github.com/facebook/relay/blob/cd1e9ae06d114c3e353d384ccbe956e6800a8679/packages/relay-runtime/handlers/connection/ConnectionHandler.js#L219-L221

This conditional is questionable. I believe the spec technically still says that endCursor is non-nullable but that is not how it used in practice nor in the types used in this library.

If edges is empty then logically endCursor doesn't really have a value so null is used. This code should be updated to change the client side page info here to allow null to be set for endCursor.

If a backend returns `hasNextPage` equal to true and `endCursor` equal to null, then the pagination code for `hasMore` should be false. However, you can't ever get that endCursor equal to null to actually get set on this connection so hasMore keeps returning true. Arguable `hasNextPage` should be `false` in that situation, but that is a separate point.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.