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