[GraphQL API] Using "after" argument for cursor pagination returns the same cursor in the response

[GraphQL API] Using "after" argument for cursor pagination returns the same cursor in the response

dylanpierce
Shopify Partner
278 13 121

This is a pretty frustrating one, it seems like it's impossible to paginate results with the GraphQL Partner API.

The `pageInfo.hasNextPage == true` given a specific cursor, yet the response from the query _gives you the same exact cursor in the response_.

This results in a never ending request for the same page and a response referencing the same page.

What's even funnier is the docs themselves seem to reference this exact behavior: https://shopify.dev/api/usage/pagination-graphql

Near the bottom of the page, the query is given an after cursor, yet the example response returns the same exact cursor. How are you supposed to programmatically cycle through pages without a new cursor to use in the response?

Screenshots below taken from the GraphQL docs in question. Notice how the request `after` cursor is defined, yet the response _contains the exact same cursor_

Screen Shot 2022-01-11 at 4.43.26 PM.png

 

Screen Shot 2022-01-11 at 4.43.53 PM.png

Founder of Real ID - Verify your customer's real IDs easily & securely with modern A.I.

Want to see it in action? Check out our demo store.

Replies 2 (2)

dylanpierce
Shopify Partner
278 13 121

Welp, I just didn't read the cursors fully.

The last 4 digits of the cursor string are the same - however on closer inspection they are indeed unique just very very subtlety. 

Basically, you have to pop off the last element in the array and retrieve the cursor. Then pass that to the `after` argument.

Jeeze. It's a small detail but they are indeed different. It's embarrassing, but I'm going to leave this up for others to find if they get confused as well as my future self that will most likely forget about this detail.

Founder of Real ID - Verify your customer's real IDs easily & securely with modern A.I.

Want to see it in action? Check out our demo store.

ktbishop
Shopify Partner
22 1 3

Really glad you left this up. I came here to ask a similar question about the cursor seemingly always coming back the same. After reading your reply I realized I ALSO didn't fully read each cursor. That 2-3 character difference sure hides itself well... 😂

Kyle B.