-
Notifications
You must be signed in to change notification settings - Fork 766
-
how to get the pagination page URL and total page number?
when we use like this:
query{
users(first:3, after:""){
pageInfo{
startCursor
endCursor
}
edges{
node{
id
username
}
}
}
}
result:
{
"data": {
"users": {
"pageInfo": {
"startCursor": "YXJyYXljb25uZWN0aW9uOjA=",
"endCursor": "YXJyYXljb25uZWN0aW9uOjI="
},
"edges": [
{
"node": {
"id": "157"
}
},
{
"node": {
"id": "156"
}
},
{
"node": {
"id": "155"
}
}
]
}
}
}
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 3 comments
-
@sjdemartini @everdrone @japrogramer @TheRexx @changeling @ptadas any thoughts on this?
Beta Was this translation helpful? Give feedback.
All reactions
-
When I faced this problem I added an extra field to the pageInfo graphql-python/graphene#573
Beta Was this translation helpful? Give feedback.
All reactions
-
I would recommend reading about cursor-based pagination and how it differs from offset-based pagination. e.g. this article might be helpful https://ignaciochiazzo.medium.com/paginating-requests-in-apis-d4883d4c1c4c, and/or https://graphql.org/learn/pagination/. You are referencing relay's cursor-based pagination, in which case there is not a "total page number" since there aren't really "pages" per se (unlike with offset-based pagination, where this can perhaps more cleanly be done). And there isn't a specific "page URL"—usually you will keep track of the next cursor in order to be able to fetch the next "page" of content. The first link above has some examples (with a REST API, though it should apply in much the same way with GraphQL).
Beta Was this translation helpful? Give feedback.