Skip to content
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

[ApolloPagination] Bi-directional paging support #3265

Closed
Iron-Ham opened this issue Oct 26, 2023 · 1 comment · Fixed by apollographql/apollo-ios-dev#115
Closed

[ApolloPagination] Bi-directional paging support #3265

Iron-Ham opened this issue Oct 26, 2023 · 1 comment · Fixed by apollographql/apollo-ios-dev#115
Labels
feature New addition or enhancement to existing solutions pagination

Comments

@Iron-Ham
Copy link
Contributor

Iron-Ham commented Oct 26, 2023

Use case

After merging apollographql/apollo-ios-dev#80, I'll be tackling building out bi-directional pager support.

Concretely:

  • At GitHub, we have a use-case where we often drop users into the middle of a paginated list. For example, when you tap a notification to an issue that you've been mentioned in, we will load the body of the issue, and we will begin forward pagination with the cursor of the specific comment you were mentioned in. If there are previous elements, we will append a ("Load n other items") button in the timeline.
  • We want to be able to paginate forward if the user scrolls down
  • We want to be able to reverse paginate if the user taps the button.

Describe the solution you'd like

My gut says that this is an additional function to the GraphQLPager API: loadPrevious that should only be available if InitialQuery == PaginatedQuery. Assuming that to be the case, when we successfully loadPrevious, we should shift everything left: what was the initial result should now be the new result, and the initial result should be made the first element of the next-page-results array.

This may involve a change for reverse pagination such that reverse-pagination based strategies would have to rely on loadPrevious (or, a different loadPrevious -- realistically in the event of InitialQuery being different than PaginatedQuery for a reverse paginated API, the "initial query" is just the last page of data).

Something to think on. I'll be working on this starting Monday, but won't be including it as part of the open pull request -- I'm worried it'll be far too hard to review at that point, as it's already a bit large.

Copy link
Contributor

Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo iOS usage and allow us to serve you better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New addition or enhancement to existing solutions pagination
Projects
None yet
2 participants