UNPKG

@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).

11 lines (10 loc) 308 B
import depthLimit from 'graphql-depth-limit'; export const useDepthLimit = (config) => { const ignore = config.ignore || []; const checkFn = depthLimit(config.maxDepth, { ignore }); return { onValidate({ addValidationRule }) { addValidationRule(checkFn); }, }; };