fix: Connection pagination refactor#2408
fix: Connection pagination refactor#2408justlevine wants to merge 30 commits intowp-graphql:developfrom
Conversation
First bug:Fetching multiple To replicate:
{
comments(first:2) {
pageInfo {
startCursor
endCursor
}
edges {
cursor
node {
databaseId
}
}
}
after:comments(first:1, after:"YXJyYXljb25uZWN0aW9uOjM="){ # the second cursor.
pageInfo {
startCursor
endCursor
}
edges {
cursor
node {
databaseId
}
}
}
}All results should be shown correctly. The reason for this is that the first comments query overfetches by one.
Screenshots |
|
@justlevine I see that this PR removed a lot of tests. For example:
etc. Were these removed because they're duplicate tests and have coverage elsewhere? or was there another reason for removing them? |
| ); | ||
| $second_to_last_comment = $comments[0]; | ||
| codecept_debug( $expected ); | ||
| $this->markTestIncomplete( 'works until here' ); |
There was a problem hiding this comment.
@justlevine For this to work, we'll need to add functionality similar to what's been done for Post and Term connections:
See: https://github.com/wp-graphql/wp-graphql/blob/develop/src/Data/Config.php#L187-L216
jasonbahl
left a comment
There was a problem hiding this comment.
@justlevine I like what you're doing here for sure.
There's a lot of rough patches with pagination and it would be lovely to get them all shored up.
I anticipate this taking some time to do comprehensively, so I propose we at least get a fix for the taxonomy pagination regression first, then continue working through other pagination issues as a focus of another release.
I have a branch locally where I have the Taxonomy pagination working that I can PR up with a few tests, so that we can unblock the Gatsby users that are suffering from the regression, then we can keep working on this to get things in a better spot.
Mostly duplicates. What wasnt has been relocated to the {ConnectionType}QueriesTest/{ConnectionType}PaginationTest to keep a standard pattern and ensure tests arent duped/overlooked in the future. |
|
Okay first pass is done: Refactored AbstractConnectionResolver to better follow the Connection spec, while using smaller methods to allow easier creation of child classes. Of note.
To Do
|
|
Those cests should not be failing 🤔 |
|
Turns out most tests don't clean up after themselves, and some use duplicate names for objects causing tests to pass that shouldnt. Tried to catch/fix as many as I could. I think all thats left are |
|
Code Climate has analyzed commit c7d9c9b and detected 3 issues on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
|
Work moved to #2457 |


What does this implement/fix? Explain your changes.
This PR aims to handle a slew of issues with paginating on GraphQL connections.
Originally surfaced by #2343, a review showed not just regressions caused by #2294, but others dating back to
v1.6.xas well.markTestIncomplete()notes where the first bug is surfaced. As those are addressed, it's possible the remaining test code will need to be tweaked.Next step is using those tests to fix the exposed issues. Work will continue on this draft PR.
Contributions are welcome, either as comments on this PR, or by your own commits - just remember to
git rebase justlevine/fix/connection-pagination, resolve any conflicts, andgit push justlevine/fix/connection-pagination --forcewhen you're done to keep the commit history clean.Does this close any currently open issues?
Will be filled out when the PR is read for merge.
Any relevant logs, error output, GraphiQL screenshots, etc?
(If it’s long, please paste to https://ghostbin.com/ and insert the link here.)
Any other comments?
...
Where has this been tested?
Operating System: Ubuntu 20.04 (wsl2 + devilbox + php 8.0.15)
WordPress Version: 6.0