Querying and updating commit statuses




I wanted to switch my application from the old GitHub REST API to the newer, faster, GraphQL. However, if I understand correctly, it’s lacking the functionality that I require - hence I’ve come to ask this question in case I haven’t dug far enough.

This is what I am currently doing using the REST API, and was wondering how possible it is to accomplish the same thing using the GraphQL API:

  1. Fetch the latest commit status for each branch of a given repository
  2. Update a commit status with for a given commit SHA
  3. Fetch recent PushEvents

I have had a browse of the GraphQL reference, and I can’t seem to find a list of branches or commits on a repository which would lead me to being able to query the status of a commit (I have noticed that the Status object is there, but it seems to only be available through the commit list of a pull request?). Similarly, I haven’t been able to find an addCommitStatus mutation, or any mention of how to query for PushEvents.

Appreciate the help!


So I’ve figured out how to fetch the latest status for each branch:

query ($owner: String!, $name: String!, $branch: String!) {
  repository(owner: $owner, name: $name) {
    ref(qualifiedName: $branch) {
      target {
        ... on Commit {
          history(first: 100) {
            edges {
              node {
                status {
                  contexts {

Still looking for some kind of status mutation and Events api…


Hi @Norbo11!

I’m glad to see that you’ve been able to find some of what you’re looking for!

I do believe those other two requests have not made it to the GraphQL schema at this point. For now, I would recommend using the v3 REST API to get that information. I’ve created an internal issue indicating your request, and we’ll update this thread when we have more information.



I’m in a similar boat: I’d like to post an updated status to a commit (but for me, it’s one associated with a PullRequest). I’d be happy to fetch information via v4 GraphQL, and post the update via v3 REST API. Is there a recommended way to go from the GraphQL representation of a PullRequest/Commit to the v3 REST “status_url” to which the updated statuses should be sent?

One option is to “dead-reckon” the URL, since it’s pretty well defined:


I could also manipulate the commitResourcePath I get back from the v4 GraphQL endpoint:

query ($owner: String!, $repo: String!, $number: Int!) {
  repository(owner: $owner, name: $repo) {
    pullRequest(number: $number) {
      commits(last:1) {
        nodes {
          commit {

… will yield something like /OWNER/REPO/commit/SHA for the commitResourcePath. Grafting https://api.github.com/repos on the front, and replacing /commit/ with /statuses/ should then result in the same url as the dead-reckoned one.

Any recommendations as to which method is less hacky? I’m leaning towards the strictly dead-reckoned one, since (a) that pattern is defined in the v3 REST API docs, and (b) I don’t think there’s any explicit correlation between the v3 and v4 APIs, even if it seems like there should be. Any thoughts/feedback would be appreciated.


Hi @JaredReisinger!

Thanks for the question!

If I’m understanding correctly, you’re asking for the best way to build the URL so that you can create a status using the Statuses REST endpoint in the V3 API.

By my reckoning (which is just my opinion), the best way would be to go with option (a), and just build the URL with your string building library of choice. In Ruby, it’d be as easy as https://api.github.com/repos/#{owner}/#{repo}/status/#{sha} - given that you already have the repository and owner from the GraphQL query, you can just pull the SHA out of the response and use that.

If this didn’t answer your question, or if you need any more clarification, let me know!