Created
February 17, 2022 18:56
-
-
Save anonrig/0299a6ca781302051db221555cecb8ea to your computer and use it in GitHub Desktop.
Get Review Threads using Github
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { graphql } from '@octokit/graphql' | |
| /** | |
| * @function getReviewThreads | |
| * @param {{ | |
| * authorization: string, | |
| * repository: {slug: string}, | |
| * organization: {slug: string}, | |
| * pull_request: {number: number} | |
| * }} filters | |
| * @param {{cursor: string|null, page_size: number=}} options | |
| * @returns {Promise<any[]>} | |
| */ | |
| export async function getReviewThreads( | |
| { authorization, repository, organization, pull_request }, | |
| { cursor = null, page_size = 100 }, | |
| ) { | |
| return graphql( | |
| `query { | |
| repository(owner: "${organization.slug}", name: "${repository.slug}") { | |
| pullRequest(number: ${pull_request.number}) { | |
| url | |
| reviewDecision | |
| reviewThreads(first: ${page_size}${cursor ? `, after: ${cursor}` : ''}) { | |
| pageInfo { | |
| endCursor | |
| } | |
| edges { | |
| node { | |
| isResolved | |
| isOutdated | |
| isCollapsed | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| `, | |
| { | |
| headers: { | |
| authorization, | |
| }, | |
| }, | |
| ) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment