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

pullRequestReads.graphql

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