graphql - 如何使用 GraphQL 获取 GitHub 存储库的提交以及已更改的文件和更改本身
问题描述
我能够获取提交列表(包含提交消息、oid、提交 url等字段)以及在分支changedFiles
的存储库中创建的数量。
但是,我无法弄清楚如何获取有关更改本身和已更改文件的任何信息。master
在 REST API 的 v3 中,有关更改的信息包含在files
->patch
和files
->中,raw_url
或者blob_url
在该阶段提供了有关原始文件本身的信息。
Q) 在使用 GraphQL 的 GitHub API v4 中,我如何获得相应的信息?
我现在坚持的查询(为简洁起见仅显示 1 个提交)-
query {
rateLimit{
cost
remaining
}
repository(owner: "elastic", name: "elasticsearch") {
name
defaultBranchRef {
name
target {
... on Commit {
history(first:1){
nodes{
message
changedFiles
id
oid
treeUrl
url
tree{
oid
}
}
pageInfo{
hasNextPage
startCursor
endCursor
}
}
}
}
}
}
}
输出:
{
"data": {
"rateLimit": {
"cost": 1,
"remaining": 4999
},
"repository": {
"name": "elasticsearch",
"defaultBranchRef": {
"name": "master",
"target": {
"history": {
"nodes": [
{
"message": "Small corrections to HLRC doc for _termvectors (#35221)\n\nRelates to #33447",
"changedFiles": 2,
"id": "MDY6Q29tbWl0NTA3Nzc1OmEyYzIyYWQ3YWViMGY4ZDUxNDg2NzdkZDcyMjJhZDQzYWZlZTlhMTc=",
"oid": "a2c22ad7aeb0f8d5148677dd7222ad43afee9a17",
"treeUrl": "https://github.com/elastic/elasticsearch/tree/a2c22ad7aeb0f8d5148677dd7222ad43afee9a17",
"url": "https://github.com/elastic/elasticsearch/commit/a2c22ad7aeb0f8d5148677dd7222ad43afee9a17",
"tree": {
"oid": "4f5f11e0e55aeafc4677800959232726a2cd787c"
}
}
],
"pageInfo": {
"hasNextPage": true,
"startCursor": "a2c22ad7aeb0f8d5148677dd7222ad43afee9a17 0",
"endCursor": "a2c22ad7aeb0f8d5148677dd7222ad43afee9a17 0"
}
}
}
}
}
}
}
解决方案
推荐阅读
- ruby-on-rails - 在相关集合上使用 send()
- javascript - 使用 TypeORM 迁移如何在迁移期间为列播种
- scala - 在 Scala 中使用 For Comprehension 在 If 测试后仅使用 flatMap Future[T]
- c# - 使用实体框架从多对多关系中选择数据
- mocha.js - mocha chai 如何根据条件添加自定义标题
- php - 为什么 .env 文件中的值是空的?
- python - 我可以向新创建的用户的辅助电子邮件发送新帐户通知吗?
- android - LeakCanary 构建失败,构建类型不是调试或发布
- audio - 如何使用 VLC 命令行转换和规范化音频?
- javascript - 在 extjs 6 中编辑后重新加载商店和网格