@envelop/depth-limit
Version:
This plugins uses [`graphql-depth-limit`](https://www.npmjs.com/package/graphql-depth-limit) in order to limit the depth of executed selection sets (by injecting a new GraphQL validation rule into your execution).
16 lines (15 loc) • 548 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.useDepthLimit = void 0;
const tslib_1 = require("tslib");
const graphql_depth_limit_1 = tslib_1.__importDefault(require("graphql-depth-limit"));
const useDepthLimit = (config) => {
const ignore = config.ignore || [];
const checkFn = (0, graphql_depth_limit_1.default)(config.maxDepth, { ignore });
return {
onValidate({ addValidationRule }) {
addValidationRule(checkFn);
},
};
};
exports.useDepthLimit = useDepthLimit;
;