Skip to content

fix: convert GraphQL queries to single-line format in resolve-pr-threads#35

Merged
JacobPEvans merged 3 commits intomainfrom
fix/graphql-single-line
Feb 14, 2026
Merged

fix: convert GraphQL queries to single-line format in resolve-pr-threads#35
JacobPEvans merged 3 commits intomainfrom
fix/graphql-single-line

Conversation

@JacobPEvans
Copy link
Owner

@JacobPEvans JacobPEvans commented Feb 14, 2026

Summary

  • Convert all GraphQL queries to single-line --raw-field format
  • Replace GraphQL variable declarations with placeholder substitution
  • Add REST API pattern for threaded review comment replies
  • Add critical warnings about single-line format requirements
  • Add comprehensive placeholder substitution documentation
  • Align with patterns from ai-assistant-instructions/github-graphql skill

Problem

The /resolve-pr-threads skill had recurring GraphQL errors:

  1. Variable $prNumber of type Int! was provided invalid value
  2. Unknown JSON field: reviewThreads
  3. Multi-line query encoding/parsing failures

Root Cause

Multi-line GraphQL queries with variable declarations ($owner, $repo, $number) caused:

  • Type coercion errors when gh CLI passed variables
  • Shell encoding issues with newlines
  • Inconsistent placeholder substitution

Solution

Converted all queries to match the reference pattern from ai-assistant-instructions:

  • Single-line format with --raw-field
  • Placeholder notation: {OWNER}, {REPO}, {NUMBER}
  • No GraphQL variable declarations
  • REST API for threaded replies (preserves threading)

Files Changed

  • graphql-queries.md: All 3 queries converted to single-line, added REST API reply section, added critical warnings
  • SKILL.md: Updated reply pattern to use REST API, added critical format requirements section

Critical Changes

graphql-queries.md

Added critical warning section:

## CRITICAL: Single-Line Format REQUIRED

**ALL GraphQL queries in this file MUST be single-line format with `--raw-field`.**

**NEVER use multi-line GraphQL queries.** Multi-line queries cause:
- Shell encoding issues with newlines
- Variable type coercion errors
- Parsing failures in Claude Code
- Inconsistent behavior

Query conversions:

  1. Fetch Unresolved Threads: Multi-line with $owner, $repo, $number variables → Single-line with {OWNER}, {REPO}, {NUMBER} placeholders
  2. Resolve Thread Mutation: Multi-line with $threadId variable → Single-line with {THREAD_ID} placeholder
  3. Verify Zero Unresolved: Multi-line with variables → Single-line with placeholders

Added new section:

  1. Reply to Review Thread: REST API pattern using gh api repos/{OWNER}/{REPO}/pulls/{NUMBER}/comments/{COMMENT_ID}/replies

SKILL.md

Added critical warning section:

## CRITICAL: GraphQL Query Format Requirements

**ALL GraphQL queries MUST use single-line format with `--raw-field`.**

**NEVER use multi-line GraphQL queries.**

**If you see or are tempted to write a multi-line GraphQL query, STOP. It is WRONG.**

Updated Step 6 (Reply to Each Thread):

  • Old: Multi-line GraphQL mutation with addPullRequestReviewComment and stdin (-F body=-)
  • New: REST API pattern with gh api repos/.../pulls/.../comments/.../replies

Benefits:

  • Maintains threaded conversation structure
  • Uses stable numeric databaseId instead of GraphQL node IDs
  • Simpler and more reliable
  • No stdin complexity

Test Plan

  • Run /resolve-pr-threads on a PR with unresolved threads
  • Verify no GraphQL variable errors
  • Verify replies are threaded (not top-level comments)
  • Verify thread resolution works
  • Verify verification query returns accurate count
  • Markdown lint passes for both files

Verification

Tested with actual PR data:

# Fetch threads (no variable errors)
OWNER=JacobPEvans REPO=ai-assistant-instructions NUMBER=445
gh api graphql --raw-field "query=query { repository(owner: \"${OWNER}\", name: \"${REPO}\") { pullRequest(number: ${NUMBER}) { reviewThreads(last: 100) { nodes { id isResolved } } } } }"
✅ Success

# Resolve thread (no type errors)
THREAD_ID="PRRT_kwDO..."
gh api graphql --raw-field "query=mutation { resolveReviewThread(input: {threadId: \"${THREAD_ID}\"}) { thread { id isResolved } } }"
✅ Success

🤖 Generated with Claude Code


Important

Convert GraphQL queries to single-line format and add REST API pattern for threaded replies in resolve-pr-threads.

  • Behavior:
    • Convert all GraphQL queries to single-line --raw-field format in graphql-queries.md.
    • Replace GraphQL variable declarations with placeholders {OWNER}, {REPO}, {NUMBER}.
    • Introduce REST API pattern for threaded review comment replies in SKILL.md.
  • Documentation:
    • Add critical warnings about single-line format requirements in graphql-queries.md and SKILL.md.
    • Provide comprehensive placeholder substitution examples in graphql-queries.md.
  • Misc:
    • Align query patterns with ai-assistant-instructions/github-graphql skill.

This description was created by Ellipsis for 1f4ea18. You can customize this summary. It will automatically update as commits are pushed.

- Convert all GraphQL queries to single-line --raw-field format
- Replace GraphQL variables with placeholder substitution
- Add REST API pattern for threaded replies
- Add critical warnings about single-line format requirements
- Add placeholder substitution examples
- Align with github-graphql skill patterns from ai-assistant-instructions

Fixes recurring errors:
- Variable type coercion errors ($prNumber, $number)
- Multi-line query encoding issues
- reviewThreads field not found errors

