How to specify PR with requestReview mutation?


#1

I am trying to use the requestReview mutation, but I’m not 100% sure how to get the ID to put into the pullRequestId parameter for the mutation.

I assume that the ID I should be using is the value of the id attribute from the pullRequest query. I did the following to get that ID:

query {
  repository(owner:"aergonaut", name:"testrepo") {
    pullRequest(number: 32) {
      id,
      path
    }
  }
}

Then I tried to use that in the requestReview mutation:

mutation RequestReview($r: RequestReviewsInput!) {
  requestReviews(input: $r) {
    pullRequest {
      path
    },
    requestedReviewersEdge {
      node {
        login
      }
    }
  }
}

{
  "r": {
    "pullRequestId": "MDEwOlJlcG9zaXRvcnk0NDU2OTQyMw==",
    "userIds": ["MDQ6VXNlcjI4NDAwNw=="]
  }
}

But the GraphiQL explorer gave me an error:

{
  "data": {
    "requestReviews": null
  },
  "errors": [
    {
      "message": "Could not resolve to a node with the global id of 'MDEwOlJlcG9zaXRvcnk0NDU2OTQyMw=='.",
      "locations": [
        {
          "line": 7,
          "column": 3
        }
      ],
      "path": [
        "requestReviews"
      ]
    }
  ]
}

Is this the right way to specify the PR for this mutation? I’m also not sure if I’m identifying the user correctly.

Thanks for any help!


#2

When I run your first query, the data I get back is:

{
  "data": {
    "repository": {
      "pullRequest": {
        "id": "MDExOlB1bGxSZXF1ZXN0OTY0MTk3NTE=",
        "path": "/aergonaut/testrepo/pull/32"
      }
    }
  }
}

It looks like MDExOlB1bGxSZXF1ZXN0OTY0MTk3NTE= is the actual pull request ID you want. Does this help?