Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
GitHub GraphQL repo commit history query
{
repository(name: "sickvim", owner: "jonathansick") {
ref(qualifiedName: "master") {
target {
... on Commit {
id
history(first: 5) {
pageInfo {
hasNextPage
}
edges {
node {
messageHeadline
oid
message
author {
name
email
date
}
}
}
}
}
}
}
}
}
@kasunsiyambalapitiya

This comment has been minimized.

Copy link

@kasunsiyambalapitiya kasunsiyambalapitiya commented Jan 30, 2017

can we use graphQL to get details about a given commit hash, (just like in commit REST API)

@kasunsiyambalapitiya

This comment has been minimized.

Copy link

@kasunsiyambalapitiya kasunsiyambalapitiya commented Jan 31, 2017

Can we use the above code to get the details of first 2 commits before a certain commit ( hash 7e6c355e1c250036c9ba0d76133b5068b2444f3d ) that exists in the repository. Here is my code.

query { 
repository(owner:"wso2",name:"product-is"){
  object(expression:"master"){
    ... on Commit {
      history(first:2,before:"7e6c355e1c250036c9ba0d76133b5068b2444f3d"){
        edges{
          node{
            id
            blame(path:"pom.xml"){
              ranges{
                startingLine
                endingLine
                commit{
                  author {
                  
                    email
                    name
                  }
                }
              }
            }
            
          }
        }
        
        
      }
    }
  }
}
    
  

}
 

but it gives me this error

"errors": [
    {
      "message": "backwards pagination unsupported for CommitHistoryConnection",
      "type": "INVALID_CURSOR_ARGUMENTS",
      "locations": [
        {
          "line": 11,
          "column": 9
        }
      ],
      "path": [
        "repository",
        "object",
        "history",
        "edges"
      ]
    }
  ]

What I am doing wrong

@echjordan

This comment has been minimized.

Copy link

@echjordan echjordan commented Feb 28, 2018

@jonathansick This query works great for me, I'm just not sure why. Based on SQL type experience, what I want to do is a "join" between Repo and Commit fields and I don't understand how that maps onto graphQL's fragments or why the ref -> target is necessary. Any clarification would be mightily appreciated.

@joebowbeer

This comment has been minimized.

Copy link

@joebowbeer joebowbeer commented May 24, 2018

@kasunsiyambalapitiya before needs to be a cursor. Generally, I think, first is used with after and last is used with before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.