The GitHub Graphql Explorer can be found at this web page:
Example Queries are often documented in a format such as the one shown below (from this web page):
query($number_of_repos:Int!) {
viewer {
name
repositories(last: $number_of_repos) {
nodes {
name
}
}
}
}
variables {
"number_of_repos": 3
}
It is important to note that you need to copy the JSON after the word variables
into a separate pane in the explorer, without the word variables
, as shown in this screenshot:
Queries
This query will get information about the viewer, and about a single repo:
query {
viewer {
id
name
login
}
repository(owner:"ucsb-cs156-f22", name:"f22-5pm-courses") {
name
id
}
}
This query will get all of the labels (for issues) associated with the repo ucsb-cs156-f22/f22-5pm-courses
query {
repository(owner:"ucsb-cs156-f22", name:"f22-5pm-courses") {
labels(first:20) {
edges {
node {
name
}
}
}
}
}
Sample output:
{
"data": {
"repository": {
"labels": {
"edges": [
{
"node": {
"name": "bug"
}
},
{
"node": {
"name": "documentation"
}
},
{
"node": {
"name": "duplicate"
}
},
{
"node": {
"name": "enhancement"
}
},
{
"node": {
"name": "good first issue"
}
},
{
"node": {
"name": "help wanted"
}
},
{
"node": {
"name": "invalid"
}
},
{
"node": {
"name": "question"
}
},
{
"node": {
"name": "wontfix"
}
}
]
}
}
}
}