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

Paginate sessions #313

Closed
wants to merge 1 commit into from
Closed

Paginate sessions #313

wants to merge 1 commit into from

Conversation

BoD
Copy link
Collaborator

@BoD BoD commented May 6, 2024

Loads the sessions by pages of 10, instead of loading the whole list immediately.

This is meant to look at how the Apollo Kotlin pagination system can be implemented in a real project.

Caveat: the pages are based on the contents of the list: when getting the first few items, we only know about Day 1, and only when scrolling to the end of Day 1 do we know that there's a Day 2, and the pager gets updated. Because of this, this can't be merged and I'll close the PR right now - at least it's a reference at how to use the pagination system that will be in the PR history.

The steps were:

  1. depend on the incubating artifacts
  2. update extra.graphqls
    2.1 mark sessions as embedded
    2.2 mark sessions.first and .after as pagination args
    2.3 mark pageInfo as embedded
  3. implement a MetaDataGenerator to keep track of endCursor and after
  4. implement a FieldMerger to merge the nodes lists
  5. watch the sessions, so the UI is refreshed when a page is appended
  6. add a fetchNextSessionsPage fun and call it from the UI when reaching the end of the LazyColumn

Note: steps 2-4 would have been simpler if the schema were following the Relay pagination spec - the rest would have been the same.

pagination.webm

@BoD BoD closed this May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant