Last active
October 29, 2023 03:11
-
-
Save SteveL-MSFT/b91ee277ea2737faf19e8962b2d7f0b7 to your computer and use it in GitHub Desktop.
GraphQL Query Example
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
$query = @" | |
query { | |
organization(login: "powershell") { | |
name | |
url | |
repository(name: "powershell") { | |
name | |
pullRequests(last: 20, states: [OPEN]) { | |
edges { | |
node { | |
title | |
comments(last: 20) { | |
edges { | |
node { | |
author { | |
login | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
"@ | |
$body = @{query=$query} | ConvertTo-Json | |
$data = Invoke-RestMethod https://api.github.com/graphql -Authentication OAuth -Token (Get-Secret GitHub) -Body $body -Method Post | |
$data.data.organization.repository.pullRequests.edges.node | Format-Table title, | |
@{ | |
label = "comments"; | |
expression = { | |
$_.comments.edges.count | |
} | |
}, | |
@{ | |
label = "authors"; | |
expression = { | |
[string]::Join(",", ( | |
$_.comments.edges.node.author.login | Select-Object -Unique | Sort-Object | |
)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment