You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When writing docs in #262, I recognized that support for offset pagination could be better. Specifically:
We can support more paging types (reverse, bidirectional)
We can support multi-query paging.
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 and AsyncGraphQLQueryPager.
🤖🤖 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 the extractPageInfo function in multiple test classes.
Here are the most important changes:
Changes to AsyncGraphQLQueryPager creation:
Tests/ApolloPaginationTests/AsyncGraphQLQueryPagerTests.swift: The AsyncGraphQLQueryPager is now created with makeQueryPager instead of makeForwardCursorQueryPager. The queryProvider has been replaced with an initialQuery 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. The extractPageInfo function has also been updated to handle both initial and paginated data. [1] [2] [3] [4]
Changes to extractPageInfo function:
Tests/ApolloPaginationTests/AsyncGraphQLQueryPagerCoordinatorTests.swift: The extractPageInfo function in AsyncGraphQLQueryPagerCoordinatorTests has been updated to handle both initial and paginated data. [1] [2]
Tests/ApolloPaginationTests/GraphQLQueryPagerTests.swift: The extractPageInfo function in GraphQLQueryPagerTests has been updated to handle both initial and paginated data. [1] [2]
Tests/ApolloPaginationTests/GraphQLQueryPagerTestsCoordinator.swift: The extractPageInfo function in GraphQLQueryPagerTestsCoordinator has been updated to handle both initial and paginated data.
Tests/ApolloPaginationTests/ReversePaginationTests.swift: The extractPageInfo function in ReversePaginationTests has been updated to handle both initial and paginated data.
Addition of new test:
Tests/ApolloPaginationTests/OffsetTests.swift: A new test file OffsetTests.swift was added to test the handling of offset pagination.
Follow-up from apollographql/apollo-ios-dev#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.Originally posted by @Iron-Ham in apollographql/apollo-ios-dev#268
The text was updated successfully, but these errors were encountered: