`relayStylePagination` `read` method clobbers `pageInfo.startCursor` and `pageInfo.endCursor`
See original GitHub issueIntended outcome: With a query as follows:
query {
someConnectionField {
edges {
node {
id
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
I would expect endCursor
to be the value returned from the API, not ""
.
Actual outcome:
Even though the API returns a valid cursor in endCursor
, the relayStylePagination
type policy attempts to read it from edges[0].cursor
(or the last edge’s cursor) and completely replaces the one in `pageInfo.
These should default to pageInfo.{startCursor,endCursor}
and not ""
.
https://github.com/apollographql/apollo-client/blob/cefb3c32621de6973191c7abb6edd365d53cbf41/src/utilities/policies/pagination.ts#L101-L102
How to reproduce the issue:
Perform a query as described above while using relayStylePagination
.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Cursor-based pagination - Apollo GraphQL Docs
With this approach, the requested cursor ID should not appear in the new page, since it identifies the item just before the beginning...
Read more >graphql – CSS-Tricks
pageInfo object that provides: endCursor – cursor of the last item in posts.edges ,; startCursor – cursor of the first item in posts.edges ......
Read more >Apollo Client relayStylePagination doesn't paginate data ...
I've implemented a TableWithData component that creates a Table after fetching the data using a relayStylePagination logic
Read more >Less code for relay style paginations in Apollo and React.
I also know some people who use Relay style pagination, ... Put the new comments at the end of the list and update...
Read more >GraphQL Pagination with Apollo V3 - Part 2
Our return data consists of pageInfo containing the data for the endCursor ... In the render method, we map the edges containing the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@benjamn Gave your PR a quick glance, it looks good to me. Glad it was (relatively) easy! I was just about to submit a PR earlier, but you beat me to it 😅 . TYSM!
@migueloller @diracs-delta @meliborn Please have a look at this PR and let me know if it meets your expectations: #8438