Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Ground Controller Lvl 1
Message 1 of 2

Using apiv4, can I get all PRs that have been merged into a branch?

Solved! Go to Solution.

Using the following query, I can get all PRs that have been merged *from* my branch into other branches:

{
organization(login: "MyOrg") {
   repository(name: "MyRepo") {
      ref(qualifiedName: "refs/heads/MyBranch") {
        associatedPullRequests(first:10) {
edges {
node {
id
}
}
} } } }

which is not very useful to me. I have tried to get all refs and get the associatedPullRequests from all refs with myBranch as the baseName, however I have far too many refs for this work and I really want the most recently created PRs. As far as I know there is no way to sort head refs by creation date/last commit date, so I am stuck

1 Reply
Solution
Ground Controller Lvl 1
Message 2 of 2

Re: Using apiv4, can I get all PRs that have been merged into a branch?

Turns out the solution was simple... just use pullRequests instead of associatedPullRequests

{
organization(login: "MyOrg") {
  repository(name: "MyRepo") {
    pullRequests(baseRefName:"MyBranch") {
      nodes{
        title
          }
        }
      }
    }
  }
}