Skip to content

Instantly share code, notes, and snippets.

@stknohg
Created April 26, 2018 06:37
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stknohg/331b4bae6448246cd6aa7fcabce49bb7 to your computer and use it in GitHub Desktop.
Save stknohg/331b4bae6448246cd6aa7fcabce49bb7 to your computer and use it in GitHub Desktop.
GitHub GraphQL APIのサンプル
#
# PowerShell/PowerShellリポジトリのリリース情報を取得するクエリ
# 取得件数は適当
#
$header = @{
'content-type' = 'application/json';
Authorization = 'bearer YOUR_GITHUB_API_TOKEN'
}
$query = @'
{
repository(owner: "powershell", name: "powershell") {
releases(first: 50, orderBy: {field: CREATED_AT, direction: DESC}) {
edges {
node {
id,
tag {
name
},
name,
url,
isPrerelease,
publishedAt,
releaseAssets(first: 20) {
edges {
node {
name,
createdAt,
size,
downloadUrl
}
}
}
}
}
}
}
}
'@
$body = @"
{
"query": "query $($query -replace "`n","" -replace """","\""")"
}
"@
Invoke-RestMethod -Uri https://api.github.com/graphql -Method Post -Headers $header -Body $body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment