Skip to content

Instantly share code, notes, and snippets.

@anonrig
Created February 17, 2022 18:56
Show Gist options
  • Select an option

  • Save anonrig/0299a6ca781302051db221555cecb8ea to your computer and use it in GitHub Desktop.

Select an option

Save anonrig/0299a6ca781302051db221555cecb8ea to your computer and use it in GitHub Desktop.
Get Review Threads using Github
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