Null mergeCommit merged PR object - when does that happen?



I’m using the GraphQL API and I don’t understand under which circumstances the mergeCommit field of a merged PR object is null. The documentation here doesn’t explain it either.

This seems to happen on open-source repos mostly, so I’m thinking that it might have something to do with it. I tried reproducing this behaviour with various forking/merging workflows unsuccessfully.

For example, running this query on the Ruby on Rails repository will return a merged PR with a null mergeCommit even though a merge commit can be seen on the PR’s page.

query { 
  repository(owner: "rails" name: "rails") {
    pullRequest(number: 18074) {
      mergeCommit {

Could you provide a set of circumstances under which a merged PR will have a null mergeCommit?




Hi @matthieualouis!

Interesting! It looks like the REST API call returns a merge_commit_sha as well, which appears to be 3eeee85b954d1a36f1383efc47702b608e06087a. Attempting to view that commit in the GitHub UI returns a 404: - likely because history was rewritten at some point, and that commit no longer exists. Instead of give a SHA with no information, the GraphQL API will return a null.

If you have any other examples, please don’t hesitate to share so that I can dig in!