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:
Charles Bochet
2024-04-25 14:45:14 +02:00
committed by GitHub
parent 52f4c34cd6
commit 11a7db5672
3 changed files with 15 additions and 11 deletions

View File

@ -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,
}),
},