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

pullRequestReviews.graphql

258 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(
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 authors(first: 3) {
186 nodes {
187 name
188 avatarUrl
189 user {
190 login
191 }
192 }
193 }
194 }
195 }
196 }
197 }
198 }
200​
201# The rest of one thread's conversation. GraphQL pages a connection nested inside another only
202# from the inner node itself, so a thread longer than a page is followed on its own: a request
203# GitHub makes necessary, and one no ordinary pull request ever provokes.
204query ReviewThreadComments(
205 $owner: String!
206 $name: String!
207 $number: Int!
208 $threadId: ID!
209 $after: String
210) {
211 viewer {
212 login
213 }
214 repository(owner: $owner, name: $name) {
215 pullRequest(number: $number) {
216 id
217 }
218 }
219 node(id: $threadId) {
220 ... on PullRequestReviewThread {
221 pullRequest {
222 id
223 }
224 comments(first: 100, after: $after) {
225 pageInfo {
226 hasNextPage
227 endCursor
228 }
229 nodes {
230 ...ThreadComment
231 }
232 }
233 }
234 }
236​
237# The dismissal events past the page the thread read carries. A pull request rarely has any: this
238# is followed only while the embedded page reports more.
239query ReviewDismissals($owner: String!, $name: String!, $number: Int!, $after: String) {
240 repository(owner: $owner, name: $name) {
241 pullRequest(number: $number) {
242 timelineItems(itemTypes: [REVIEW_DISMISSED_EVENT], first: 100, after: $after) {
243 pageInfo {
244 hasNextPage
245 endCursor
246 }
247 nodes {
248 ... on ReviewDismissedEvent {
249 dismissalMessage
250 review {
251 id
252 }
253 }
254 }
255 }
256 }
257 }