I'm trying to migrate my project from GitHub API v3 to v4.
How to get the files or directories of a repository through GraphQL API just like what I've done with the following RESTful API in v3:
GET /repos/:owner/:repo/contents/:path
?
I've read the document of GitHub API v4 but failed to find anything about it.
For searching the directory:
query {
repository(name: "<repo>", owner: "<owner>") {
object(expression: "master:") {
... on Tree {
entries {
name
}
}
}
}
}
And for getting the file content:
query {
repository(name: "<repo>", owner: "<owner>") {
object(expression: "master:<path>") {
... on Blob {
oid
byteSize
text
}
}
}
}