6

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!

1 Answer 1

6

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

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.