GraphQl: Fix duplicated items in descending pagination - #352
Merged
iLLiCiTiT merged 2 commits intoSep 14, 2026
Conversation
Descending pagination continued from 'startCursor'. Server returns edges of a page queried with 'last' from the newest item, so 'startCursor' points to the newest item of the page and the next page overlapped the previous one except for one item. Continue from 'endCursor' for both orders. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
The fake server always raises an unbalanced-query error, so the regression test cannot run.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Fixes duplicate results in descending GraphQL pagination and adds regression-test infrastructure.
Changes:
- Uses
endCursorfor descending pagination. - Adds an in-memory GraphQL fake server.
- Adds regression coverage for ordering and duplicate-free results.
File summaries
| File | Summary |
|---|---|
tests/test_graphql_descending_pagination.py |
Adds descending pagination regression coverage. |
tests/graphql_fake_server.py |
Adds fake GraphQL server support; critical parser validation issue prevents tests from running. |
ayon_api/graphql.py |
Updates pagination to use endCursor. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+101
to
+102
| if stack: | ||
| raise ValueError("Unbalanced query") |
iLLiCiTiT
approved these changes
Sep 14, 2026
iLLiCiTiT
deleted the
bugfix/graphql-descending-pagination-duplicates
branch
September 14, 2026 09:03
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.
Bug
Querying GraphQl in descending order (
order=SortOrder.descending, orget_events(last=...)) returns the same items many times once more than one page (300 items) is needed.On a local server,
get_events(order=SortOrder.descending, limit=900)returned 900 events of which only 302 were unique.Cause
For descending order the next page was requested with
before: <pageInfo.startCursor>.AYON server returns the edges of a page queried with
last: Nordered from the newest item, andstartCursoris the cursor of the first edge, so it points to the newest item of the page. Requestingbeforethat item returns the same page again shifted by one item:Fix
Always continue from
endCursor(the cursor of the last received edge) —after:for ascending,before:for descending — and queryendCursorinpageInfofor both orders. As a side effect descending results are now returned in consistent descending order instead of page-shuffled.Reproduce
Requires a server with more than 300 events.
Testing notes
get_events(last=900)) and compare total vs. unique ids; also checkcreatedAtis descending.endCursorwas already used), e.g.get_folderson a project with more than 300 folders still returns all folders.tests/test_graphql_descending_pagination.pyreproduces it against an in-memory fake server (no AYON server needed).🤖 Generated with Claude Code