Skip to content
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

#1827 - Term connection order issues #1828

Merged
merged 5 commits into from
Mar 31, 2021

Conversation

jasonbahl
Copy link
Collaborator

What does this implement/fix? Explain your changes.

This adds an order field to Term Connection Queries allowing the queries to set an order of ASC or DESC.

Users can now query like so:

{
  categories( where: { orderby: COUNT order: ASC} ) {
    nodes {
      id
      databaseId
      name
      count
    }
  }
}

Does this close any currently open issues?

Closes #1827

Any other comments?

Post Connections support orderby as an array of field/order like below:

where: { orderby: [ { field: TITLE order: ASC }, { field: DATE, order: DESC } ]

The WP_Term_Query only supports a single input for order and orderby and WPGraphQL maps to WP_Term_Query, so only a single order and orderby are supported, not a list of fields with their own cardinality.

- add "order" enum to Term Connection Queries
- Add a test case to make sure the query with order is valid and returns
@jasonbahl jasonbahl self-assigned this Mar 29, 2021
@jasonbahl jasonbahl added type: bug Issue that causes incorrect or unexpected behavior impact: med Minor performance improvements, fix broad user base issues labels Mar 29, 2021
@coveralls
Copy link

coveralls commented Mar 29, 2021

Coverage Status

Coverage decreased (-0.1%) to 79.832% when pulling 6892faf on jasonbahl:bug/#1827-taxonomy-orderby into d58ef1f on wp-graphql:develop.

- Add CursorPaginationForCategoriesTest
- Remove check for `before` argument in TermObjectConnectionResolver when flipping the ASC/DESC args
- Update TermObjectCursor to handle ASC/DESC order based on the compare direction
- Code formatting adjustments
- Remove commented code from refactoring to add Cursor support to term connections
- Update yoda conditional
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: connections Relating to GraphQL Connections component: pagination Relating to pagination impact: med Minor performance improvements, fix broad user base issues type: bug Issue that causes incorrect or unexpected behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Taxonomy Queries Using Orderby Count No Longer Sort Correctly
2 participants