How to return changed files under Commit?


#1

Is it possible to get changed files under Commit. I would like to get change files’ names and status(e.g. ‘modified’)?
It appears that tree{entities{names in Commits returns all files, and not only those that have been changed, and from one commit to the next the entries do not change.
Here is an example of a query:

query {
         repository(owner: "xyz", name: "abc") {
            ... on Repository{
              ref(qualifiedName:"master"){
                target{
                  ... on Commit{
                    history(first:100,since:"2017-04-01T06:00:00Z"){
                      edges{
                        node{
                          message
                          committedDate
                          tree{
                            entries{
                              name
                            }
                          }
                        }
                      }
                    }
                }
              }
            }
        }
      }
    }

Per commit, the equivalent endpoint in REST is this:
curl -i 'https://api.github.com/repos/MyOrg/MyRepo/commits/123406fffd' -u me
The returned json contains files collection. Is there a way to get to this data from the GraphQL query? In my case the rest query returns 4 changed files, as expected, but GraphQL returns all files, regardless of their status(even those that have not been modified)
Thank you


#2

Hi there

+1, this is also of interest to me.

Actually I’m not sure how you get all files in the repository @nickrally – I can only figure out how to get the root tree, i.e. the trees correspond to files & directories in the root directory of the repo. There doesn’t seem to be a way to expand directory trees.

In any case, the ability to get the files changed by individual commits in v4 would be great. The same applies to PRs :slight_smile:

Thank you
Nick


#3

This feature would be nice for me, too. files and stats, like we can do in v3.


Schema request to fetch a list of changed files associated with a pull request
#4

Following up here with the same interest. I haven’t found a way to do this on Github’s graphql API directly, but - if you’re using Apollo - you can specify this in the client using directives (e.g., @include). See this post: https://dev-blog.apollodata.com/the-anatomy-of-a-graphql-query-6dffa9e9e747 and jump down to the Directives section.

Let me know if you guys have figured out how to do this on Github’s API directly.


#5

I would really like this feature as well. List of new/modified/deleted files for a commit. Currently have to make one request per commit using v3 only for this, and I can do everything else in v4.


#6

Hello,

This is in the works! I can’t give an exact date, modeling git data can be challenging in GraphQL and we’re working on making the implementation as intuitive and complete as possible.

When this does eventually ship, we’ll let everyone know here.