Fix graphql query

This commit is contained in:
Colin McDonnell
2025-12-15 21:42:43 -08:00
parent b038fc574f
commit 6f96458e2d
2 changed files with 13 additions and 11 deletions
+4 -4
View File
@@ -124854,6 +124854,8 @@ query ($owner: String!, $repo: String!, $pullNumber: Int!) {
pullRequest(number: $pullNumber) { pullRequest(number: $pullNumber) {
reviewThreads(first: 100) { reviewThreads(first: 100) {
nodes { nodes {
diffSide
startDiffSide
comments(first: 100) { comments(first: 100) {
nodes { nodes {
id id
@@ -124862,8 +124864,6 @@ query ($owner: String!, $repo: String!, $pullNumber: Int!) {
path path
line line
startLine startLine
diffSide
startSide
url url
author { author {
login login
@@ -124934,8 +124934,8 @@ var GetReviewCommentsTool = tool({
path: comment.path, path: comment.path,
line: comment.line, line: comment.line,
start_line: comment.startLine, start_line: comment.startLine,
side: comment.diffSide, side: thread.diffSide,
start_side: comment.startSide, start_side: thread.startDiffSide,
user: comment.author?.login ?? null, user: comment.author?.login ?? null,
created_at: comment.createdAt, created_at: comment.createdAt,
updated_at: comment.updatedAt, updated_at: comment.updatedAt,
+9 -7
View File
@@ -2,12 +2,15 @@ import { type } from "arktype";
import { contextualize, tool } from "./shared.ts"; import { contextualize, tool } from "./shared.ts";
// graphql query to fetch all review threads with comments and replies // graphql query to fetch all review threads with comments and replies
// note: diffSide and startDiffSide are on the thread, not the comment
const REVIEW_THREADS_QUERY = ` const REVIEW_THREADS_QUERY = `
query ($owner: String!, $repo: String!, $pullNumber: Int!) { query ($owner: String!, $repo: String!, $pullNumber: Int!) {
repository(owner: $owner, name: $repo) { repository(owner: $owner, name: $repo) {
pullRequest(number: $pullNumber) { pullRequest(number: $pullNumber) {
reviewThreads(first: 100) { reviewThreads(first: 100) {
nodes { nodes {
diffSide
startDiffSide
comments(first: 100) { comments(first: 100) {
nodes { nodes {
id id
@@ -16,8 +19,6 @@ query ($owner: String!, $repo: String!, $pullNumber: Int!) {
path path
line line
startLine startLine
diffSide
startSide
url url
author { author {
login login
@@ -47,8 +48,6 @@ type GraphQLReviewComment = {
path: string; path: string;
line: number | null; line: number | null;
startLine: number | null; startLine: number | null;
diffSide: "LEFT" | "RIGHT";
startSide: "LEFT" | "RIGHT" | null;
url: string; url: string;
author: { author: {
login: string; login: string;
@@ -64,10 +63,12 @@ type GraphQLReviewComment = {
}; };
type GraphQLReviewThread = { type GraphQLReviewThread = {
diffSide: "LEFT" | "RIGHT";
startDiffSide: "LEFT" | "RIGHT" | null;
comments: { comments: {
nodes: (GraphQLReviewComment | null)[] | null; nodes: (GraphQLReviewComment | null)[] | null;
} | null; } | null;
}; } | null;
type GraphQLResponse = { type GraphQLResponse = {
repository: { repository: {
@@ -152,6 +153,7 @@ export const GetReviewCommentsTool = tool({
if (!threadBelongsToReview) continue; if (!threadBelongsToReview) continue;
// include all comments from this thread (original + replies) // include all comments from this thread (original + replies)
// side info comes from thread level, not comment level
for (const comment of threadComments) { for (const comment of threadComments) {
allComments.push({ allComments.push({
id: comment.databaseId, id: comment.databaseId,
@@ -159,8 +161,8 @@ export const GetReviewCommentsTool = tool({
path: comment.path, path: comment.path,
line: comment.line, line: comment.line,
start_line: comment.startLine, start_line: comment.startLine,
side: comment.diffSide, side: thread.diffSide,
start_side: comment.startSide, start_side: thread.startDiffSide,
user: comment.author?.login ?? null, user: comment.author?.login ?? null,
created_at: comment.createdAt, created_at: comment.createdAt,
updated_at: comment.updatedAt, updated_at: comment.updatedAt,