简体   繁体   中英

Correct value for `startCursor` and `endCursor` in `PageInfo` when there are 0 items/edges? Is the Relay pagination spec incorrect?

The Relay pagination specification says the following about PageInfo :

It must also contain fields startCursor and endCursor , both of which return non-null opaque strings.

[...]

startCursor and endCursor must be the cursors corresponding to the first and last nodes in edges, respectively.

But what if I want to return zero items? There are lots of reason why a request to that specific endpoint would return an empty connection.

I don't see what values startCursor and endCursor should have in that case. The obvious answer is null , but the spec explicitly says "non-null". What's up with that?

For what it's worth, I looked at roughly 15 articles about the topic of "graphql pagination" and all of those either ignore the issue or assign null in the case of an empty list. So at this point it seems that the spec is just wrong or incompatible with the real world?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM