Repository navigation
Make the cursor pager's previous page return the page before the current one - #101
Merged
Merged
Conversation
…ent one PreviousPageAsync sent the current page's end cursor as 'before' while keeping 'first', which asks for the first N items before that cursor - always the top of the list. Going back from page 3 returned page 1, and the existing test only went back from page 2, so it passed by accident. The pager now remembers the page size the query was built with and pages backwards with 'last' plus the current page's start cursor, and forwards with 'first' plus the end cursor, clearing the other pair each way.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GraphCursorPager.PreviousPageAsync/PreviousPageWithResultAsyncsent the current page's end cursor asbeforewhile keepingfirst: N.first+beforeasks for the first N items before that cursor, which always counts from the top of the list - so going back from page 3 returned page 1. The existingOrders_Pagingtest only went back from page 2, where the two coincide, so it passed by accident.Fix
first, elselast).last: <page size>,before: StartCursor; clearsfirst/after.first: <page size>,after: EndCursor; clearslast/beforeso you can go back and forth.Tests
Two new tests in
QueryPagingTestspage forward to page 3 withOrders(first: 1), go back, and assert they land on page 2 (and that going forward again returns page 3). Both failed before the fix.Known limitation
If the query sets neither
firstnorlast(server default page size), the pager has no page size to send aslast, so going back is still only correct from page 2.