问题描述
我想使用 GraphQL Github API 递归列出目录中包含的所有文件.现在我的查询看起来像这样:
I want to use the GraphQL Github API to recursively list all files contained in the directory. Right now my query looks like this:
{
search(first:1, type: REPOSITORY, query: "language:C") {
edges {
node {
... on Repository {
name
descriptionHTML
stargazers {
totalCount
}
forks {
totalCount
}
object(expression: "master:") {
... on Tree {
entries {
name
type
}
}
}
}
}
}
}
}
然而,这只给了我第一级目录内容,特别是一些结果对象又是树.有没有办法调整查询,使其再次递归列出树的内容?
However, this only gives me only the first level of directory contents, in particular some of the resulting objects are again trees. Is there a way to adjust the query, such that it recursively list the contents of tree again?
推荐答案
在 GraphQL 中没有递归迭代的方法.但是,您可以使用查询变量以编程方式执行此操作:
There is no way to recursively iterate in GraphQL. However, you can do so programmatically using a query variable:
query TestQuery($branch: GitObjectID) {
search(first: 1, type: REPOSITORY, query: "language:C") {
edges {
node {
... on Repository {
object(expression: "master:", oid: $branch) {
... on Tree {
entries {
oid
name
type
}
}
}
}
}
}
}
}
从 null
的值开始,然后从那里开始.
Start with a value of null
and go from there.
这篇关于Github GraphQL 递归列出目录中的所有文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论