@envelop/rate-limiter
Version:
This plugins uses [`graphql-rate-limit`](https://github.com/teamplanes/graphql-rate-limit#readme) in order to limit the rate of calling queries and mutations.
9 lines (8 loc) • 366 B
JavaScript
export function getDirective(info, name) {
const { parentType, fieldName, schema } = info;
const schemaType = schema.getType(parentType.name);
const field = schemaType.getFields()[fieldName];
const astNode = field.astNode;
const rateLimitDirective = astNode?.directives?.find(d => d.name.value === name);
return rateLimitDirective || null;
}