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

pullRequestReviews.graphql

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