4

I can query the first pull request like this:

query {
  repository(owner: "test_owner", name: "test_name") {
    pullRequests(first: 1) {
      nodes {
        id
        number
        title
      }
    }
  }
}

But how do I query a certain pull request based on its number?

The following doesn't work:

query {
  repository(owner: "test_owner", name: "test_name") {
    pullRequests(first: 1, number: 50) { <-- CANNOT FILTER BY `number`
      nodes {
        id
        number
        title
      }
    }
  }
}

Thanks for any help!

Bertrand Martel
  • 42,756
  • 16
  • 135
  • 159
liszt
  • 1,139
  • 1
  • 9
  • 17

1 Answers1

5

Use pullRequest instead of pullRequests connection :

Returns a single pull request from the current repository by number.

{
  repository(owner: "nodejs", name: "node") {
    pullRequest(number: 2) {
      id
      number
      title
    }
  }
}

Try it in the explorer

Bertrand Martel
  • 42,756
  • 16
  • 135
  • 159
  • Compared to a `pullRequests` (with an s at the end) query, you just need to remove the `edges` and `node` outer clauses, all the `node` fields apply. – rustyDev Feb 13 '19 at 03:49