gqlcheck
Version:
Performs additional checks on your GraphQL documents and operations to ensure they conform to your rules, whilst allow-listing existing operations and their constituent parts (and allowing overrides on a per-field basis). Rules include max selection set d
33 lines (32 loc) • 2.02 kB
TypeScript
import type { ASTNode, DocumentNode, FragmentDefinitionNode, FragmentSpreadNode, GraphQLError, GraphQLSchema, OperationDefinitionNode } from "graphql";
import * as graphqlLibrary from "graphql";
import { ValidationContext } from "graphql";
import type { CheckDocumentOutput, ErrorOperationLocation } from "./interfaces";
import type { TypeAndOperationPathInfo } from "./operationPaths";
import type { RuleError } from "./ruleError";
export declare class RulesContext extends ValidationContext {
private typeInfo;
private resolvedPreset;
graphqlLibrary: typeof graphqlLibrary;
constructor(schema: GraphQLSchema, ast: DocumentNode, typeInfo: TypeAndOperationPathInfo, resolvedPreset: GraphileConfig.ResolvedPreset, onError: (error: RuleError | GraphQLError) => void);
_meta: CheckDocumentOutput["meta"];
addMeta<TKey extends keyof CheckDocumentOutput["meta"]>(key: TKey, value: CheckDocumentOutput["meta"][TKey]): void;
getMeta(): {
count?: import("./interfaces").CheckDocumentCounts;
};
getTypeInfo(): TypeAndOperationPathInfo;
getOperationPath(): string;
getResolvedPreset(): GraphileConfig.ResolvedPreset;
isIntrospection(): boolean;
subPathByNode: Map<ASTNode, string>;
operationPathsByNodeByOperation: Map<OperationDefinitionNode, Map<ASTNode, string[]>>;
operationNamesByNode: Map<ASTNode, (string | undefined)[]>;
_fragmentsByRoot: Map<OperationDefinitionNode | FragmentDefinitionNode, FragmentSpreadNode[]>;
_nodesByRoot: Map<OperationDefinitionNode | FragmentDefinitionNode, ASTNode[]>;
_operationDefinitions: OperationDefinitionNode[];
_fragmentDefinitions: FragmentDefinitionNode[];
initEnterNode(node: ASTNode): void;
initLeaveNode(node: ASTNode): void;
getOperationNamesForNodes(nodes: readonly ASTNode[] | undefined): (string | undefined)[];
getErrorOperationLocationsForNodes(nodes: readonly ASTNode[] | undefined, limitToOperations?: ReadonlyArray<string | undefined>): ReadonlyArray<ErrorOperationLocation>;
}