Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Ground Controller Lvl 1
Message 1 of 2

How to use GraphQL API to get the latest commit date of a specific file.

How can I use the GraphQL API to return the latest commit date of a specific file in a specific repository?

1 Reply
Copilot Lvl 2
Message 2 of 2

Re: How to use GraphQL API to get the latest commit date of a specific file.

The below query returns the latest commit date using commit history.

 

history is ordered from the new to the older commits, hence first:1 returns the latest commit.

In the path property, you should give the specific file path 

 

 

 

{
  repository(owner: "octocat", name: "Hello-World") {
    object(expression: "master") {
      ... on Commit {
        history(path: "README", first:1) {
          edges {
            node {
              commitUrl
              committedDate
            }
          }
        }
      }
    }
  }
}