Ability to order HistoryConnection

schema-request

#1

Right now, in order to get who the original author of a file was, when it was created, and so forth, we need to go through the HistoryConnection and then pull out every commit, it would be nice if we could order the history so that we can simply extract the original author with a single call like the following:

query FileInfo($repo: String!, $user: String!, $path: String!) {
  rateLimit {
    cost
  }

  repository(owner: $user, name: $repo) {
    ref(qualifiedName: "refs/heads/master") {
      target {
      	... on Commit {
          id

          # Order is unsupported right now
          history(first: 1, path: $path, order:  { field: CREATED_AT, direction: DESC }) {
            pageInfo {
              ...
            }

            edges {
              node {
                committedDate
              }
            }
          }
        }
      }
    }
  }
}

If there is a better way to do this I’m open to that too.


#2

It just occurred to me that I didn’t provide a reason why this is useful. On our Jekyll sites we would like to infer who the original author of a post was by using the API to extract who created the file, as normally it’s the person who committed the file that is the author and having this would make doing that very efficient compared to now where calls can exponentially grow as commits grow, especially on some blogs where could be upwards of tens of thousands of commits.


#3

Hi @envygeeks!

Thank you for sharing that use case, it’s very helpful in determining the best way to expose this information.

I can’t think of a way to get the original author of a file through the GraphQL API at the moment. I wonder if the best way would to have a contributors connection hang off of the Blob object, then we’d add an orderBy to that. What do you think of that @envygeeks?

I’ll add this to our internal tracker either way. Thanks for the request.


#4

That sounds like a good connection, I like that!