Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 2
Message 1 of 5

GraphQL API response for commit status is null

Using the GraphQL API Explorer (but also in my own code), and with the following query:

query($owner:String!,$name:String!) {
  repository(owner:$owner,name:$name) {
    pullRequests(last:10, states:OPEN) {
      nodes {
        commits(last:1) {
          nodes {
            commit {
              status {
                state
              }
            }
          }
        }
      }
    }
  }
}

The commit status is always null for private repositories, even though the GraphQL API Explorer has the right access, and some of the first pull requests do return a status.

 

Am I using the wrong query to get the commit status of the last commit for a given PR, or is something else wrong?

4 Replies
Highlighted
GitHub Staff
Message 2 of 5

Re: GraphQL API response for commit status is null

Hey @pascaldevink!

 

Your query looks right to me! I tested it in a couple of my private repositories and it returned the data that I expected. In your code, are you using a Personal Access Token (PAT)? If so, what scopes does it have? 

Highlighted
Copilot Lvl 2
Message 3 of 5

Re: GraphQL API response for commit status is null

Hi @nickvanw, thanks for coming back to me.

I'm currently using a personal access token with all the `repo` access, and `read:org`, although I want to eventually migrate to using OAuth.

 

I think I've tracked down the root issue: For some repositories, I was able to get all the status information on commits, but for some repositories I was only able to do that up till a certain point.

We are using CircleCI in our organisation and in October we've switched to using Pull Request Checks. You can probably already guess when the status field stopped giving usefull information by now.

 

I see the checks API is still in beta, but the announcement and documentation only cover V3 of the API. Is there an equivalent in V4? And is there any documentation on it for V4?

Highlighted
GitHub Staff
Message 4 of 5

Re: GraphQL API response for commit status is null

Hey @pascaldevink!

 

I think the GraphQL API may be able to do what you want! There is a `Commit.checkSuites` connection that should get you the names and statuses of CircleCI's Checks, something like this:

 

query ($owner: String!, $name: String!) {
  repository(owner: $owner, name: $name) {
    pullRequests(last: 10, states: OPEN) {
      nodes {
        commits(last: 1) {
          nodes {
            commit {
              checkSuites(first: 10) {
                nodes {
                  app {
                    name
                  }
                  checkRuns(first:10) {
                    nodes {
                      status
                      name
                    }
                  }
                  status
                }
              }
            }
          }
        }
      }
    }
  }
}

Let me know if that works!

Highlighted
Copilot Lvl 2
Message 5 of 5

Re: GraphQL API response for commit status is null


@nickvanw wrote:

Hey @pascaldevink!

 

Your query looks right to me! I tested it in a couple of my private repositories and it returned the data that I expected. In your code, are you using a Personal Access Token (PAT)? If so, what scopes does it have? 


@nickvanwI am seeing a similar issue, I can see status for private and public repos with no branch protection rules, however, on repos with branch protection rules on I only get null for all status checks in the Graphql API.