-
Notifications
You must be signed in to change notification settings - Fork 442
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
Unexpected Results While Retrieving Terms via Cursor-Based Pagination, Sorted by Term Name, When Multiple Terms Have Identical Names #2926
Comments
@jasonbahl, I have re-enabled the link for reproduction of the issue. It is a localwp wp that connects online. This needs my machine to be up. Could you please that you can connect to it from your end? |
@mohjak I was able to login to your environment. I think you might have some debug code active though, as I'm seeing the following response when executing a query: |
@mohjak yes, open a PR and we can go from there! 🙏🏻 By the way, thanks so much for the detailed issue, steps to reproduce and the effort put into resolving it. Much appreciated! 🙌🏻 @kidunot89 recently worked on this PR (#2882) fixing similar issues with pagination for queries for posts, so we can likely take some of the work he did for that and apply it to Term cursors as well! |
@jasonbahl you are right I am getting the same result with public users, I was executing queries with a logged in user, since I am debugging and review SQL queries. I didn't figure this out. Nothing special, I've just created an empty wp with wp-graphql and the same result appears when I view the website from a public user. I think the problem is related to localwp online service because the issue is not appearing when I am viewing from the localhost url. Anyways, please if you want to reproduce the issue execute queries for a logged in user. |
wp-graphql#2926 Terms cursor now handles identical names accurately with asc/desc and after/before.
Description
Context:
I am encountering unexpected behavior when querying for terms with identical names using cursor-based pagination.
Data Setup:
Here are the terms that serve as children to the term with
term_id: 39
.Initial GraphQL Query:
Initial SQL Query:
Expected and Actual Outcome:
The executed GraphQL query returns the following JSON output, which is in line with expectations:
Follow-up GraphQL Query:
I then executed another query, using the
endCursor
obtained from the first query:Follow-up SQL Query:
Unexpected Outcome:
Contrary to expectations, the following data was returned:
I expected to see
term_id: 201, term_id: 202
in the next cursor pagination as I presumed that if the names are identical, the pagination should consider using the nextterm_id
.Code Reference:
Upon inspecting the code here, it seems that the
term_id
is only used for ordering if there are no other specified order criteria.Suggested Fix:
I propose that
term_id
should act as a secondary sorting parameter when the names are identical, ensuring consistent cursor-based pagination.Steps to reproduce
You can replicate this issue at Test Terms Cursor with the following credentials:
Additional context
No response
WPGraphQL Version
1.16.0
WordPress Version
6.3.1
PHP Version
8.1.9
Additional enviornment details
No response
Please confirm that you have searched existing issues in the repo.
Please confirm that you have disabled ALL plugins except for WPGraphQL.
The text was updated successfully, but these errors were encountered: