So what is that business logic?

Description of your first forum.
Post Reply
badsha0025
Posts: 218
Joined: Sat Feb 01, 2025 9:29 am

So what is that business logic?

Post by badsha0025 »

Great! This gives us a way to keep track of how much we have left. Now we have to set our threshold.

The threshold prevents us from making requests when we’re below a set rate limit. We want to avoid going below zero and hitting those 429 responses.

In order to do that, we’re just going to define another variable. We’re going to call it rateLimitThreshold, and we’re going to set it to 50. Now, 50 isn’t an arbitrary number. We can do some mental math here. We know that every mutation costs 10 query points and I’m doing about three of them at once. That would be 30 points used in the amount of time it takes to do one request. Therefore, 30 is less than 50. Given that the amount of time we’re waiting for requests is roughly about a second, this math should check out.

Now I expect that sometimes we’ll be off and it’ll approach getting below 50, but cameroon phone data that’s when our business logic will protect us. We’ll go over and implement that shortly.

Safeguarding with thresholds

Now we want to take a look to see what’s that value that’s stored in my availableRateLimit variable. After I’ve made those requests, what do I have left? If that’s less than my rateLimitThreshold, the acceptable threshold that we’ve defined for ourselves, then we want to tell our applications, “Wait a second. Hold on. We don’t have room to keep making these requests indefinitely.”

“The goal is to build good software, so that we can prevent making any requests that we know are going to hit our rate limit.”

We’re doing this because we want to avoid hitting a bunch of 429s, which might actually make Shopify think we’re a bot. The goal is to build good software, so that we can prevent making any requests that we know are going to hit a 429.
Post Reply