Fix workspace schema caching when user is not logged in (#5173)
In this PR: - Follow up on #5170 as we did not take into account not logged in users - only apply throttler on root fields to avoid performance overhead
This commit is contained in:
@ -40,6 +40,10 @@ export const useThrottler = (
|
||||
addPlugin(
|
||||
useOnResolve(async ({ args, root, context, info }) => {
|
||||
if (options.limit && options.ttl) {
|
||||
if (root !== undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
const id = options.identifyFn(context);
|
||||
|
||||
const errorMessage = await context.rateLimiterFn(
|
||||
@ -47,7 +51,7 @@ export const useThrottler = (
|
||||
{
|
||||
max: options?.limit,
|
||||
window: `${options?.ttl}s`,
|
||||
message: interpolate('Too much request.', {
|
||||
message: interpolate('Too many requests.', {
|
||||
id,
|
||||
}),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user