Useful Github API GraphQL requests
2023-03-16
Here are a few useful GraphQL requests that I found while working with the Github API for get-activity and okra.
Get recent issue comments from a user
{
viewer {40) {
issueComments(last:
nodes {
url
publishedAt
}
}
} }
Get recent PR comments from a given repository
{"XX", name: "YY") {
repository(owner: 50) {
pullRequests(last:
nodes {50) {
comments(last:
nodes {
url
publishedAt
}
}
}
}
} }
Get all open issues from a repository
{"XX", name: "YY") {
repository(owner: 100) {
issues(filterBy: {states: [OPEN]}, last:
nodes {
title
number
}
}
} }
Get CI failures from a repository
{"XX", name: "YY") {
repository(owner: 13004) {
pullRequest(number: 1) {
commits(last:
nodes {
commit {30) {
checkSuites(last:
nodes {
workflowRun {
workflow { name }
}30) {
checkRuns(filterBy: {conclusions: [FAILURE, STARTUP_FAILURE]}, first:
nodes {
name
conclusion30) {
annotations(first:
nodes {
message
path
location {
start { line }
}
}
}
}
}
}
}
}
}
}
}
} }
Get all files from a directory
{"XX", name: "YY") {
repository(owner: "branch:path/to/something/*") {
object(expression: on Tree {
...
entries {
name
object {on Blob { text }
...
}
}
}
}
} }