GraphQL
Table of Contents
Fetching data from Github API with GraphQL
This is the link to the tool to test and build these queries.
Query to view my gists
Query:
{
viewer {
gists(first: 10) {
nodes {
id
createdAt
description
}
}
login
}
}
Result:
{
"data": {
"viewer": {
"gists": {
"nodes": [
{
"id": "MDQ6R2lzdGU4NjNiNDI5MmMzOWNlYjY4NThjZTZmNjkzYzI3Mzli",
"createdAt": "2018-11-15T08:22:48Z",
"description": "My linux setup"
},
{
"id": "MDQ6R2lzdDdjYmVhMTQwMDg0NDU0NGZmMDIyNDUyYThiNmY2NmIx",
"createdAt": "2019-01-16T11:55:27Z",
"description": "My personal vimium config"
}
]
},
"login": "craftsmandigital"
}
}
}
Query to fetch my repos
Query:
query {
repositoryOwner(login: "craftsmandigital") {
login
url
repositories(first: 5){
totalCount
nodes{
name
url
description
}
}
}
}
Result:
{
"data": {
"repositoryOwner": {
"login": "craftsmandigital",
"url": "https://github.com/craftsmandigital",
"repositories": {
"totalCount": 34,
"nodes": [
{
"name": "configuration-files",
"url": "https://github.com/craftsmandigital/configuration-files",
"description": "my config. files"
},
{
"name": "install-scripts",
"url": "https://github.com/craftsmandigital/install-scripts",
"description": "All my installation scripts in one place"
},
{
"name": "test",
"url": "https://github.com/craftsmandigital/test",
"description": null
},
{
"name": "emacs-configuration",
"url": "https://github.com/craftsmandigital/emacs-configuration",
"description": "My emacs (spacemacs) configuration in one place"
},
{
"name": "windows-batc",
"url": "https://github.com/craftsmandigital/windows-batc",
"description": "All my windows batc files"
}
]
}
}
}
}