Created
April 26, 2018 06:37
-
-
Save stknohg/331b4bae6448246cd6aa7fcabce49bb7 to your computer and use it in GitHub Desktop.
GitHub GraphQL APIのサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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