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

pullRequestReads.graphql

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