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

pullRequestReads.graphql

536 lines12.8 KB

1# Reads of one pull request, or of the repository it belongs to.
2​
3# Resolves a listing's authors to avatars, which no listing field carries.
4query ActorAvatars($ids: [ID!]!) {
5 nodes(ids: $ids) {
6 ... on User {
7 login
8 avatarUrl
9 }
10 ... on Bot {
11 login
12 avatarUrl
13 }
14 }
16​
17# A check context of the head commit. `isRequired` is asked for on github.com only (`$required`):
18# an older Enterprise server may not know it, and an unknown field fails the whole read.
19fragment CheckContext on StatusCheckRollupContext {
20 ... on StatusContext {
21 context
22 state
23 targetUrl
24 createdAt
25 description
26 isRequired(pullRequestNumber: $number) @include(if: $required)
27 }
28 ... on CheckRun {
29 name
30 status
31 conclusion
32 startedAt
33 completedAt
34 detailsUrl
35 isRequired(pullRequestNumber: $number) @include(if: $required)
36 checkSuite {
37 workflowRun {
38 workflow {
39 name
40 }
41 }
42 }
43 }
45​
46# The detail of a pull request with the viewer's standing on it. Pull refs let the comparison
47# (`$headRef` is `refs/pull/<number>/head`) share this read without first resolving a fork branch.
48query PullRequestCore(
49 $owner: String!
50 $name: String!
51 $number: Int!
52 $headRef: String!
53 $required: Boolean!
54 $requestedReviewers: Int!
55) {
56 repository(owner: $owner, name: $name) {
57 mergeCommitAllowed
58 squashMergeAllowed
59 rebaseMergeAllowed
60 autoMergeAllowed
61 viewerPermission
62 pullRequest(number: $number) {
63 number
64 title
65 url
66 body
67 state
68 isDraft
69 mergeable
70 mergeStateStatus
71 reviewDecision
72 additions
73 deletions
74 changedFiles
75 createdAt
76 updatedAt
77 mergedAt
78 closedAt
79 headRefName
80 baseRefName
81 headRefOid
82 isCrossRepository
83 headRepositoryOwner {
84 login
85 }
86 # The source branch's own repository and ref, which is what deleting the branch needs: write
87 # there, and a branch still to delete.
88 headRepository {
89 nameWithOwner
90 viewerPermission
91 }
92 headRef {
93 id
94 }
95 author {
96 login
97 avatarUrl
98 ... on User {
99 id
100 name
101 }
102 }
103 autoMergeRequest {
104 mergeMethod
105 }
106 viewerCanUpdate
107 viewerDidAuthor
108 viewerCanUpdateBranch
109 baseRef {
110 compare(headRef: $headRef) {
111 behindBy
112 }
113 }
114 reviewRequests(first: $requestedReviewers) {
115 nodes {
116 requestedReviewer {
117 ... on User {
118 login
119 name
120 }
121 ... on Bot {
122 login
123 }
124 # A team's name and avatar are nullable differently from a person's, so they travel
125 # under their own aliases. `combinedSlug` is the `org/slug` a reviewer row shows.
126 ... on Team {
127 slug
128 combinedSlug
129 teamName: name
130 teamAvatarUrl: avatarUrl
131 }
132 }
133 }
134 }
135 labels(first: 100) {
136 nodes {
137 name
138 color
139 }
140 }
141 commits(last: 1) {
142 nodes {
143 commit {
144 statusCheckRollup {
145 contexts(first: 100) {
146 nodes {
147 ...CheckContext
148 }
149 pageInfo {
150 hasNextPage
151 }
152 }
153 }
154 }
155 }
156 }
157 }
158 }
160​
161# Every check context of the head commit, a page at a time, for a rollup past one page.
162query PullRequestCheckContexts(
163 $owner: String!
164 $name: String!
165 $number: Int!
166 $required: Boolean!
167 $after: String
168) {
169 repository(owner: $owner, name: $name) {
170 pullRequest(number: $number) {
171 headRefOid
172 commits(last: 1) {
173 nodes {
174 commit {
175 statusCheckRollup {
176 contexts(first: 100, after: $after) {
177 nodes {
178 ...CheckContext
179 }
180 pageInfo {
181 hasNextPage
182 endCursor
183 }
184 }
185 }
186 }
187 }
188 }
189 }
190 }
192​
193query PullRequestPreview($owner: String!, $name: String!, $number: Int!) {
194 repository(owner: $owner, name: $name) {
195 pullRequest(number: $number) {
196 number
197 title
198 url
199 state
200 isDraft
201 createdAt
202 author {
203 login
204 avatarUrl
205 ... on User {
206 name
207 }
208 }
209 }
210 }
212​
213# The conversation a pull request carries outside its review threads: who opened it, its issue
214# comments, its reviews and its newest commits. The two remark connections page independently, so
215# each is switched on only while it has more to give; the first read (`$head`) asks for everything.
216query PullRequestActivity(
217 $owner: String!
218 $name: String!
219 $number: Int!
220 $head: Boolean!
221 $withComments: Boolean!
222 $commentsAfter: String
223 $withReviews: Boolean!
224 $reviewsAfter: String
225) {
226 repository(owner: $owner, name: $name) {
227 pullRequest(number: $number) {
228 author @include(if: $head) {
229 login
230 avatarUrl
231 ... on User {
232 name
233 }
234 }
235 commits(last: 100) @include(if: $head) {
236 nodes {
237 commit {
238 oid
239 messageHeadline
240 committedDate
241 authors(first: 10) {
242 nodes {
243 name
244 email
245 user {
246 login
247 }
248 }
249 }
250 }
251 }
252 }
253 comments(first: 100, after: $commentsAfter) @include(if: $withComments) {
254 pageInfo {
255 hasNextPage
256 endCursor
257 }
258 nodes {
259 id
260 body
261 createdAt
262 lastEditedAt
263 url
264 author {
265 login
266 avatarUrl
267 ... on User {
268 name
269 }
270 }
271 }
272 }
273 reviews(first: 100, after: $reviewsAfter) @include(if: $withReviews) {
274 pageInfo {
275 hasNextPage
276 endCursor
277 }
278 nodes {
279 id
280 body
281 state
282 submittedAt
283 lastEditedAt
284 url
285 author {
286 login
287 avatarUrl
288 ... on User {
289 name
290 }
291 }
292 }
293 }
294 }
295 }
297​
298# Open pull requests whose head branch has one name, from whichever repository it lives in.
299query PullRequestHeads($owner: String!, $name: String!, $head: String!, $after: String) {
300 repository(owner: $owner, name: $name) {
301 pullRequests(first: 100, after: $after, states: [OPEN], headRefName: $head) {
302 pageInfo {
303 hasNextPage
304 endCursor
305 }
306 nodes {
307 number
308 headRefOid
309 isCrossRepository
310 headRepositoryOwner {
311 login
312 }
313 }
314 }
315 }
317​
318# The pull request's own node id, which is what a mutation against the pull request itself is
319# addressed by. Read only when one is being written: the conversation carries an id for every
320# remark in it, and the pull request is the one subject nothing in it names.
321query PullRequestNodeId($owner: String!, $name: String!, $number: Int!) {
322 repository(owner: $owner, name: $name) {
323 pullRequest(number: $number) {
324 id
325 }
326 }
328​
329# Where a client-given subject actually hangs: the pull request itself, or the pull request an
330# issue comment, a review comment, or a review belongs to. Read before a mutation reaches it, so a
331# subject named for one pull request cannot write on another's behalf.
332query PullRequestSubject($owner: String!, $name: String!, $number: Int!, $subjectId: ID!) {
333 repository(owner: $owner, name: $name) {
334 pullRequest(number: $number) {
335 id
336 }
337 }
338 node(id: $subjectId) {
339 id
340 ... on IssueComment {
341 pullRequest {
342 id
343 }
344 }
345 # Aliased apart: an issue comment's pull request is nullable, the other two are not.
346 ... on PullRequestReviewComment {
347 reviewCommentPullRequest: pullRequest {
348 id
349 }
350 }
351 ... on PullRequestReview {
352 reviewPullRequest: pullRequest {
353 id
354 }
355 }
356 }
358​
359# Core detail and write checks share one read of permissions and merge settings.
360query ViewerPermissions($owner: String!, $name: String!, $number: Int!) {
361 repository(owner: $owner, name: $name) {
362 mergeCommitAllowed
363 squashMergeAllowed
364 rebaseMergeAllowed
365 autoMergeAllowed
366 viewerPermission
367 pullRequest(number: $number) {
368 viewerCanUpdate
369 viewerDidAuthor
370 headRepository {
371 viewerPermission
372 }
373 }
374 }
376​
377# Who a review may be asked of, and who it has already been asked of, in one read.
379# `assignableUsers` is the list GitHub's own reviewer picker is built from (everyone with access to
380# the repository) rather than `collaborators`, which the REST API refuses to anyone without push
381# access and which would therefore be empty for exactly the reader most likely to be looking.
383# Teams are asked for only where one has already been requested, so a request to a team can be
384# taken back. The teams a repository could newly be sent to live on the owning organization and
385# need `read:org`, which a repository-scoped token need not carry, and a query GitHub refuses
386# fails whole, taking the people down with the teams.
387query ReviewerCandidates($owner: String!, $name: String!, $number: Int!) {
388 repository(owner: $owner, name: $name) {
389 assignableUsers(first: 100) {
390 pageInfo {
391 hasNextPage
392 }
393 nodes {
394 login
395 name
396 avatarUrl
397 }
398 }
399 pullRequest(number: $number) {
400 author {
401 login
402 }
403 reviewRequests(first: 100) {
404 nodes {
405 requestedReviewer {
406 ... on User {
407 login
408 name
409 avatarUrl
410 }
411 # Aliased apart from a person's: their nullability differs.
412 ... on Team {
413 slug
414 combinedSlug
415 teamName: name
416 teamAvatarUrl: avatarUrl
417 }
418 ... on Bot {
419 login
420 avatarUrl
421 }
422 }
423 }
424 }
425 }
426 }
428​
429query LabelCandidates($owner: String!, $name: String!, $number: Int!) {
430 repository(owner: $owner, name: $name) {
431 labels(first: 100, orderBy: { field: NAME, direction: ASC }) {
432 pageInfo {
433 hasNextPage
434 }
435 nodes {
436 name
437 color
438 description
439 }
440 }
441 pullRequest(number: $number) {
442 labels(first: 100) {
443 nodes {
444 name
445 }
446 }
447 }
448 }
450​
451# Which files of a pull request the signed-in account has cleared. GraphQL only, since the REST
452# files endpoint the patch is read from carries no viewed state, so this is a second read rather
453# than a wider version of the first.
454query PullRequestFilesViewed($owner: String!, $name: String!, $number: Int!, $after: String) {
455 repository(owner: $owner, name: $name) {
456 pullRequest(number: $number) {
457 files(first: 100, after: $after) {
458 pageInfo {
459 hasNextPage
460 endCursor
461 }
462 nodes {
463 path
464 viewerViewedState
465 }
466 }
467 }
468 }
470​
471# What a merge that rewrites its message reads first: GitHub's own message for the method, and
472# whether a merge queue will choose its own instead.
473query PullRequestMergeMessage(
474 $owner: String!
475 $name: String!
476 $number: Int!
477 $method: PullRequestMergeMethod!
478) {
479 repository(owner: $owner, name: $name) {
480 pullRequest(number: $number) {
481 isMergeQueueEnabled
482 headRefOid
483 viewerMergeBodyText(mergeType: $method)
484 }
485 }
487​
488# What `gh pr merge` and `gh pr update-branch` read before they act.
489query PullRequestActionState($owner: String!, $name: String!, $number: Int!, $headRef: String!) {
490 repository(owner: $owner, name: $name) {
491 pullRequest(number: $number) {
492 id
493 headRefOid
494 isMergeQueueEnabled
495 mergeStateStatus
496 baseRef {
497 compare(headRef: $headRef) {
498 behindBy
499 }
500 }
501 }
502 }
504​
505# What deleting a closed or merged pull request's source branch reads first: the branch, the
506# commit it should still point at, and the repository it lives in.
507query PullRequestBranchToDelete($owner: String!, $name: String!, $number: Int!) {
508 repository(owner: $owner, name: $name) {
509 pullRequest(number: $number) {
510 state
511 headRefName
512 baseRefName
513 headRefOid
514 headRepository {
515 id
516 }
517 }
518 }
520​
521# The source branch as its own repository holds it now, beside that repository's default branch,
522# so a branch that moved on or is the default is never deleted.
523query PullRequestSourceBranch($repositoryId: ID!, $ref: String!) {
524 node(id: $repositoryId) {
525 ... on Repository {
526 defaultBranchRef {
527 name
528 }
529 ref(qualifiedName: $ref) {
530 target {
531 oid
532 }
533 }
534 }
535 }