Shopify-api-node icon indicating copy to clipboard operation
Shopify-api-node copied to clipboard

autoLimit in context of graphql calls

Open pociej opened this issue 4 years ago • 6 comments
trafficstars

As we know one can set autoLimit to avoid hiting rate limit. Problem is that ( from documentation )

When using an object, the calls property and the interval property specify the refill rate and the bucketSize property the bucket size

While in graphql api context limits are not calculated based on calls but points as described here https://shopify.dev/concepts/about-apis/rate-limits.

pociej avatar Jan 12 '21 17:01 pociej

The autoLimit option is ignored when using the GraphQL API. This is documented here https://github.com/MONEI/Shopify-api-node#shopifycalllimits

lpinca avatar Jan 13 '21 20:01 lpinca

I missed that indeed. Anyways, issue is still the same. Queuing calls to make sure one dont hit limit should should be on api wrapper level. And in case of REST API it is. What i reason you didnt implement this on the graphql level?

pociej avatar Jan 13 '21 21:01 pociej

Because the rate limiting method is different. Rate limiting for the REST API is based on the token bucket algorithm and we use https://github.com/lpinca/stopcock. This does not work for the GraphQL API, see https://github.com/MONEI/Shopify-api-node/pull/282#issuecomment-501310673.

lpinca avatar Jan 14 '21 06:01 lpinca

Of course i know it. If you would reread my first comment in this thread you could see I linked shopify docs that describes it. However fact that rate limit is different doesn't mean package should not support graphql case. autoLimit could for example have one more level and be of the form autoLimit : { rest : {}, graphQl : {} }. With current implementation one can rely on the package when it comes to REST rate limits but for graphql not and monkey patching is needed. It doesn't sound good. Right?

pociej avatar Jan 14 '21 11:01 pociej

However fact that rate limit is different doesn't mean package should not support graphql case.

No one said there should be no support for it. It is not implemented.

lpinca avatar Jan 14 '21 11:01 lpinca

Ah ok, so we misunderstood each other ( or at least i misunderstood you :) ). I was sure you are trying to convince me that it is intentional and should be reported as issue. I will PR in free moment.

pociej avatar Jan 14 '21 15:01 pociej

I'm closing this due to inactivity.

lpinca avatar Jan 13 '24 14:01 lpinca