0

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.

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
harry1102
  • 81
  • 1
  • 2
  • 10
  • related question - https://stackoverflow.com/questions/41697489/how-to-find-users-who-approved-a-pull-request-using-github-api/66767595?noredirect=1#comment135711517_66767595 – harry1102 Aug 28 '23 at 20:19
  • Are you sure they're doing it _on behalf of_ the team? – jonrsharpe Aug 28 '23 at 20:26
  • Not sure about this. Is there an explicit way to approve pull request on behalf of a team? I thought the `TeamConnection` mapping should be implicitly established in `PullRequestReviewConnection`. – harry1102 Aug 28 '23 at 20:42
  • "On behalf of" means the _team's_ review was requested, and one member of that team performed that review. It's unclear from what you've posted whether that's happening or what team(s) you're looking for in the response. – jonrsharpe Aug 28 '23 at 21:17

0 Answers0