Skip to content

Comment pagination fails due to wrong $field key in AbstractCursor #3068

Description

@giafrata

Description

Doing a query to retrieve paginated comments in a single post, passing after parameter raise this error

"debugMessage": "Expected "value" value to be provided for WPGraphQL\Data\Cursor\CommentObjectCursor cursor compare field. A scalar value must be given.",

the problem is that you are checking for "by" variable but are using "value" here

if ( ! isset( $field['value'] ) ) {

query AllComments($postId: ID!, $after: String = "") {
  post(id: $postId, idType: DATABASE_ID) {
    id
    comments(where: {orderby: COMMENT_PARENT, order: ASC}, last: 1, after: $after) {
      pageInfo {
        endCursor
        hasNextPage
        hasPreviousPage
        startCursor
      }
      nodes {
        content(format: RENDERED)
        author {
          node {
            name
            email
          }
        }
        id
        databaseId
        date
        parentId
        dateGmt
        replies {
          nodes {
            content(format: RENDERED)
            author {
              node {
                name
                email
              }
            }
            id
            databaseId
            parentId
            date
            dateGmt
          }
        }
      }
    }
    commentCount
  }
}

Steps to reproduce

Try to paginate comments using after parameter.

Additional context

No response

WPGraphQL Version

1.22.0

WordPress Version

6.4.1

PHP Version

8.1

Additional environment 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

Labels

component: connectionsRelating to GraphQL Connectionseffort: lowAround a day or lessimpact: medMinor performance improvements, fix broad user base issuesstatus: actionableReady for work to begintype: bugIssue that causes incorrect or unexpected behavior

Type

No fields configured for Bug.

Projects

Status
✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions