Lack of documentation on ordering options

community-help

#1

Hi,

I was trying to reproduce the list of repository that is seen in any organisation main view (ie https://github.com/<org_name>/ where the repositories are ordered by date of last push. So I read the current docs and tried playing around but I couldn’t find how to specify the Ordering for repositories. I also checked the graphql documentation for general ordering and couldn’t not find it either.

This is my query:

query { 
   organization (login: "lvtech"){ 
    repositories (first: 3, orderBy: (RepositoryOrder: (RepositoryOrderField: PUSHED_AT) ) {
      edges{
        node  {
          name
        }
      }
    }
  }
}

which generates a parsing error as this is obviously not the correct syntax for setting the ordering but the few ways I tried all failed in similar ways.

Can someone please help me get this to work?

Thanks :slight_smile:


How to sort commits by committedDate in Ascending order
#2

You’re right! It’s not very well documented at the moment. Sorry about that!

You’ll want something like this:

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

This uses the InputObject, passing in the two required fields: field and direction. Hope this helps!