Skip to content
Coding4GaiAmaOpen Source straight from the jungle

#Github GraphQL to recursively list all files in the directory

Thanks to this amazing SO (StackOverflow) answer to the question “Github GraphQL to recursively list all files in the directory” I finally got my query working 😃

The query works only using the gatsby-source-graphql plugin.
If you want to use it outside Gatsby remove the GitHub_ prefixes so it becomes GitObjectID, Tree and Blob, haven’t tested it elsewhere though.

GraphQL
query($branch: GitHub_GitObjectID) {
github {
viewer {
repository(name: "Coding4GaiAma") {
name
object(expression: "master:", oid: $branch) {
... on GitHub_Tree {
entries {
name
object {
... on GitHub_Blob {
text
}
}
}
}
}
issues(first: 10, filterBy: { states: OPEN }) {
nodes {
title
url
bodyText
}
}
}
}
}
}
Discuss on Twitter
Share

Can Rau

Open Source & Rainforest Maintainer at GaiAma.org 🌴