I'm using Github API v4 to run search query.
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
}
}
}
}
And response is:
{
"data": {
"search": {
"pageInfo": {
"startCursor": "Y3Vyc29yOjE=",
"hasNextPage": true,
"endCursor": "Y3Vyc29yOjEwMA=="
},
...
}
To communicate with GitHub's GraphQL API, fill in the header name with "Authorization" and the header value with "bearer [your personal access token]". Save this new header for your GraphiQL application. Finally, you are ready to make requests to GitHub's GraphQL API with your GraphiQL application.
To resolve this issue, GraphQL servers can paginate their list fields. This diagram shows offset-based pagination, in which a client requests a page based on an absolute index in the list ( offset ) and the maximum number of elements to return ( limit ).
Pagination means getting a part of data in a large dataset, and continuously get parts of it till the whole dataset has been received. This helps in optimizing our app's performance because trying to get all the data will result in a slow load time of our app and also a slow rendering of the results in the UI.
Pagination is a process that is used to divide a large dataset into smaller chunks (pages). All Square API endpoints that return a list of resources support pagination. For example, the SearchCustomers endpoint (Customers API) and ListCustomerRefunds endpoint (Refunds API) support pagination.
According to graphql documentation there are more than one pagination model.
GitHub is using complete connection model
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
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With