Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Pagination page URL and total page number #1468

Unanswered
iamfoysal asked this question in Q&A
Discussion options

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"
 }
 }
 ]
 }
 }
}
You must be logged in to vote

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

When I faced this problem I added an extra field to the pageInfo graphql-python/graphene#573

You must be logged in to vote
0 replies
Comment options

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).

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /