@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.
13 lines (12 loc) • 504 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDirective = void 0;
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;
}
exports.getDirective = getDirective;