Fix hasPreviousPage/hasNextPage logic for array connections#400
Fix hasPreviousPage/hasNextPage logic for array connections#400fraunos wants to merge 1 commit intographql:mainfrom
Conversation
Update connectionFromArraySlice to follow Relay spec for hasPreviousPage and hasNextPage.
|
|
The relay spec is a bit wishy-washy on this, in particular:
The "if it can do so efficiently" is typically "no". With limit/offset pagination it's cheap to determine if you have a previous/next page (previous: is offset > 0, next: fetch 1 extra, if present then has next) but with actual cursor pagination (where cursors are not a simple offset) it's normally much harder to determine if there's a previous page when paginating forward, often requiring a second (reverse) fetch. The end result is that most implementations simply say "we can't do it efficiently" and return |
Update connectionFromArraySlice to follow Relay spec for hasPreviousPage and hasNextPage.
This makes the PageInfo return
hasPreviousPageandhasNextPageregardless of the direction of pagination (firstwithafterorlastwithbefore)