Open mbohun opened 5 years ago
mbohun@linux-bswl:~/src> curl -s -H "Authorization: bearer $GITHUB_TOKEN" -X POST -d " \
{ \
\"query\": \"query { viewer { gists { totalCount} }}\" \
} \
" https://api.github.com/graphql | jq
{
"data": {
"viewer": {
"gists": {
"totalCount": 230
}
}
}
}
...with variables:
mbohun@linux-bswl:~/src> curl -s -H "Authorization: bearer $GITHUB_TOKEN" -X POST https://api.github.com/graphql -d '{"query": "query($num_gists:Int!) { viewer { gists(last: $num_gists) { nodes { description id } } } }", "variables": { "num_gists": 2} }' | jq
{
"data": {
"viewer": {
"gists": {
"nodes": [
{
"description": "Google API notes",
"id": "MDQ6R2lzdDgxZGY5YTI3ZTkwODQ2YmE5MTM4NzFiMDRkNzYyYzRm"
},
{
"description": "gist-view jsTree notes",
"id": "MDQ6R2lzdDdhYzExNzU0ODQ0ZDdmZDVjZTk5M2I5NGFlN2M1MGVk"
}
]
}
}
}
}
There might be NUMEROUS LIMITATIONS/RESTRICTIONS compared to the GitHub REST API, this needs proper checking/evaluation:
mbohun@linux-bswl:~/src> curl -s -H "Authorization: bearer $GITHUB_TOKEN" -X POST -d " \
> { \
> \"query\": \"query { viewer { gists { totalCount} }}\" \
> } \
> " https://api.github.com/graphql | jq
{
"data": {
"viewer": {
"gists": {
"totalCount": 230
}
}
}
}
mbohun@linux-bswl:~/src> curl -s -X POST -d " \
{ \
\"query\": \"query { viewer { gists { totalCount} }}\" \
} \
" https://api.github.com/graphql | jq
{
"message": "This endpoint requires you to be authenticated.",
"documentation_url": "https://developer.github.com/v3/#authentication"
}
HTTP GET
, while the GitHub GraphQL API spec (in general?) uses HTTP POST
, and that in turn has restricted support in the Fetch API Request in many browsers
GitHub GraphQL API
GET number of gist-s
result:
GET gist-s description and id
result:
TODO: HOW to get pagination limit ?
result: