INNER CODE UNIT · TypeScript
defaultSetState
ravangen/graphql-rate-limit · src/index.ts:237
export function defaultSetState<TContext>(name = 'rateLimit'): RateLimitSetState<TContext> {
return (response, directiveArgs, source, args, context, info) => {
let state = context[name];
if (!state) {
state = {};
context[name] = state;
}
state[getSchemaCoordinate(info)] = response;
};
}
/**
* Create an implementation of a rate limit directive.
*/
export function rateLimitDirective<
TContext,
TLimiterOptions extends IRateLimiterOptions = IRateLimiterOptions,
>({