Set GraphQL query variables from Javascript Query

Hi. I need to retrieve paginated records from the Shopify API. I have created a GraphQL query that takes an end_cursor as a parameter. The query works as expected.

I am calling this query from a Javascript Query but need to set the 'end_cursor' variable to fetch the next pages recursively.

The reason I need to do this is because I need to filter and transform the results once I have retrieved all the records (pages) from Shopify (GraphQL).

How can I access and set the variables from within a javascript query? I we can't do this, is there another way to achieve this?

Thank you

Hey @griffinsweets,

Would using additionalScope in your queries be helpful? Here’s a forum thread that walks through it:

We also have this thread on looping through an array to trigger an API for each element and returning the data all together:

Let me know if you have any questions!

Thank you for the quick response. I was able to resolve my issue!