Jordan V
Jordan V

Reputation: 117

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

Upvotes: 3

Views: 1387

Answers (1)

VonC
VonC

Reputation: 1328332

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.

Upvotes: 2

Related Questions