Skip to content

Querying by search term + pagination doesn't respect default sorting #2550

Description

@justlevine

Description

When paginating through search terms, a different result order is used when a cursor is provided.

via Lorenzo Castro on Slack

Steps to reproduce

  1. Create two posts with 'Search Term' in the title or content.
  2. Run the following query
fragment SearchFragment on RootQueryToPostConnection {
  edges {
    node {
      databaseId
      title
      content
    }
    cursor
  }
}

query searchQuery( $after: String) {
  all: posts(
    first: 6, 
    where: {search: "search"}
  ) {
    ...SearchFragment
  }
  afterFirst: posts(
    first: 6,
    where: {search: "search"},
    after: $after
  ) {
    ...SearchFragment
  }
  afterFirstSorted: posts(
    first: 6, 
    where: {
      search:"search", 
      orderby: {field:DATE, order:ASC}}, 
    after:$after
  ) {
    ...SearchFragment
  }
}

Additional context

image

WPGraphQL Version

1.11.1

WordPress Version

6.0.2

PHP Version

8.0.19

Additional enviornment details

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have disabled ALL plugins except for WPGraphQL.

  • Yes
  • My issue is with compatibility with a specific WordPress plugin, and I have listed all my installed plugins (and version info) above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    close candidateNeeds confirmation before closingcomponent: paginationRelating to paginationduplicateThis issue or pull request already existsstale?May need to be revalidated due to prolonged inactivitytype: bugIssue that causes incorrect or unexpected behavior

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions