How to sort commits by committedDate in Ascending order


#1

Hi. I saw this reply on using orderBy here.https://platform.github.community/t/lack-of-documentation-on-ordering-options/1477

Is it possible to use orderBy for commits? It does not look like I can use orderBy in Commits section of the query below

{
  organization(login:"MyOrg"){
    repositories(first: 3, orderBy:{field:PUSHED_AT, direction:ASC}){
      edges{
        node{
          name
          pushedAt
          ... on Repository{
            ref(qualifiedName:"master"){
              target{
                ... on Commit{
                  history(first:10, since:"2017-01-01T00:00:00Z"){
                    edges{
                       node{
                          oid
                          committedDate
                       }
              cursor
              }
              pageInfo{
                hasNextPage
              }
            }
                  }
                }
              }
             }
          }
        }
      }
    }
  }

Thank you


#2

Correct, commits don’t sort by orderBy.

Out of curiosity, how would you expect it to be used? Commits instead use since and before as ordering options as there aren’t many other choices.


#3

Hi @gjtorikian. Thank you for reply. I would like to use it here:

history(first:10, since:"2017-01-01T00:00:00Z", orderBy:{field:committedDate, direction:ASC}){

Using since or before allows me to filter the commits. My question is not so much about filtering but about sorting(ordering). The commits come in the order with the latest (most recent) first - in descending order. I want them to be sorted on the server in the ascending order, with the oldest first. From your reply I understand it is not possible. Once again, thank you for the quick answer.