GitHubGetFileShaAndContent

Get the (textual) value of a file in a GitHub repo via GraphQL

  • $branchAndFilePath should be formatted as ${branchName}:${filePath without the leading '/'}

Note that the text field will be null if the file is a binary blog (such as an image).

If you need to read the binary content, email [support@onegraph.com](mailto:support@onegraph.com?subject=Can you add a base64-encoded binary content field to the GitHubBlob type on OneGraph?) and we can stitch in the corresponding REST endpoint

query GetFileTextContentsQuery($repoName: String!, $repoOwner: String!, $branchAndFilePath: String = "master:README.md") { gitHub { repository(name: $repoName, owner: $repoOwner) { object_: object(expression: $branchAndFilePath) { ... on GitHubBlob { sha: oid # alias this to `sha`, as that's a bit more familiar byteSize isBinary # Note the text content will be null if # `isBinary` is true text } } } } }
Types used in this example
Query

No description

String

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

GitHubQuery

The query root of GitHub's GraphQL interface.

GitHubRepository

A repository contains the content for a project.

GitHubGitObject

Represents a Git object.

GitHubBlob

Represents a Git blob.

GitHubGitObjectID

A Git object ID.

Int

The Int scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.

Boolean

The Boolean scalar type represents true or false.

____________________________________________________________________________________________________