Skip to content

fix(review): GraphQL schema error in getThreadIdFromComment - pullRequestReviewThread field doesn't exist #251

Description

@amondnet

Summary

The gh please pr review reply command fails with a GraphQL schema error because the pullRequestReviewThread field doesn't exist on the PullRequestReviewComment type.

Error Message

❌ Error: GraphQL query failed: gh: Field 'pullRequestReviewThread' doesn't exist on type 'PullRequestReviewComment'

Root Cause

In src/lib/github/review-operations.ts, the getThreadIdFromComment function (lines 89-115) uses an invalid GraphQL query:

query GetThreadFromComment($commentId: ID!) {
  node(id: $commentId) {
    ... on PullRequestReviewComment {
      pullRequestReviewThread {  # ← This field doesn't exist!
        id
      }
    }
  }
}

The GitHub GraphQL schema does not have a pullRequestReviewThread field on the PullRequestReviewComment type.

Steps to Reproduce

gh please pr review reply PRRC_kwDOxxxxxx -b "test reply"

Expected Behavior

The command should successfully create a reply to the review comment.

Actual Behavior

The command fails with the GraphQL schema error.

Suggested Fix

Option 1: Use PR's reviewThreads and match by comment ID

query GetThreadFromComment($prId: ID!, $commentId: ID!) {
  node(id: $prId) {
    ... on PullRequest {
      reviewThreads(first: 100) {
        nodes {
          id
          comments(first: 100) {
            nodes {
              id
            }
          }
        }
      }
    }
  }
}

Then find the thread that contains the target comment ID.

Option 2: Use REST API fallback

# Get all review comments and find thread relationship via in_reply_to_id
GET /repos/{owner}/{repo}/pulls/{pull_number}/comments

Environment

  • gh-please version: latest
  • gh version: 2.x
  • OS: Linux/macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions