Using REST and GraphQL methods in tandem on the same resources to handle rate limits?

Highlighted
Tourist
11 0 3

Hello,

We've implemented a Shopify integration using the REST APIs, and we have several users managing their stores through this integration. 

We're running into constant rate limiting issues when importing products (i.e. importing their entire catalog initially), and creating/updating products in bulk. 

Since the REST and GraphQL endpoints have entirely separate rate limits, we're wondering if it's possible to use both for the operations that are running up our rate limits. 

For example, to import a user's initial catalog, we need to import all products and their associated data, e.g. variants, images, collections, etc. Let's say a user has 10K products, and we run through the first 1K (so 4 API calls to products with limit 250, + calls to inventory items) before getting a 429 error. Is it possible to then "switch" to GraphQL? I notice that REST payloads provide a admin_graphql_api_id in the return, ideally we could use this as a cursor and retrieve products via GraphQL "after" the last item we retrieved via REST, but I'm not sure if order is maintained and if there's any possible way to keep track of state here to prevent requesting overlapping products, or the opposite problem where not all products are requested properly. 

Similarly with, for example, creating 1000 products, we're wondering if it's possible to go through and make as many POST requests as possible per-product until hitting a 429, then switching to GraphQL to send ProductCreate mutations for each product until potentially hitting another rate limit, then switching back to REST assuming it's "cooled off" by then, etc. 

Has anyone tried anything like this? Is it possible, or are we better off just trying to switch entirely to GraphQL for heavier operations like this, assuming it has friendlier rate limiting?

1 Like
Shopify Partner
78 3 7

I haven't tried anything like that; however - I would assume that since they are 2 completely separate systems, that it would actually work.

Perhaps a good way to test this would be to write a small script that reported your rate limit ratio ( you wouldn't have to hit the limits by any means); but just REST the creation of 20 faux products, then run a GraphQL query to see where the ratio is at. If it's still 0, then you're good to go.

Most people, it turns out, just aren't interested unless they have to pay for it. Go figure.
0 Likes
Highlighted
Excursionist
46 1 6

I once remember reading or being told (can't remember which) that the GraphQL limit was by app, they suggested that you can actually create two apps, two keys, and they have their own limits.  I never tried that, but I would be interested to know if that was actually the case

 

Thanks

 

Grant

0 Likes
Highlighted
Shopify Partner
78 3 7

Out of curiosity - did you figure this out?

Most people, it turns out, just aren't interested unless they have to pay for it. Go figure.
0 Likes
Highlighted
Tourist
11 0 3

Hey @PhobosTech , sorry I missed this. 

What we ended up doing is using the GraphQL bulk API to do the entire import in a single bulk call. We then switched our entire product management (creates, updates) to GraphQL. We left our order management with REST API for now. 

So we did end up going with a mix, which do have separate rate limits, but we aren't "switching" between REST/GraphQL in a single call (i.e. switching back and forth during pagination). With that said, employing the mix of calls has seemed to help so far. 

0 Likes
Highlighted
Tourist
7 0 0

@ShaneOH Hi Shame, we are in need of assistance in getting our api installed and running smoothly. is something you can help with?

Thanks

0 Likes
Highlighted
Tourist
11 0 3

Hey @ravibains -- I can try to help! Feel free to direct message me so as not to flood this topic

0 Likes