Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

pullRequestReads.graphql

649 lines15.2 KB

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