To communicate with the GraphQL server, youโll need an OAuth token with the right scopes.
Follow the steps in โCreating a personal access token for the command lineโ to create a token. The scopes you require depends on the type of data youโre trying to request. For example, select the User scopes to request user data. If you need access to repository information, select the appropriate Repository scopes.
Request the following scopes:
user
public_repo
repo
repo_deployment
repo:status
read:repo_hook
read:org
read:public_key
read:gpg_key
The REST API v3 has numerous endpoints; the GraphQL API v4 has a single endpoint:
https://github-graphql2.p.rapidapi.com/graphql
The endpoint remains constant no matter what operation you perform.
query {
repository(owner:"octocat", name:"Hello-World") {
issues(last:20, states:CLOSED) {
edges {
node {
title
url
labels(first:5) {
edges {
node {
name
}
}
}
}
}
}
}
}
GQL Query:
query($number_of_repos:Int!) {
viewer {
name
repositories(last: $number_of_repos) {
nodes {
name
}
}
}
}
Variables:
{
"number_of_repos": 3
}