I am trying to fetch the team name of the users who have approved a pull request using the GraphQL API. I am looking forward to perform this operation in a single query. I am able to get the list of reviewers who have approved the request but the team name in the response is empty.
I am trying to look into PullRequestReviewConnection and onBehalfOf field for fetching the team name of the approver. This is my query.
query {
repository(name: "test", owner: "example") {
pullRequest(number: 2) {
reviews(first: 100, states: APPROVED) {
nodes {
author {
avatarUrl
login
resourcePath
url
}
onBehalfOf(first:100) {
nodes {
name
}
}
}
}
}
}
}
Response:
{
"data": {
"repository": {
"pullRequest": {
"reviews": {
"nodes": [
{
"author": {
"avatarUrl": "https://avatars.githubusercontent.com/u/8484848484?u=jdjdjdj",
"login": "abc-xyz",
"resourcePath": "/abc-xyz",
"url": "https://github.com/abc-xyz"
},
"onBehalfOf": {
"nodes": []
}
}
]
}
}
}
}
Wondering whether it would be easier to do this via REST API.