OneGraph / onegraph-changelog

Product Changelog for OneGraph using Persisted Queries

Home Page:https://onegraph.com/changelog

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GitHub repository contributors available in OneGraph

sgrove opened this issue · comments

For those of you who've reached out wondering how to get a list of all the contributors (and the number of their contributions) for a repository in GitHub, we've stitched in another part of the GitHub v3 REST api endpoint!

You can try it out right here

An example use case

Say you wanted to build a view similar to GitHub's contributors view:
Screenshot 2019-09-19 12 51 50

Show me the query!

You can get quite most (not all!) of the info with the following query:

query RepositoryContributorsQuery(
  $owner: String!
  $name: String!
  $after: String
) {
  gitHub {
    repository(name: $name, owner: $owner) {
      contributors_oneGraph(
        includeAnonymousContributors: false
        after: $after
      ) {
        nodes {
          avatarUrl
          contributionCount
          login
          user {
            bio
          }
        }
        pageInfo {
          hasNextPage
          hasPreviousPage
          startCursor
          endCursor
        }
      }
    }
  }
}

And you can simply use that query with variables like:

{"owner": "clojure", "name": "clojurescript", "after": null}

or for the second page of contributors (using the after argument and endCursor from the first query result) :

{"owner": "clojure", "name": "clojurescript", "after": "MDpnaXRodWI6MQ"}

Caveats

The API doesn't expose data about when a user contributed, or the total line added/removed by a contributor - just their discrete contribution total.

Pagination returns 30 contributors at a time, and you'll need to fetch more using the after argument until hasNextPage comes back as false.

As usual with our forward-looking integrations, we've marked the stitched field by adding a suffix of _oneGraph in case GitHub adds a contributors field in the future, there won't be a conflict and apps you build today will continue to work on OneGraph!

Try it out

Give it a try to see the top contributors to: