Closed sdee3 closed 7 months ago
I went through Apollo's getting started guide and experienced no issues with the limiter, see example branch.
I didn't leverage mergeTypeDefs
as it was not necessary. The example has a query, but mutation also limits.
Maybe use a custom limiter class to see how many times things are being "consumed":
// This is not necessary, it exists to demonstrate when we check the rate limit usage
class DebugRateLimiterMemory extends RateLimiterMemory {
consume(key, pointsToConsume, options) {
console.log(`[CONSUME] ${key} for ${pointsToConsume}`);
return super.consume(key, pointsToConsume, options);
}
}
const {
rateLimitDirectiveTypeDefs,
rateLimitDirectiveTransformer
} = rateLimitDirective({
limiterClass: DebugRateLimiterMemory
});
For example, in your setup, I am unclear what limiter class you are using and any custom key generator.
Happy to reopen if necessary
Hi, I've been having problems setting this up within my fullstack app where I'm serving the BE through Apollo Server version
4.10.0
.Given the simple setup here:
I was expecting that the directive would automatically work for one of my mutations that implement this directive:
submitData: Boolean @rateLimit(limit: 2, duration: 60)
But triggering this mutation from my FE over 20x within 5 seconds does not lead to anything other than my mutation running completely - as if there's no directive applied to it.
What could be wrong?
This is part of what I have installed in my BE package.json: