问题描述
GitHub 的 GraphQL API 是否与 contents API?
我似乎无法提出接受 repo 所有者、repo 名称和文件路径并返回文件内容的查询.我猜它与 tree 对象有关?>
https://developer.github/early-access/graphql/explorer/
解决方案经过一番挖掘,找到了:
查询{存储库(名称:repoName",所有者:repoOwner"){对象(表达式:分支:路径/到/文件"){...在 Blob {文本}}}}
传递给 object
字段上的 expression
的参数实际上是一个适用于 rev-parse
的 git 修订表达式,所以我猜你可以用它来做高级查询.
文档:
GitHub API 上的存储库对象rev-parseDoes GitHub's GraphQL API have an equivalent to the contents API?
I can't seem to come up with a query that accepts repo owner, repo name and file path and returns the contents of the file. I'm guessing it has something to do with the tree object?
https://developer.github/early-access/graphql/explorer/
解决方案After some digging, found it:
query {
repository(name: "repoName", owner: "repoOwner") {
object(expression: "branch:path/to/file") {
... on Blob {
text
}
}
}
}
The argument passed to expression
on the object
field is actually a git revision expression suitable for rev-parse
, so I guess you can have fun with it to do advanced querying.
Documentation:
Repository object on GitHub API rev-parse这篇关于GitHub GraphQL 等价于内容 API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论