Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github v4 GraphQL API. Get commits by date

New to graphql and the Github API. I'm trying to get a list of commits back, sorted by date. This is what I have so far:

{
  repository(owner: "facebook", name: "create-react-app") {
    ref(qualifiedName: "master") {
      target {
        ... on Commit {
          id
          history(first: 20) {
            pageInfo {
            hasNextPage
          }
          edges {
            node {
              messageHeadline
              oid
              message
            }
          }
        }
      }
   }
}

This just returns a flat list of the commit history. Is there another object or connection that I can use to group the results by date?

Thanks

like image 253
Jordan V Avatar asked Apr 30 '26 17:04

Jordan V


1 Answers

There is no notion of "groupBy" or "GroupedBy" in the GraphQL API v4 reference.

All you have is an orderBy argument for repository.
You can see an example here

{
  organization(login: "lvtech") {
    repositories(first: 3, orderBy: {field: PUSHED_AT, direction: DESC}) {
      edges {
        node {
          name
        }
      }
    }
  }
}

But again, that applies to repository attributes, not to commit attributes.

like image 50
VonC Avatar answered May 05 '26 08:05

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!