Open History to see the last commit
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 }
27}
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
41}
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.
46#
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.
49#
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.
53#
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(
57 $owner: String!
58 $name: String!
59 $number: Int!
60 $after: String
61 $requestedReviewers: Int!
62) {
63 viewer {
64 login
65 }
66 repository(owner: $owner, name: $name) {
67 pullRequest(number: $number) {
68 reviewThreads(first: 100, after: $after) {
69 totalCount
70 pageInfo {
71 hasNextPage
72 endCursor
73 }
74 nodes {
75 id
76 isResolved
77 isOutdated
78 path
79 # Null once the thread's line has left the diff, which `isOutdated` reports.
80 line
81 diffSide
82 # Only ten comments ride with each thread. A hundred threads times a hundred comments
83 # made GitHub reserve 10,000 nested rows and charge 104 points; unfinished threads are
84 # paged from their own cursor by `ReviewThreadComments`.
85 comments(first: 10) {
86 totalCount
87 pageInfo {
88 hasNextPage
89 endCursor
90 }
91 nodes {
92 ...ThreadComment
93 }
94 }
95 }
96 }
97 viewerCanUpdate
98 viewerDidAuthor
99 author {
100 __typename
101 login
102 avatarUrl
103 }
104 ...Reactions
105 comments(first: 100) {
106 nodes {
107 id
108 lastEditedAt
109 author {
110 __typename
111 login
112 avatarUrl
113 }
114 ...Reactions
115 }
116 }
117 # For their reactions and edit times: the words and the verdict arrive with the activity read.
118 reviews(first: 100) {
119 nodes {
120 id
121 lastEditedAt
122 author {
123 __typename
124 login
125 avatarUrl
126 }
127 ...Reactions
128 }
129 }
130 reviewRequests(first: $requestedReviewers) {
131 nodes {
132 # Null for nobody. A team goes by its `org/slug`; a mannequin answers with neither and
133 # names nobody to show. A team's name and avatar are aliased apart from a person's,
134 # since their nullability differs.
135 requestedReviewer {
136 ... on User {
137 login
138 name
139 avatarUrl
140 }
141 ... on Bot {
142 login
143 avatarUrl
144 }
145 ... on Team {
146 combinedSlug
147 teamName: name
148 teamAvatarUrl: avatarUrl
149 }
150 }
151 }
152 }
153 latestReviews(first: 50) {
154 nodes {
155 state
156 author {
157 __typename
158 login
159 avatarUrl
160 }
161 }
162 }
163 reviewDismissals: timelineItems(itemTypes: [REVIEW_DISMISSED_EVENT], first: 100) {
164 pageInfo {
165 hasNextPage
166 endCursor
167 }
168 nodes {
169 ... on ReviewDismissedEvent {
170 dismissalMessage
171 review {
172 id
173 }
174 }
175 }
176 }
177 # `last` rather than `first`: a pull request with more than a hundred commits keeps the
178 # newest ones, which is what a reader scoping a diff wants.
179 commits(last: 100) {
180 nodes {
181 commit {
182 oid
183 messageHeadline
184 committedDate
185 additions
186 deletions
187 parents(first: 1) {
188 totalCount
189 }
190 authors(first: 3) {
191 nodes {
192 name
193 avatarUrl
194 user {
195 login
196 }
197 }
198 }
199 }
200 }
201 }
202 }
203 }
204}
205
206# The rest of one thread's conversation. GraphQL pages a connection nested inside another only
207# from the inner node itself, so a thread longer than a page is followed on its own: a request
208# GitHub makes necessary, and one no ordinary pull request ever provokes.
209query ReviewThreadComments(
210 $owner: String!
211 $name: String!
212 $number: Int!
213 $threadId: ID!
214 $after: String
215) {
216 viewer {
217 login
218 }
219 repository(owner: $owner, name: $name) {
220 pullRequest(number: $number) {
221 id
222 }
223 }
224 node(id: $threadId) {
225 ... on PullRequestReviewThread {
226 pullRequest {
227 id
228 }
229 comments(first: 100, after: $after) {
230 pageInfo {
231 hasNextPage
232 endCursor
233 }
234 nodes {
235 ...ThreadComment
236 }
237 }
238 }
239 }
240}
241
242# The dismissal events past the page the thread read carries. A pull request rarely has any: this
243# is followed only while the embedded page reports more.
244query ReviewDismissals($owner: String!, $name: String!, $number: Int!, $after: String) {
245 repository(owner: $owner, name: $name) {
246 pullRequest(number: $number) {
247 timelineItems(itemTypes: [REVIEW_DISMISSED_EVENT], first: 100, after: $after) {
248 pageInfo {
249 hasNextPage
250 endCursor
251 }
252 nodes {
253 ... on ReviewDismissedEvent {
254 dismissalMessage
255 review {
256 id
257 }
258 }
259 }
260 }
261 }
262 }
263}