I am attempting to read the raw contents of a specific file in my GitLab repository using the GraphQL API. Doing this with the REST Api is detailed here: https://docs.gitlab.com/ee/api/repository_files.html#get-raw-file-from-repository
Yet I can’t quite figure out how to do this with GraphQL. This is as far as I’ve gotten.
{
project(fullPath: "BenSa/first-project") {
repository {
tree(ref: "master", recursive: true){
blobs{
nodes {
name
type
flatPath
sha
}
}
}
}
}
}
The result of this query is:
{
"data": {
"project": {
"repository": {
"tree": {
"blobs": {
"nodes": [
{
"name": "data.json",
"type": "blob",
"flatPath": "",
"sha": "aa6f396f7a0e2c3163bc05c857539db89ade1a37"
},
{
"name": "index.html",
"type": "blob",
"flatPath": "",
"sha": "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"
}
]
}
}
}
}
}
}
Yet I want to access the raw contents of “data.json”. I have searched through the GraphQL schema for the word “raw” and only found references to snippets. The Blob type has a webUrl but not a rawUrl and besides I need the data coming from the GraphQL response if possible, not a separate fetch request. Any ideas?
Here is the GitLab GraphiQL link: https://gitlab.com/-/graphql-explorer
And the GraphQL Reference: https://docs.gitlab.com/ee/api/graphql/reference/
Thanks