I'm trying to get a list of folders name in Gatsby, along with the name of the files located inside them.
Here are the 2 queries I can use :
query fetchDirectories {
allDirectory(filter: {
relativeDirectory: {
regex: "/documentation/"
}
}) {
edges {
node {
name
}
}
}
}
and
query fetchFilesByDirectory($directory: String) {
allFile(filter: {
internal: {
mediaType: {
eq: "text/markdown"
}
}
relativePath: {
regex: $directory
}
}) {
edges {
node {
name
}
}
}
}
Separately, the queries are working, and I can get the good results.
In my code, I'd like to execute that second query for each directories returned by the first query.
Any idea on how to do it ?