Pull requests reviews for user

I’m trying to get all pull request reviews for a specific user (If needed, I can supply a specific repository on which to search).

I tried using the Rest API, but all you can get there is:

  1. Pull requests for a given repository and from there you can get the reviews (if exists). No filter per user.

  2. With a pull request id, get its reviewes. No filter per user.

Using the GraphQL API, I was able to reach the following query:

query {
    user(login: <userName>) {
        contributionsCollection {
            pullRequestReviewContributionsByRepository {
                contributions(first: 100) {
                    nodes {
                        pullRequestReview {
                            <DATA HERE>
                        }
                    }
                }
            }
        }
    }
}

But as it seems, it only returns data for public repositories (or my own pull request reviews), even when I’m using an authenticated token for an organization.

Using that token and supplying some member from the oranization, the pullRequestReviewContributionsByRepository parameter always returns as an empty array.

Is there any easy way of getting all pull request reviews for a given user (on a given repository will also work)?

Thanks

Up until now, the only approach I found is the following:

query {
  repository(name: <repoName>, owner: <orgName>) {
    pullRequests(first: 100) {
      nodes {
        reviews(first: 100, author: <userName>) {
          nodes {
            <DATA HERE>
          }
        }
      }
    }
  }
}

This will provide the pull requests reviewed for a given user on a given repository, but in order to get to these you will have to filter out all the other pull requests in the repository (that did not hold a review by the author).

See response for example:

{
  "data": {
    "repository": {
      "pullRequests": {
        "nodes": [
          {
            "reviews": {
              "nodes": []
            }
          },
          {
            "reviews": {
              "nodes": []
            }
          },
          {
            "reviews": {
              "nodes": [
                {
                  "submittedAt": "2020-04-04T20:33:04Z"
                }
              ]
            }
          },
          {
            "reviews": {
              "nodes": [
                {
                  "submittedAt": "2020-04-04T18:19:22Z"
                }
              ]
            }
          },
          {
            "reviews": {
              "nodes": []
            }
          },
          {
            "reviews": {
              "nodes": []
            }
          },
          {
            "reviews": {
              "nodes": []
            }
          },
          {
            "reviews": {
              "nodes": []
            }
          },
          {
            "reviews": {
              "nodes": []
            }
          },
          {
            "reviews": {
              "nodes": []
            }
          }
        ]
      }
    }
  }
}

So if anyone has a less awkward approach, it would be appreciated.

Hi @ilia-cy,

Thanks for being here! Would ContributionsConnection help?

{
  user(login: "andreagriffiths11") {
    login
    contributionsCollection {
      commitContributionsByRepository {
        contributions(last: 100) {
          nodes {
            occurredAt
            commitCount
            repository {
              nameWithOwner
            }
          }
        }
      }
    }
  }
}

Hello Andrea,

The contributionsCollection is indeed the right solution, as it provides all pull request reviews per repository.

Thing is, it only works for public content.

I discussed this with Github support, and they say it’s a known (non documented) issue and they currently don’t have any ETA of when it will be supported.

1 Like

Hi how can I pull request for fire user for federal or national registry such as federal register.gov or www.gov.uk 

“self declare to is …”

How can I pull request for national archives or data or do tests or self declare a trust