-
Notifications
You must be signed in to change notification settings - Fork 41
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] Remove convenience functions, improved Offset-pagination support #268
Conversation
👷 Deploy request for eclectic-pie-88a2ba pending review.Visit the deploys page to approve it
|
6e4cf80
to
06e5572
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
c762dcf0 [ApolloPagination] Remove convenience functions, improved Offset-pagination support (#268) git-subtree-dir: apollo-ios-pagination git-subtree-split: c762dcf0e62508e9b54163e854fbfb257f63feda
…nvenience functions, improved Offset-pagination support git-subtree-dir: apollo-ios-pagination git-subtree-mainline: 637a4ad git-subtree-split: c762dcf0e62508e9b54163e854fbfb257f63feda
|
Follow-up from #267
When writing docs in #262, I recognized that support for offset pagination could be better. Specifically:
As such, this pull request modifies the OffsetPagination class to be a namespace, just like CursorBasedPagination. We introduce three new structs to facilitate pagination:
OffsetPagination.Forward
: Introduced OffsetPagination.Forward structure to represent a forward pagination state. This is identical to the previous contents of OffsetPagination.OffsetPagination.Reverse
: Introduced OffsetPagination.Reverse structure to represent a reverse pagination state.OffsetPagination.Bidirectional
: Introduced OffsetPagination.Bidirectional structure to represent a bidirectional pagination state.Once introduced, I added tests to use an offset pagination scheme.
The tests made clear that offset-pagination needs the full set of existing data in order to properly determine whether the end of the list had been reached.
As a result, there were changes to the
PageExtractionData
type to include an additional value. Classes and tests were updated accordingly.Finally, we generalized and deleted the many convenience functions present – we are working under the assumption that if a user is primarily only using one pagination type, that they can trivially create their own extension. In order to facilitate the user adding their own extensions, two new initializers were added to both
GraphQLQueryPager
andAsyncGraphQLQueryPager
.🤖🤖 Copilot Generated Summary 🤖🤖
This pull request includes changes to the ApolloPaginationTests in the Apollo iOS SDK. The changes focus on modifying the way the
AsyncGraphQLQueryPager
is created and how it handles pagination, as well as updating theextractPageInfo
function in multiple test classes.Here are the most important changes:
Changes to
AsyncGraphQLQueryPager
creation:Tests/ApolloPaginationTests/AsyncGraphQLQueryPagerTests.swift
: TheAsyncGraphQLQueryPager
is now created withmakeQueryPager
instead ofmakeForwardCursorQueryPager
. ThequeryProvider
has been replaced with aninitialQuery
and a closure that provides a new query based on the page and direction. This allows for the handling of both next and previous pages. TheextractPageInfo
function has also been updated to handle both initial and paginated data. [1] [2] [3] [4]Changes to
extractPageInfo
function:Tests/ApolloPaginationTests/AsyncGraphQLQueryPagerCoordinatorTests.swift
: TheextractPageInfo
function inAsyncGraphQLQueryPagerCoordinatorTests
has been updated to handle both initial and paginated data. [1] [2]Tests/ApolloPaginationTests/GraphQLQueryPagerTests.swift
: TheextractPageInfo
function inGraphQLQueryPagerTests
has been updated to handle both initial and paginated data. [1] [2]Tests/ApolloPaginationTests/GraphQLQueryPagerTestsCoordinator.swift
: TheextractPageInfo
function inGraphQLQueryPagerTestsCoordinator
has been updated to handle both initial and paginated data.Tests/ApolloPaginationTests/ReversePaginationTests.swift
: TheextractPageInfo
function inReversePaginationTests
has been updated to handle both initial and paginated data.Addition of new test:
Tests/ApolloPaginationTests/OffsetTests.swift
: A new test fileOffsetTests.swift
was added to test the handling of offset pagination.