【发布时间】:2018-01-02 16:01:53
【问题描述】:
我有一个应用程序在数据库中记录一些 GitHub 存储库的名称。以以下 3 个 repo 为例。
- https://github.com/zhangkun-Jser/react-experience
- https://github.com/zhangkun-Jser/vue-plug
- https://github.com/hsluoyz/casbin
但问题是我记录的 repos 可能会被重命名。比如上面三个repos已经分别改名为:
- https://github.com/zhangkun-Jser/react-kit
- https://github.com/zhangkun-Jser/FE-plugs
- https://github.com/casbin/casbin
我想编写一些代码来主动将数据库中的任何旧仓库名称更新为新的仓库名称。例如,将zhangkun-Jser/react-experience 更新为zhangkun-Jser/react-kit。
我知道我可以使用 GitHub V3 API 获取每个 repo 的存储库信息,然后获取新名称。但这需要为每个 repo 发送请求。我的问题是if there is any method to get the new names for a list of repos in one request?
注意:repos 可以来自不同的所有者,如示例中所示。
我尝试使用GraphQL API v4,但我不知道如何获取存储库列表的信息。而且 V4 API 似乎无法识别旧名称。例如,如果我发送以下请求:
{
repository(owner: "zhangkun-Jser" name: "react-experience") {
name
id
}
}
回复是:
{
"data": {
"repository": null
},
"errors": [
{
"message": "Could not resolve to a Repository with the name 'react-experience'.",
"type": "NOT_FOUND",
"path": [
"repository"
],
"locations": [
{
"line": 2,
"column": 3
}
]
}
]
}
有人可以帮忙吗?谢谢。
【问题讨论】:
标签: github graphql github-api github-graphql