GitHub API v4:如何使用分页遍历?(GraphQL) [英] GitHub API v4: How can I traverse with pagination? (GraphQL)
本文介绍了GitHub API v4:如何使用分页遍历?(GraphQL)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用 Github API v4 来运行搜索查询.
I'm using Github API v4 to run search query.
从 API 文档中我可以理解以下查询为我提供了 pageInfo,但我不知道如何使用它来遍历.
From the API documentation I can understand that the following query gives me pageInfo but I don't know how to use it to traverse.
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 文档有是多个分页模型.
According to graphql documentation there are more than one pagination model.
GitHub 正在使用完整的连接模型
GitHub is using complete connection model
在此模型中,您可以通过在搜索查询中添加 after:"Y3Vyc29yOjEwMA==" 进行遍历.
In this model you can traverse with adding after:"Y3Vyc29yOjEwMA==" to your search query.
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
}
}
}
}
这篇关于GitHub API v4:如何使用分页遍历?(GraphQL)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文