Getting PR by global ID fails ("Something went wrong while executing your query")


#1

Hello!

Right now I’m trying to get all the review feedbacks from the given PR.

I haven’t found any REST API endpoint for that, so I had to go with GraphQL. One side note here is that you can’t just get “global id” to use with GraphQL, you need to query the REST api for the PR (to get the global id) and then do the GraphQL request to get the reviews.

I’ve received global id from the REST endpoint (“id” field in response) and trying to use it in GraphQL:

query($owner: String!, $repo: String!) {
  repositoryOwner(login: $owner) {
    repository(name: $repo) {
      # pullRequests(last: 1 states:MERGED){
      # pullRequests(states:OPEN first:30){
      pullRequests(first: 1 after: "95861680"){
        edges{
          node{
            id
          }
        }
      }
    }
  }
}

And this query fails:

{
  "data": null,
  "errors": [
    {
      "message": "Something went wrong while executing your query. This is most likely a GitHub bug. Please include \"6B1407D4:14AE4:C390BD6:58413698\" when reporting this issue."
    }
  ]
}

While two other options to get PRs work (the commented ones, with state filtering).

Is it possible to get PR by non-global ID in one GraphQL query? Or get review results from the REST API?
Is it possible to somehow fix that GraphQL request?

It may be similar to other problem, but reproduction steps are different and headRef is not required in “my” case.

Thanks!


#2

The main problem has been adressed in other topic: it’s possible to request pullRequest(number: ID to get one PR with given id, which is very nice.

But still, the failing request is there.


#3

Also note (maybe you know that already) that you can do

repository(owner: $owner, name: $repo) {

instead of

  repositoryOwner(login: $owner) {
    repository(name: $repo) {

#4

Is it possible to get PR by non-global ID in one GraphQL query? Or get review results from the REST API?

As you found, I think the pullRequest(number: $number) connection will probably best suit your needs.

Is it possible to somehow fix that GraphQL request?

I have a hunch that this may be a specific bug with the repository or pull request that you’re requesting. In order to confirm that, would you mind executing this query?

query {
  repository(owner:"rails", name:"rails") {
    pullRequest(number: 27271) {
      title
      author {
        login
      }
      reviews(first:30) {
        edges {
          node {
            comments(first:30) {
              edges {
                node {
                  author {
                    login
                  }
                  body
                }
              }
            }
          }
        }
      }
    }
  }
}

I think that it has all of the information that you desire, albeit for a different repository. If that works, could you try it for the repository and pull request in question and let me know if that works?

Cheers,
Brooks


#5

Thanks for the reply!

I’ve tried the same request once again and it’s no longer showing the previous error, right now it’s showing correct error message:

  "message": "`95861680` does not appear to be a valid cursor.",
  "type": "INVALID_CURSOR_ARGUMENTS",

So, issue has been fixed one way or another. :slight_smile:


#6

That’s good to hear! If anything odd comes up, please let us know and we’ll do our best to resolve it in a timely manner.

Cheers,
Brooks