'How to get file name with latest commit in GitHub GraphQL API

I can get a list of file names, the latest commit message for that file in separate queries. However, that method is more time consuming the more files you have. Is there a way to get the file name and its commit at the same time?

I am stuck with right now

{
  repository(owner: "fluenthub-community", name: "fluenthub") {
    filename: object(expression: "main:") {
      ... on Tree {
        entries {
          name
        }
      }
      ... on Commit {
        history (path: ) {
          edges {
            node {
              
            }
          }
        }
      }
    }
  }
}

Once the tree is retrieved, a list of file names can be obtained, and for each file name, a commit is retrieved. However, the more files there are, the slower this method becomes. If possible, I would like to get the file name and its latest commit all at once.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source