我正在使用 Github API v4 来运行搜索查询。
从API文档中我可以了解到以下查询为我提供了pageInfo,但我不知道如何使用它来遍历。
query {
search(first: 100, type:USER, query:"location:usa repos:>0 language:java") {
pageInfo {
startCursor
hasNextPage
endCursor
}
userCount
nodes {
... on User {
bio
company
email
id
isBountyHunter
isCampusExpert
isDeveloperProgramMember
isEmployee
isHireable
isSiteAdmin
isViewer
location
login
name
url
websiteUrl
}
}
}
}
响应是:
{
"data": {
"search": {
"pageInfo": {
"startCursor": "Y3Vyc29yOjE=",
"hasNextPage": true,
"endCursor": "Y3Vyc29yOjEwMA=="
},
...
}
最佳答案
根据graphql documentation分页模型不止一种。
GitHub 使用完整连接模型
在此模型中,您可以通过在搜索查询中添加 after:"Y3Vyc29yOjEwMA==" 来进行遍历。
query {
search(first: 100, after:"Y3Vyc29yOjEwMA==", type:USER, query:"location:usa repos:>0 language:java") {
pageInfo {
startCursor
hasNextPage
endCursor
}
userCount
nodes {
... on User {
bio
company
email
id
isBountyHunter
isCampusExpert
isDeveloperProgramMember
isEmployee
isHireable
isSiteAdmin
isViewer
location
login
name
url
websiteUrl
}
}
}
}
关于rest - GitHub API v4 : How can I traverse with pagination?(GraphQL),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48116781/