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

schema-request

#1

There is an existing v3 REST API call for this, https://developer.github.com/v3/pulls/#list-pull-requests-files however there does not appear to be a way to gain this information via GraphQL. I can get a list of the root Tree of a given commit, but that’s all the files in the root, not the changed files.


#2

+1. Related to this post.


#3

We needed that to implement a bot, unfortunately we had to go back to v3, since it is not implemented yet.


#4

I’ve added this request to our internal tracker. We’ll give an update here as soon as we have something to share.


#5

Just stumbled on this missing feature. I’ll be looking forward for it.


#6

+1 also had to drop back to v3 because of this =(


#7

I’m mixing v3 with v4 to get what I need :confused:


#8

Any updates on this? It has been open for a while.


#9

I ran into this missing in v4 compared to v3 as well. :+1:

As an observation, of the following PR fields available in v3:

"comments": 10,
"commits": 3,
"additions": 100,
"deletions": 3,
"changed_files": 5,

It’s possible to get the first two:

comments {
    totalCount
}
commits {
    totalCount
}

But not the last three.


#10

An update. As of October 27, 2017 (2 days after my reply above), it’s now possible to get additions and deletions as well. Those fields have been added to the PullRequest object. See https://developer.github.com/v4/changelog/2017-10-27-schema-changes/.

That means changed_files is the last remaining property that still can’t be fetched via GitHub GraphQL API v4.


#11

Hi,
Any update on how we can get the list of files?
I guess mixing with V3 isn’t the intended solution , right?


#12

I’ve run into this myself a few times now. I’m preparing a presentation on “GraphQL for integrators” using GitHub’s GraphQL as an example, and I would love to show one bit that requires this to work. Can you by any chance give a rough ETA?


#13

Hey @gr2m, @cohenjo,

This is in our list of things to do. We’ll get it done as soon as we can :slight_smile:

I’ll be sure to update this thread when we release this.


#14

It looks like this has been implemented already - see here


#15

@ericat changedFiles is just an integer, telling how many files have changed, not a connection to file nodes


#16

yes, that is true :’(


#17

What’s the ETA for supporting the equivalent of the v3 list pull request files API (https://developer.github.com/v3/pulls/#list-pull-requests-files) in GraphQL v4? Also, would it be possible to get the number of additions and deletions per file as well?


#18

The raw data present at patch_url can be easily regexed to find names of files changed along with their paths. :sweat_smile:


#19

Let me start by saying that we do not have an ETA of when this will be complete, but listing pull request files is something that I am personally working on right now.

Internally at GitHub we’re working on a project to get us closer to the same amount of coverage in our GraphQL schema that we have in the REST API. The way we’re doing that is REST resource by REST resource, and it unfortunately takes time to ensure that we have the right schema design and are confident that we won’t break it in the future. The particular resource that I’m working on right now is the one that’s returned in GET /repos/:owner/:repo/pulls/:number/files.

In order to do this, we take a multi-step process:

  1. Add the appropriate objects, fields, connections, etc to the GraphQL schema in order to build the exact same REST resource that we return in the V3 API.
  2. Craft a query using this new schema to return all of the data that we need for the REST resource in question
  3. Take the result of the query and massage it into a format that looks identical to the REST response of a given endpoint
  4. Use the Scientist library to ensure that the results look correct (return the right types, etc)

I’ll update this thread as soon as we get closer to shipping this and adding the appropriate items to the public schema.

Thank you for your patience :bowing_man:.