The best way to control Claude Code, Codex and more from any computer or phone
| 1 | # Reads of the signed-in account, one pull request, or its repository. |
| 2 | |
| 3 | query RoutingIdentityViewer { |
| 4 | viewer { |
| 5 | databaseId |
| 6 | login |
| 7 | } |
| 8 | } |
| 9 | |
| 10 | # Resolves a listing's authors to avatars, which no listing field carries. |
| 11 | query ActorAvatars($ids: [ID!]!) { |
| 12 | nodes(ids: $ids) { |
| 13 | ... on User { |
| 14 | login |
| 15 | avatarUrl |
| 16 | } |
| 17 | ... on Bot { |
| 18 | login |
| 19 | avatarUrl |
| 20 | } |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | # A check context of the head commit. `isRequired` is asked for on github.com only (`$required`): |
| 25 | # an older Enterprise server may not know it, and an unknown field fails the whole read. |
| 26 | fragment CheckContext on StatusCheckRollupContext { |
| 27 | ... on StatusContext { |
| 28 | context |
| 29 | state |
| 30 | targetUrl |
| 31 | createdAt |
| 32 | description |
| 33 | isRequired(pullRequestNumber: $number) @include(if: $required) |
| 34 | } |
| 35 | ... on CheckRun { |
| 36 | name |
| 37 | status |
| 38 | conclusion |
| 39 | startedAt |
| 40 | completedAt |
| 41 | detailsUrl |
| 42 | isRequired(pullRequestNumber: $number) @include(if: $required) |
| 43 | checkSuite { |
| 44 | workflowRun { |
| 45 | workflow { |
| 46 | name |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | # The detail of a pull request with the viewer's standing on it. Pull refs let the comparison |
| 54 | # (`$headRef` is `refs/pull/<number>/head`) share this read without first resolving a fork branch. |
| 55 | query PullRequestCore( |
| 56 | $owner: String! |
| 57 | $name: String! |
| 58 | $number: Int! |
| 59 | $headRef: String! |
| 60 | $required: Boolean! |
| 61 | $requestedReviewers: Int! |
| 62 | $mergeQueue: Boolean! |
| 63 | ) { |
| 64 | repository(owner: $owner, name: $name) { |
| 65 | mergeCommitAllowed |
| 66 | squashMergeAllowed |
| 67 | rebaseMergeAllowed |
| 68 | autoMergeAllowed |
| 69 | viewerPermission |
| 70 | pullRequest(number: $number) { |
| 71 | number |
| 72 | title |
| 73 | url |
| 74 | body |
| 75 | state |
| 76 | isDraft |
| 77 | mergeable |
| 78 | mergeStateStatus |
| 79 | reviewDecision |
| 80 | additions |
| 81 | deletions |
| 82 | changedFiles |
| 83 | createdAt |
| 84 | updatedAt |
| 85 | mergedAt |
| 86 | mergeCommit { |
| 87 | oid |
| 88 | } |
| 89 | mergedBy { |
| 90 | login |
| 91 | avatarUrl |
| 92 | ... on User { |
| 93 | name |
| 94 | } |
| 95 | } |
| 96 | closedAt |
| 97 | headRefName |
| 98 | baseRefName |
| 99 | headRefOid |
| 100 | isCrossRepository |
| 101 | maintainerCanModify |
| 102 | headRepositoryOwner { |
| 103 | login |
| 104 | } |
| 105 | # The source branch's own repository and ref, which is what deleting the branch needs: write |
| 106 | # there, and a branch still to delete. |
| 107 | headRepository { |
| 108 | nameWithOwner |
| 109 | viewerPermission |
| 110 | } |
| 111 | headRef { |
| 112 | id |
| 113 | } |
| 114 | author { |
| 115 | login |
| 116 | avatarUrl |
| 117 | ... on User { |
| 118 | id |
| 119 | name |
| 120 | } |
| 121 | } |
| 122 | autoMergeRequest { |
| 123 | mergeMethod |
| 124 | } |
| 125 | # Merge queue checks run on a commit of the queue's own, so a pull request the queue drops |
| 126 | # can keep a green head. Only this event says it left without merging. |
| 127 | mergeQueueRemovals: timelineItems(last: 1, itemTypes: [REMOVED_FROM_MERGE_QUEUE_EVENT]) |
| 128 | @include(if: $mergeQueue) { |
| 129 | nodes { |
| 130 | ... on RemovedFromMergeQueueEvent { |
| 131 | id |
| 132 | createdAt |
| 133 | reason |
| 134 | } |
| 135 | } |
| 136 | } |
| 137 | viewerCanUpdate |
| 138 | viewerDidAuthor |
| 139 | viewerCanUpdateBranch |
| 140 | baseRef { |
| 141 | compare(headRef: $headRef) { |
| 142 | behindBy |
| 143 | } |
| 144 | } |
| 145 | reviewRequests(first: $requestedReviewers) { |
| 146 | nodes { |
| 147 | requestedReviewer { |
| 148 | ... on User { |
| 149 | login |
| 150 | name |
| 151 | } |
| 152 | ... on Bot { |
| 153 | login |
| 154 | } |
| 155 | # A team's name and avatar are nullable differently from a person's, so they travel |
| 156 | # under their own aliases. `combinedSlug` is the `org/slug` a reviewer row shows. |
| 157 | ... on Team { |
| 158 | slug |
| 159 | combinedSlug |
| 160 | teamName: name |
| 161 | teamAvatarUrl: avatarUrl |
| 162 | } |
| 163 | } |
| 164 | } |
| 165 | } |
| 166 | labels(first: 100) { |
| 167 | nodes { |
| 168 | name |
| 169 | color |
| 170 | description |
| 171 | } |
| 172 | } |
| 173 | commits(last: 1) { |
| 174 | nodes { |
| 175 | commit { |
| 176 | statusCheckRollup { |
| 177 | contexts(first: 100) { |
| 178 | nodes { |
| 179 | ...CheckContext |
| 180 | } |
| 181 | pageInfo { |
| 182 | hasNextPage |
| 183 | endCursor |
| 184 | } |
| 185 | } |
| 186 | } |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | } |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | # Every check context of the head commit, a page at a time, for a rollup past one page. |
| 195 | query PullRequestCheckContexts( |
| 196 | $owner: String! |
| 197 | $name: String! |
| 198 | $number: Int! |
| 199 | $required: Boolean! |
| 200 | $after: String |
| 201 | ) { |
| 202 | repository(owner: $owner, name: $name) { |
| 203 | pullRequest(number: $number) { |
| 204 | headRefOid |
| 205 | commits(last: 1) { |
| 206 | nodes { |
| 207 | commit { |
| 208 | statusCheckRollup { |
| 209 | contexts(first: 100, after: $after) { |
| 210 | nodes { |
| 211 | ...CheckContext |
| 212 | } |
| 213 | pageInfo { |
| 214 | hasNextPage |
| 215 | endCursor |
| 216 | } |
| 217 | } |
| 218 | } |
| 219 | } |
| 220 | } |
| 221 | } |
| 222 | } |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | query PullRequestPreview($owner: String!, $name: String!, $number: Int!) { |
| 227 | repository(owner: $owner, name: $name) { |
| 228 | pullRequest(number: $number) { |
| 229 | number |
| 230 | title |
| 231 | url |
| 232 | state |
| 233 | isDraft |
| 234 | createdAt |
| 235 | author { |
| 236 | login |
| 237 | avatarUrl |
| 238 | ... on User { |
| 239 | name |
| 240 | } |
| 241 | } |
| 242 | } |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | # The conversation a pull request carries outside its review threads: who opened it, its issue |
| 247 | # comments, its reviews and its newest commits. The two remark connections page independently, so |
| 248 | # each is switched on only while it has more to give; the first read (`$head`) asks for everything. |
| 249 | query PullRequestActivity( |
| 250 | $owner: String! |
| 251 | $name: String! |
| 252 | $number: Int! |
| 253 | $head: Boolean! |
| 254 | $withComments: Boolean! |
| 255 | $commentsAfter: String |
| 256 | $withReviews: Boolean! |
| 257 | $reviewsAfter: String |
| 258 | ) { |
| 259 | repository(owner: $owner, name: $name) { |
| 260 | pullRequest(number: $number) { |
| 261 | author @include(if: $head) { |
| 262 | login |
| 263 | avatarUrl |
| 264 | ... on User { |
| 265 | name |
| 266 | } |
| 267 | } |
| 268 | commits(last: 100) @include(if: $head) { |
| 269 | nodes { |
| 270 | commit { |
| 271 | id |
| 272 | oid |
| 273 | messageHeadline |
| 274 | committedDate |
| 275 | parents(first: 1) { |
| 276 | totalCount |
| 277 | } |
| 278 | authors(first: 10) { |
| 279 | nodes { |
| 280 | name |
| 281 | |
| 282 | user { |
| 283 | login |
| 284 | } |
| 285 | } |
| 286 | } |
| 287 | } |
| 288 | } |
| 289 | } |
| 290 | comments(first: 100, after: $commentsAfter) @include(if: $withComments) { |
| 291 | pageInfo { |
| 292 | hasNextPage |
| 293 | endCursor |
| 294 | } |
| 295 | nodes { |
| 296 | id |
| 297 | body |
| 298 | createdAt |
| 299 | lastEditedAt |
| 300 | url |
| 301 | isMinimized |
| 302 | author { |
| 303 | login |
| 304 | avatarUrl |
| 305 | ... on User { |
| 306 | name |
| 307 | } |
| 308 | } |
| 309 | } |
| 310 | } |
| 311 | reviews(first: 100, after: $reviewsAfter) @include(if: $withReviews) { |
| 312 | pageInfo { |
| 313 | hasNextPage |
| 314 | endCursor |
| 315 | } |
| 316 | nodes { |
| 317 | id |
| 318 | body |
| 319 | state |
| 320 | submittedAt |
| 321 | lastEditedAt |
| 322 | url |
| 323 | isMinimized |
| 324 | author { |
| 325 | login |
| 326 | avatarUrl |
| 327 | ... on User { |
| 328 | name |
| 329 | } |
| 330 | } |
| 331 | } |
| 332 | } |
| 333 | } |
| 334 | } |
| 335 | } |
| 336 | |
| 337 | # Merge commits include upstream changes in their stats, which the timeline does not display. |
| 338 | # Read only the non-merge commits named by the activity connection. |
| 339 | query PullRequestCommitStats($ids: [ID!]!) { |
| 340 | nodes(ids: $ids) { |
| 341 | ... on Commit { |
| 342 | oid |
| 343 | additions |
| 344 | deletions |
| 345 | } |
| 346 | } |
| 347 | } |
| 348 | |
| 349 | # Open pull requests whose head branch has one name, from whichever repository it lives in. |
| 350 | query PullRequestHeads($owner: String!, $name: String!, $head: String!, $after: String) { |
| 351 | repository(owner: $owner, name: $name) { |
| 352 | pullRequests(first: 100, after: $after, states: [OPEN], headRefName: $head) { |
| 353 | pageInfo { |
| 354 | hasNextPage |
| 355 | endCursor |
| 356 | } |
| 357 | nodes { |
| 358 | number |
| 359 | headRefOid |
| 360 | isCrossRepository |
| 361 | headRepositoryOwner { |
| 362 | login |
| 363 | } |
| 364 | } |
| 365 | } |
| 366 | } |
| 367 | } |
| 368 | |
| 369 | # The pull request's own node id, which is what a mutation against the pull request itself is |
| 370 | # addressed by. Read only when one is being written: the conversation carries an id for every |
| 371 | # remark in it, and the pull request is the one subject nothing in it names. |
| 372 | query PullRequestNodeId($owner: String!, $name: String!, $number: Int!) { |
| 373 | repository(owner: $owner, name: $name) { |
| 374 | pullRequest(number: $number) { |
| 375 | id |
| 376 | } |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | # Where a client-given subject actually hangs: the pull request itself, or the pull request an |
| 381 | # issue comment, a review comment, or a review belongs to. Read before a mutation reaches it, so a |
| 382 | # subject named for one pull request cannot write on another's behalf. |
| 383 | query PullRequestSubject($owner: String!, $name: String!, $number: Int!, $subjectId: ID!) { |
| 384 | repository(owner: $owner, name: $name) { |
| 385 | pullRequest(number: $number) { |
| 386 | id |
| 387 | } |
| 388 | } |
| 389 | node(id: $subjectId) { |
| 390 | id |
| 391 | ... on IssueComment { |
| 392 | pullRequest { |
| 393 | id |
| 394 | } |
| 395 | } |
| 396 | # Aliased apart: an issue comment's pull request is nullable, the other two are not. |
| 397 | ... on PullRequestReviewComment { |
| 398 | reviewCommentPullRequest: pullRequest { |
| 399 | id |
| 400 | } |
| 401 | } |
| 402 | ... on PullRequestReview { |
| 403 | reviewPullRequest: pullRequest { |
| 404 | id |
| 405 | } |
| 406 | } |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | # Core detail and write checks share one read of permissions and merge settings. |
| 411 | query ViewerPermissions($owner: String!, $name: String!, $number: Int!) { |
| 412 | repository(owner: $owner, name: $name) { |
| 413 | mergeCommitAllowed |
| 414 | squashMergeAllowed |
| 415 | rebaseMergeAllowed |
| 416 | autoMergeAllowed |
| 417 | viewerPermission |
| 418 | pullRequest(number: $number) { |
| 419 | viewerCanUpdate |
| 420 | viewerDidAuthor |
| 421 | headRepository { |
| 422 | viewerPermission |
| 423 | } |
| 424 | } |
| 425 | } |
| 426 | } |
| 427 | |
| 428 | # Who a review may be asked of, and who it has already been asked of, in one read. |
| 429 | # |
| 430 | # `assignableUsers` is the list GitHub's own reviewer picker is built from (everyone with access to |
| 431 | # the repository) rather than `collaborators`, which the REST API refuses to anyone without push |
| 432 | # access and which would therefore be empty for exactly the reader most likely to be looking. |
| 433 | # |
| 434 | # Teams are asked for only where one has already been requested, so a request to a team can be |
| 435 | # taken back. The teams a repository could newly be sent to live on the owning organization and |
| 436 | # need `read:org`, which a repository-scoped token need not carry, and a query GitHub refuses |
| 437 | # fails whole, taking the people down with the teams. |
| 438 | query ReviewerCandidates($owner: String!, $name: String!, $number: Int!, $query: String) { |
| 439 | repository(owner: $owner, name: $name) { |
| 440 | assignableUsers(first: 100, query: $query) { |
| 441 | pageInfo { |
| 442 | hasNextPage |
| 443 | } |
| 444 | nodes { |
| 445 | login |
| 446 | name |
| 447 | avatarUrl |
| 448 | } |
| 449 | } |
| 450 | pullRequest(number: $number) { |
| 451 | author { |
| 452 | login |
| 453 | } |
| 454 | reviewRequests(first: 100) { |
| 455 | nodes { |
| 456 | requestedReviewer { |
| 457 | ... on User { |
| 458 | login |
| 459 | name |
| 460 | avatarUrl |
| 461 | } |
| 462 | # Aliased apart from a person's: their nullability differs. |
| 463 | ... on Team { |
| 464 | slug |
| 465 | combinedSlug |
| 466 | teamName: name |
| 467 | teamAvatarUrl: avatarUrl |
| 468 | } |
| 469 | ... on Bot { |
| 470 | login |
| 471 | avatarUrl |
| 472 | } |
| 473 | } |
| 474 | } |
| 475 | } |
| 476 | } |
| 477 | } |
| 478 | } |
| 479 | |
| 480 | query LabelCandidates($owner: String!, $name: String!, $number: Int!) { |
| 481 | repository(owner: $owner, name: $name) { |
| 482 | labels(first: 100, orderBy: { field: NAME, direction: ASC }) { |
| 483 | pageInfo { |
| 484 | hasNextPage |
| 485 | } |
| 486 | nodes { |
| 487 | name |
| 488 | color |
| 489 | description |
| 490 | } |
| 491 | } |
| 492 | pullRequest(number: $number) { |
| 493 | labels(first: 100) { |
| 494 | nodes { |
| 495 | name |
| 496 | } |
| 497 | } |
| 498 | } |
| 499 | } |
| 500 | } |
| 501 | |
| 502 | query RepositoryLabels($owner: String!, $name: String!, $query: String) { |
| 503 | repository(owner: $owner, name: $name) { |
| 504 | labels(first: 100, query: $query, orderBy: { field: NAME, direction: ASC }) { |
| 505 | pageInfo { |
| 506 | hasNextPage |
| 507 | } |
| 508 | nodes { |
| 509 | name |
| 510 | color |
| 511 | } |
| 512 | } |
| 513 | } |
| 514 | } |
| 515 | |
| 516 | fragment ReferenceCandidate on IssueOrPullRequest { |
| 517 | __typename |
| 518 | ... on Issue { |
| 519 | number |
| 520 | title |
| 521 | issueState: state |
| 522 | } |
| 523 | ... on PullRequest { |
| 524 | number |
| 525 | title |
| 526 | pullRequestState: state |
| 527 | } |
| 528 | } |
| 529 | |
| 530 | # `search` cannot match a number, so a numeric query also looks the number up directly. |
| 531 | query RepositoryReferences( |
| 532 | $owner: String! |
| 533 | $name: String! |
| 534 | $q: String! |
| 535 | $number: Int! |
| 536 | $exact: Boolean! |
| 537 | ) { |
| 538 | search(query: $q, type: ISSUE, first: 20) { |
| 539 | pageInfo { |
| 540 | hasNextPage |
| 541 | } |
| 542 | nodes { |
| 543 | ...ReferenceCandidate |
| 544 | } |
| 545 | } |
| 546 | repository(owner: $owner, name: $name) @include(if: $exact) { |
| 547 | issueOrPullRequest(number: $number) { |
| 548 | ...ReferenceCandidate |
| 549 | } |
| 550 | } |
| 551 | } |
| 552 | |
| 553 | # Mentionable rather than assignable users: a pull request from a fork is opened by someone with |
| 554 | # no access to the repository, and a listing is still narrowed by them. |
| 555 | query RepositoryAuthors($owner: String!, $name: String!, $query: String) { |
| 556 | repository(owner: $owner, name: $name) { |
| 557 | mentionableUsers(first: 50, query: $query) { |
| 558 | pageInfo { |
| 559 | hasNextPage |
| 560 | } |
| 561 | nodes { |
| 562 | login |
| 563 | name |
| 564 | avatarUrl |
| 565 | } |
| 566 | } |
| 567 | } |
| 568 | } |
| 569 | |
| 570 | # Which files of a pull request the signed-in account has cleared. GraphQL only, since the REST |
| 571 | # files endpoint the patch is read from carries no viewed state, so this is a second read rather |
| 572 | # than a wider version of the first. |
| 573 | query PullRequestFilesViewed($owner: String!, $name: String!, $number: Int!, $after: String) { |
| 574 | repository(owner: $owner, name: $name) { |
| 575 | pullRequest(number: $number) { |
| 576 | files(first: 100, after: $after) { |
| 577 | pageInfo { |
| 578 | hasNextPage |
| 579 | endCursor |
| 580 | } |
| 581 | nodes { |
| 582 | path |
| 583 | viewerViewedState |
| 584 | } |
| 585 | } |
| 586 | } |
| 587 | } |
| 588 | } |
| 589 | |
| 590 | query PullRequestFileStats($owner: String!, $name: String!, $number: Int!, $after: String) { |
| 591 | repository(owner: $owner, name: $name) { |
| 592 | pullRequest(number: $number) { |
| 593 | files(first: 100, after: $after) { |
| 594 | pageInfo { |
| 595 | hasNextPage |
| 596 | endCursor |
| 597 | } |
| 598 | nodes { |
| 599 | path |
| 600 | additions |
| 601 | deletions |
| 602 | } |
| 603 | } |
| 604 | } |
| 605 | } |
| 606 | } |
| 607 | |
| 608 | # What a merge that rewrites its message reads first: GitHub's own message for the method, and |
| 609 | # whether a merge queue will choose its own instead. |
| 610 | query PullRequestMergeMessage( |
| 611 | $owner: String! |
| 612 | $name: String! |
| 613 | $number: Int! |
| 614 | $method: PullRequestMergeMethod! |
| 615 | ) { |
| 616 | repository(owner: $owner, name: $name) { |
| 617 | pullRequest(number: $number) { |
| 618 | isMergeQueueEnabled |
| 619 | headRefOid |
| 620 | viewerMergeBodyText(mergeType: $method) |
| 621 | } |
| 622 | } |
| 623 | } |
| 624 | |
| 625 | # What `gh pr merge` and `gh pr update-branch` read before they act. |
| 626 | query PullRequestActionState($owner: String!, $name: String!, $number: Int!, $headRef: String!) { |
| 627 | repository(owner: $owner, name: $name) { |
| 628 | pullRequest(number: $number) { |
| 629 | id |
| 630 | headRefOid |
| 631 | isMergeQueueEnabled |
| 632 | mergeStateStatus |
| 633 | baseRef { |
| 634 | compare(headRef: $headRef) { |
| 635 | behindBy |
| 636 | } |
| 637 | } |
| 638 | } |
| 639 | } |
| 640 | } |
| 641 | |
| 642 | # What deleting a closed or merged pull request's source branch reads first: the branch, the |
| 643 | # commit it should still point at, and the repository it lives in. |
| 644 | query PullRequestBranchToDelete($owner: String!, $name: String!, $number: Int!) { |
| 645 | repository(owner: $owner, name: $name) { |
| 646 | pullRequest(number: $number) { |
| 647 | state |
| 648 | headRefName |
| 649 | baseRefName |
| 650 | headRefOid |
| 651 | headRepository { |
| 652 | id |
| 653 | } |
| 654 | } |
| 655 | } |
| 656 | } |
| 657 | |
| 658 | # The source branch as its own repository holds it now, beside that repository's default branch, |
| 659 | # so a branch that moved on or is the default is never deleted. |
| 660 | query PullRequestSourceBranch($repositoryId: ID!, $ref: String!) { |
| 661 | node(id: $repositoryId) { |
| 662 | ... on Repository { |
| 663 | defaultBranchRef { |
| 664 | name |
| 665 | } |
| 666 | ref(qualifiedName: $ref) { |
| 667 | target { |
| 668 | oid |
| 669 | } |
| 670 | } |
| 671 | } |
| 672 | } |
| 673 | } |