Changes:
- graphql-queries.md: All 3 queries converted to single-line, added REST API reply section
- SKILL.md: Updated reply pattern to use REST API, added critical format requirements

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 14, 2026 15:35
Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Looks good to me! 👍

Reviewed everything up to 1f4ea18 in 8 seconds. Click for details.
  • Reviewed 258 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.

Workflow ID: wflow_zWdWcSagM7p4V6LS

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@gemini-code-assist
Copy link

Summary of Changes

Hello @JacobPEvans, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses recurring GraphQL errors in the /resolve-pr-threads skill by standardizing GraphQL query formats and updating the review comment reply mechanism. The changes eliminate issues caused by multi-line queries and variable handling, ensuring robust and reliable interaction with the GitHub API for managing pull request review threads.

Highlights

  • GraphQL Query Format Standardization: All GraphQL queries have been converted to a single-line format using --raw-field to prevent shell encoding and variable type coercion issues.
  • Placeholder Substitution: GraphQL variable declarations have been replaced with direct placeholder substitution (e.g., {OWNER}, {REPO}, {NUMBER}) for improved reliability.
  • Threaded Reply Mechanism: The method for replying to review comments has been updated to use the GitHub REST API, ensuring replies are correctly threaded and maintain conversation structure.
  • Critical Warnings Added: New critical warning sections have been added to documentation files, emphasizing the strict requirement for single-line GraphQL queries.
  • Documentation Enhancement: Comprehensive documentation for placeholder substitution and the new REST API reply pattern has been included.
Changelog
  • github-workflows/skills/resolve-pr-threads/SKILL.md
    • Added a critical warning section detailing GraphQL query format requirements.
    • Updated Step 6 to use the GitHub REST API for posting threaded replies, replacing the previous GraphQL mutation.
  • github-workflows/skills/resolve-pr-threads/graphql-queries.md
    • Introduced a critical warning section enforcing single-line GraphQL query format.
    • Converted the 'Fetch Unresolved Threads' GraphQL query to a single-line format with placeholder substitution.
    • Converted the 'Resolve Thread Mutation' GraphQL query to a single-line format with placeholder substitution.
    • Converted the 'Verify Zero Unresolved' GraphQL query to a single-line format with placeholder substitution.
    • Added a new section documenting the REST API pattern for replying to review threads, including placeholder examples.
    • Enhanced documentation for placeholder substitution across all GraphQL queries.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request successfully converts GraphQL queries to a single-line format and introduces the use of the REST API for threaded replies, addressing previous issues with multi-line queries and variable handling. The documentation has been updated with critical warnings and clear examples for placeholder substitution. The changes improve the robustness and reliability of the resolve-pr-threads skill.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes recurring GraphQL errors in the /resolve-pr-threads skill by converting all GraphQL queries from multi-line format with variable declarations to single-line format with placeholder substitution, and replacing the GraphQL mutation for replies with a REST API pattern.

Changes:

  • Converted all GraphQL queries to single-line --raw-field format with placeholder substitution ({OWNER}, {REPO}, {NUMBER}, {THREAD_ID})
  • Added REST API pattern for replying to review threads using gh api repos/{owner}/{repo}/pulls/{number}/comments/{comment_id}/replies
  • Added critical warnings and comprehensive documentation about single-line format requirements

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
github-workflows/skills/resolve-pr-threads/graphql-queries.md Converted all 3 GraphQL queries to single-line format; added REST API reply section; added critical warnings and placeholder substitution examples
github-workflows/skills/resolve-pr-threads/SKILL.md Added critical warning section about GraphQL format requirements; updated Step 6 to use REST API for replies with detailed substeps

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

JacobPEvans and others added 2 commits February 14, 2026 13:11
Critical fix to prevent "Expected VALUE, actual: RPAREN" errors.

Root cause: GraphQL queries were being executed with empty or unset
variables (e.g., `pullRequest(number: )` instead of `pullRequest(number: 35)`).

Changes:
- Add REQUIRED variable validation before every GraphQL query
- Add clear error messages for missing repo context
- Update all placeholder substitution examples with validation steps
- Add validation to SKILL.md Step 1 (fetch threads)
- Add validation examples to all graphql-queries.md patterns

This prevents agents from wasting tokens on GraphQL parsing errors
by catching missing variables before execution.

Example validation pattern (now required):
```bash
OWNER=$(gh repo view --json owner --jq .owner.login)
REPO=$(gh repo view --json name --jq .name)
NUMBER=$(gh pr view --json number --jq .number)
[[ -z "$OWNER" || -z "$REPO" || -z "$NUMBER" ]] && { echo "Error: Missing repo context"; exit 1; }
```

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Changed from STRICT (fail if not set) to SMART (infer from context).

Before: Required OWNER/REPO/NUMBER to be set, exited with error if missing
After: Automatically infers from current git/PR context when not provided

Pattern:
```bash
# Smart inference - tries current context first
OWNER=${OWNER:-$(gh repo view --json owner --jq -r '.owner.login' 2>/dev/null)}
REPO=${REPO:-$(gh repo view --json name --jq -r '.name' 2>/dev/null)}
NUMBER=${NUMBER:-$(gh pr view --json number --jq -r '.number' 2>/dev/null)}

# Only error if ALL inference methods fail AND about to execute
[[ -z "$OWNER" || -z "$REPO" || -z "$NUMBER" ]] && { echo "Error: Could not infer context"; exit 1; }
```

Benefits:
- Works without arguments when run from git repo/PR branch
- Still accepts explicit arguments: OWNER=x REPO=y NUMBER=z
- Only errors when truly unable to determine context
- Makes skill smart, not strict

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@JacobPEvans JacobPEvans merged commit 0b482c5 into main Feb 14, 2026
5 checks passed
@JacobPEvans JacobPEvans deleted the fix/graphql-single-line branch February 14, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant