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