Challenges with Implementing Custom Cursor Pagination for GraphQL API


Implementing custom cursor pagination for a GraphQL API, facing issues passing ‘endCursor’ value into subsequent requests.


Hello Community,
I am encountering challenges with implementing a custom cursor pagination for a GraphQL API and seeking your assistance.
Here’s the challenge:
• My GraphQL query requires pagination, and I’ve tried using offset pagination with a next token; however, the pagination doesn’t seem to terminate properly.
• To address this, I shifted towards custom cursor pagination to leverage the ability to specify a stop condition.
• Each page response from the API includes an ‘endCursor’, which I use for fetching the next page of results.
The issue I’m facing:
• Although I’m able to extract the ‘endCursor’ value from the first response, I’m struggling to pass this cursor into my GraphQL query to request subsequent pages.
• My current setup involves attempting to inject the cursor value into a variable within the JSON payload for the next request. However, despite my efforts, I can’t seem to correctly pass this cursor value into the query for subsequent requests.
Could anyone provide insights into where my approach might be going wrong? Any suggestions on ensuring the cursor value is used for the next page request?

Thank you in advance for any help you can provide.

This topic has been created from a Slack thread to give it more visibility.
It will be on Read-Only mode here. Click here if you want to access the original thread.

Join the conversation on Slack

["custom-cursor-pagination", "graphql-api", "pagination", "endcursor"]

Are you doing that in the Connector Builder? While it’s great for rest apis, I know graphql is challenging to work with in it. I’d love to try and help.

Can you paste your connector manifest, and give me test credentials for the api you’re working with to play around?

I get the challenge of forming a correct graphql query in builder, my idea would be to try and implement paginator as a custom python component and plug it into Builder. You can do that, but you’d have to run Builder locally on your dev machine to do it, and then publish a custom connector image, or contribute the connector on GitHub if you need it in cloud.

I’m happy to help and make some guides about it!

Thank you for your response! Yes, I am working within the Connector Builder. I need to check with my client regarding the possibility of sharing test credentials.

In the meantime, I would be very grateful for any guides or advice on implementing a custom Python component, especially one that can be utilized in a cloud environment.

Re: credentials: not the real ones, of course — a test account with no private information would be useful, though.

re: custom component: okay! I’ll make a video later tonight — you’ll see it your Tuesday morning. :wink:

It’s been a long day — didn’t have time to make a proper overview and a doc, BUT, here’s a rough overview of how to get started.

This week or next week, Builder will also be able to save the manifest into the local file, so at that point you can use builder and then just make a PR from the directory with the connector.

If the target source service is more or less standard, we’ll accept it.

I would be pleased to help!

Hello Natik,
Thank you so much for your patience and for the video you prepared. It’s incredibly helpful and provides a great starting point for me to try and implement the custom Python component in the Connector Builder. I truly appreciate the guidance!

I’ve also managed to secure test credentials and will share them with you via DM so you can have a closer look.

Thanks again for your willingness to assist!