Issue: Recursive Supabase Edge Function for Paginated Shopify Products #33863
Unanswered
harsh-makroagency
asked this question in
Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi everyone,
I've built a Supabase Edge Function that fetches products from a Shopify store. Since Shopify has pagination, I need to retrieve multiple pages of products.
To handle this, I implemented self-calling recursion—invoking the Edge Function within itself to fetch the next page when required. However, I've noticed that Supabase Edge Functions have a limited execution time, which is causing issues when fetching large datasets.
Current Approach
Here’s the code snippet that invokes the function for the next page:
const response = await fetch(
https://${shopifyStoreDomain}.myshopify.com/admin/api/2024-04/graphql.json
, {method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Shopify-Access-Token': shopifyAccessToken,
},
body: JSON.stringify({ query, variables: { first: 250, after: cursor?.endCursor || null } }),
});
Challenges
Beta Was this translation helpful? Give feedback.
All reactions