-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggestion: Change metadata #84
Comments
Came here to ask for the same functionality. This would simplify graphql-consuming code on the client. |
ericsullivan
added a commit
to annkissam/paginator
that referenced
this issue
Aug 24, 2021
ericsullivan
added a commit
to annkissam/paginator
that referenced
this issue
Jan 4, 2022
ericsullivan
added a commit
to annkissam/paginator
that referenced
this issue
Feb 15, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TL;DR
Make after and before always present and add has_next_page and has_previous_page booleans to metada.
Hello there 👋
I've recently started using this library to cursor paginate a list in a small Phoenix + Vue project and bumped into an issue that required a lot of work-arounds when using this in an infinite scroll scenario.
Problem
Picture this:
We want to paginate through 5 records ([1, 2, 3, 4, 5]) 3 at a time (limit: 3).
So, the first query returns something like this:
On the client-side application I push the 3 entries to an items array and store the
after
cursor in a pagination object.The second query then will ask for 3 records after the cursor 3 and paginatior returns the following:
On the client-side application I push the 2 entries to the items array and now the
after
cursor isnull
so if I store it and use it, the next query will return the first 3 entries again. I can't use thebefore
cursor as well because the next query would then return me the 5th item again.I built a bit of a complex work-around on the client-side where I fetch the before the last and the last items just to get the cursor of the last item.
Suggestion
Make the after and before cursors be always present so that the consumers of the API always have the beginning and end of the page.
Add two different metadata properties to show that there is a next page and a previous page.
I suggest has_next_page and has_previous_page mimicking graphQL's relay style pagination - https://relay.dev/graphql/connections.htm#sec-undefined.PageInfo
What do you think?
The text was updated successfully, but these errors were encountered: