Get file size (e.g. README)


#1

In
https://developer.github.com/v3/repos/contents/

It allows to get the contents of a file or directory in a repository (like README):

{
  "type": "file",
  "encoding": "base64",
  "size": 5362,
  "name": "README.md",
  "path": "README.md",
  "content": "encoded content ...",
  "sha": "3d21ec53a331a6f037a91c368710b99387d012c1",
  "url": "https://api.github.com/repos/octokit/octokit.rb/contents/README.md",
  "git_url": "https://api.github.com/repos/octokit/octokit.rb/git/blobs/3d21ec53a331a6f037a91c368710b99387d012c1",
  "html_url": "https://github.com/octokit/octokit.rb/blob/master/README.md",
  "download_url": "https://raw.githubusercontent.com/octokit/octokit.rb/master/README.md",
  "_links": {
    "git": "https://api.github.com/repos/octokit/octokit.rb/git/blobs/3d21ec53a331a6f037a91c368710b99387d012c1",
    "self": "https://api.github.com/repos/octokit/octokit.rb/contents/README.md",
    "html": "https://github.com/octokit/octokit.rb/blob/master/README.md"
  }
}

How can I do that in GraphQL API?

I managed to get down to the level of:

{
  repository(owner: "nickvanw", name:"ircx") {
    object(expression: "master:README.md") {
      {... on Tree {entries { HERE, HOW TO SPECIFY SIZE }}
    }
  }
}

from https://developer.github.com/v4/explorer/, but can’t get any further.

Please help. Thx!


#2

I don’t think we have the ability to provide file contents via the GraphQL API… at least not without doing some things that we shouldn’t!

My recommendation would be to use the v3 API to get file contents, or (if there’s a lot of it) to clone the repository with a depth of 1 and get the files from the filesystem.