Get pull request that was just merged?

I’m trying to use GraphQL API to search for a Pull Request that was just merged to base branch (master). I am trying to figure out what’s the best way to do this, but I wanted to try to search the Pull Request by its merge commit SHA. I already have the latest commit from master, and I want to find the Pull Request that has the same commit.

I’m still new to GraphQL but this is what I tried so far:

 repository(owner: "octocat", name: "Hello-World") {  
 pullRequests(states: MERGED, first: 1, mergeCommit: "$sha", baseRefName: "master") {   
 edges {   
 node {   

I’m getting this error: Field ‘pullRequests’ doesn’t accept argument ‘mergeCommit’. Not sure what the right syntax for this is.

If you look at the documentation for the Repository.pullRequests connection, there isn’t a mergeCommit filter. So you’ll have to query all the pull requests and filter them yourself by the merge commit SHA. Of course, if you’re only looking for the one that was “just merged” you could order them by updated time and only look at the most recent one or so.

I hope that helps!