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

pullRequestReviews.graphql

257 lines6.5 KB

1# The review conversation: threads, their comments, and what the people on the review said.
2​
3# A reaction group as every reactable node reports it. `reactors` is bounded rather than paged: a
4# hover says who reacted, and a hundred and forty names is a count, not a sentence.
5fragment Reactions on Reactable {
6 reactionGroups {
7 content
8 viewerHasReacted
9 reactors(first: 10) {
10 totalCount
11 nodes {
12 ... on User {
13 login
14 }
15 ... on Bot {
16 login
17 }
18 ... on Organization {
19 login
20 }
21 ... on Mannequin {
22 login
23 }
24 }
25 }
26 }
28​
29fragment ThreadComment on PullRequestReviewComment {
30 id
31 author {
32 __typename
33 login
34 avatarUrl
35 }
36 body
37 createdAt
38 lastEditedAt
39 url
40 ...Reactions
42​
43# One page of review threads with their comments, and the people on the review. `$after` is null
44# for the first page and the last page's `endCursor` after that, so a pull request with more
45# threads than one page holds is walked rather than cut off.
47# `viewer` rides along: GitHub names who reacted but never says whether that is the reader, so the
48# comparison is made locally rather than paid for with a request of its own.
50# Reviewers come from here because `reviewRequests` holds only requests still outstanding, so
51# anyone who has already reviewed drops off it; `latestReviews` adds them back. A reviewer can be a
52# person or an app, and both are asked for by name because they are different GraphQL types.
54# `viewerCanUpdate` and `viewerDidAuthor` belong to the pull request this query is already
55# standing on, so what the reader may do with it arrives with the conversation.
56query ReviewThreads($owner: String!, $name: String!, $number: Int!, $after: String) {
57 viewer {
58 login
59 }
60 repository(owner: $owner, name: $name) {
61 pullRequest(number: $number) {
62 reviewThreads(first: 100, after: $after) {
63 totalCount
64 pageInfo {
65 hasNextPage
66 endCursor
67 }
68 nodes {
69 id
70 isResolved
71 isOutdated
72 path
73 # Null once the thread's line has left the diff, which `isOutdated` reports.
74 line
75 diffSide
76 # Only ten comments ride with each thread. A hundred threads times a hundred comments
77 # made GitHub reserve 10,000 nested rows and charge 104 points; unfinished threads are
78 # paged from their own cursor by `ReviewThreadComments`.
79 comments(first: 10) {
80 totalCount
81 pageInfo {
82 hasNextPage
83 endCursor
84 }
85 nodes {
86 ...ThreadComment
87 }
88 }
89 }
90 }
91 viewerCanUpdate
92 viewerDidAuthor
93 author {
94 __typename
95 login
96 avatarUrl
97 }
98 ...Reactions
99 comments(first: 100) {
100 nodes {
101 id
102 lastEditedAt
103 author {
104 __typename
105 login
106 avatarUrl
107 }
108 ...Reactions
109 }
110 }
111 # For their reactions and edit times: the words and the verdict arrive with the activity read.
112 reviews(first: 100) {
113 nodes {
114 id
115 lastEditedAt
116 author {
117 __typename
118 login
119 avatarUrl
120 }
121 ...Reactions
122 }
123 }
124 reviewRequests(first: 50) {
125 nodes {
126 # Null for nobody. A team goes by its `org/slug`; a mannequin answers with neither and
127 # names nobody to show. A team's name and avatar are aliased apart from a person's,
128 # since their nullability differs.
129 requestedReviewer {
130 ... on User {
131 login
132 name
133 avatarUrl
134 }
135 ... on Bot {
136 login
137 avatarUrl
138 }
139 ... on Team {
140 combinedSlug
141 teamName: name
142 teamAvatarUrl: avatarUrl
143 }
144 }
145 }
146 }
147 latestReviews(first: 50) {
148 nodes {
149 state
150 author {
151 __typename
152 login
153 avatarUrl
154 }
155 }
156 }
157 reviewDismissals: timelineItems(itemTypes: [REVIEW_DISMISSED_EVENT], first: 100) {
158 pageInfo {
159 hasNextPage
160 endCursor
161 }
162 nodes {
163 ... on ReviewDismissedEvent {
164 dismissalMessage
165 review {
166 id
167 }
168 }
169 }
170 }
171 # `last` rather than `first`: a pull request with more than a hundred commits keeps the
172 # newest ones, which is what a reader scoping a diff wants.
173 commits(last: 100) {
174 nodes {
175 commit {
176 oid
177 messageHeadline
178 committedDate
179 additions
180 deletions
181 parents(first: 1) {
182 totalCount
183 }
184 authors(first: 3) {
185 nodes {
186 name
187 avatarUrl
188 user {
189 login
190 }
191 }
192 }
193 }
194 }
195 }
196 }
197 }
199​
200# The rest of one thread's conversation. GraphQL pages a connection nested inside another only
201# from the inner node itself, so a thread longer than a page is followed on its own: a request
202# GitHub makes necessary, and one no ordinary pull request ever provokes.
203query ReviewThreadComments(
204 $owner: String!
205 $name: String!
206 $number: Int!
207 $threadId: ID!
208 $after: String
209) {
210 viewer {
211 login
212 }
213 repository(owner: $owner, name: $name) {
214 pullRequest(number: $number) {
215 id
216 }
217 }
218 node(id: $threadId) {
219 ... on PullRequestReviewThread {
220 pullRequest {
221 id
222 }
223 comments(first: 100, after: $after) {
224 pageInfo {
225 hasNextPage
226 endCursor
227 }
228 nodes {
229 ...ThreadComment
230 }
231 }
232 }
233 }
235​
236# The dismissal events past the page the thread read carries. A pull request rarely has any: this
237# is followed only while the embedded page reports more.
238query ReviewDismissals($owner: String!, $name: String!, $number: Int!, $after: String) {
239 repository(owner: $owner, name: $name) {
240 pullRequest(number: $number) {
241 timelineItems(itemTypes: [REVIEW_DISMISSED_EVENT], first: 100, after: $after) {
242 pageInfo {
243 hasNextPage
244 endCursor
245 }
246 nodes {
247 ... on ReviewDismissedEvent {
248 dismissalMessage
249 review {
250 id
251 }
252 }
253 }
254 }
255 }
256 }