( commentsSchema: PrCommentsSchema, prNumber: number, git: AuthenticatedGitClient, )
| 176 | |
| 177 | /** Get all files in a PR from github */ |
| 178 | export async function getPrComments<PrCommentsSchema>( |
| 179 | commentsSchema: PrCommentsSchema, |
| 180 | prNumber: number, |
| 181 | git: AuthenticatedGitClient, |
| 182 | ) { |
| 183 | /** The owner and name of the repository */ |
| 184 | const {owner, name} = git.remoteConfig; |
| 185 | /** The Graphql query object to get a page of pending PRs */ |
| 186 | const PRS_QUERY = params( |
| 187 | { |
| 188 | $first: 'Int', // How many entries to get with each request |
| 189 | $after: 'String', // The cursor to start the page at |
| 190 | $owner: 'String!', // The organization to query for |
| 191 | $name: 'String!', // The repository to query for |
| 192 | }, |
| 193 | { |
| 194 | repository: params( |
| 195 | {owner: '$owner', name: '$name'}, |
| 196 | { |
| 197 | pullRequest: params( |
| 198 | { |
| 199 | number: prNumber, |
| 200 | }, |
| 201 | { |
| 202 | comments: params( |
| 203 | { |
| 204 | first: '$first', |
| 205 | after: '$after', |
| 206 | }, |
| 207 | { |
| 208 | nodes: [commentsSchema], |
| 209 | pageInfo: { |
| 210 | hasNextPage: types.boolean, |
| 211 | endCursor: types.string, |
| 212 | }, |
| 213 | }, |
| 214 | ), |
| 215 | }, |
| 216 | ), |
| 217 | }, |
| 218 | ), |
| 219 | }, |
| 220 | ); |
| 221 | /** The current cursor */ |
| 222 | let cursor: string | undefined; |
| 223 | /** If an additional page of members is expected */ |
| 224 | let hasNextPage = true; |
| 225 | /** Array of pending PRs */ |
| 226 | const comments: Array<PrCommentsSchema> = []; |
| 227 | |
| 228 | // For each page of the response, get the page and add it to the list of PRs |
| 229 | while (hasNextPage) { |
| 230 | const paramsValue = { |
| 231 | after: cursor || null, |
| 232 | first: 100, |
| 233 | owner, |
| 234 | name, |
| 235 | }; |
no test coverage detected