Vova
Vova

Reputation: 670

Commits stats from github using graphql

Can someone tell me - is where are a way to get all commits of specific repository with stats using graphql api? For now i end with query like this:

query {
  viewer {

  repository(name: "CRM_system") {
    ref(qualifiedName: "master") {
      target {
        ... on Commit {
          id
          history(since: my_date_time) {
            edges {
              node {
                messageHeadline
                oid
                message
                author {
                  name
                  email
                  date
                }
              }
            }
          }
        }
      }
    }
  }
}
  }

But it show commits only from 'master' and doesnt show stats at all, i want to see something similar to github rest api:

stats: {
total: 27
additions: 27
deletions: 0}

Upvotes: 2

Views: 940

Answers (1)

Vova
Vova

Reputation: 670

Get answer from support

https://platform.github.community/t/commit-stats-for-commits-in-repository/2193/4

With latest schema change you can do it this way:

query{
  repository(owner:"education",name:"classroom"){
    defaultBranchRef{
      target{
        ... on Commit{
          changedFiles
          additions
          deletions
        }
      }
    }
}

Upvotes: 1

Related Questions