UNPKG

@graphql-eslint/eslint-plugin

Version:

GraphQL plugin for ESLint

21 lines (17 loc) • 982 B
import { DocumentNode, SelectionNode, FragmentDefinitionNode, OperationDefinitionNode } from 'graphql'; /** * Port of `graphql-depth-limit` (MIT, https://github.com/stems/graphql-depth-limit). * * The original package is no longer maintained and reports via `new GraphQLError(message, [node])`, * a signature removed in graphql v17 (the error then has no `locations`). This port reports the * offending AST node directly instead, which works with every graphql version. */ type DepthNode = SelectionNode | FragmentDefinitionNode | OperationDefinitionNode; type DepthLimitOptions = { maxDepth: number; /** Stops recursive depth checking for matching field names, strings are used as RegExp */ ignore: ReadonlyArray<string | RegExp | ((fieldName: string) => boolean)>; onDepthExceeded: (node: DepthNode, operationName: string) => void; }; declare function checkDepthLimit(document: DocumentNode, options: DepthLimitOptions): void; export { checkDepthLimit };