@graphql-tools/graphql
Version:
Fork of GraphQL.js
63 lines (62 loc) • 3.19 kB
text/typescript
import type { Maybe } from '../jsutils/Maybe.cjs';
import type { GraphQLError } from '../error/GraphQLError.cjs';
import type { DocumentNode, FragmentDefinitionNode, FragmentSpreadNode, OperationDefinitionNode, SelectionSetNode, VariableNode } from '../language/ast.cjs';
import type { ASTVisitor } from '../language/visitor.cjs';
import type { GraphQLArgument, GraphQLCompositeType, GraphQLEnumValue, GraphQLField, GraphQLInputType, GraphQLOutputType } from '../type/definition.cjs';
import type { GraphQLDirective } from '../type/directives.cjs';
import type { GraphQLSchema } from '../type/schema.cjs';
import { TypeInfo } from '../utilities/TypeInfo.cjs';
declare type NodeWithSelectionSet = OperationDefinitionNode | FragmentDefinitionNode;
interface VariableUsage {
readonly node: VariableNode;
readonly type: Maybe<GraphQLInputType>;
readonly defaultValue: Maybe<unknown>;
}
/**
* An instance of this class is passed as the "this" context to all validators,
* allowing access to commonly useful contextual information from within a
* validation rule.
*/
export declare class ASTValidationContext {
private _ast;
private _onError;
private _fragments;
private _fragmentSpreads;
private _recursivelyReferencedFragments;
constructor(ast: DocumentNode, onError: (error: GraphQLError) => void);
get [Symbol.toStringTag](): string;
reportError(error: GraphQLError): void;
getDocument(): DocumentNode;
getFragment(name: string): Maybe<FragmentDefinitionNode>;
getFragmentSpreads(node: SelectionSetNode): ReadonlyArray<FragmentSpreadNode>;
getRecursivelyReferencedFragments(operation: OperationDefinitionNode): ReadonlyArray<FragmentDefinitionNode>;
}
export declare type ASTValidationRule = (context: ASTValidationContext) => ASTVisitor;
export declare class SDLValidationContext extends ASTValidationContext {
private _schema;
constructor(ast: DocumentNode, schema: Maybe<GraphQLSchema>, onError: (error: GraphQLError) => void);
get [Symbol.toStringTag](): string;
getSchema(): Maybe<GraphQLSchema>;
}
export declare type SDLValidationRule = (context: SDLValidationContext) => ASTVisitor;
export declare class ValidationContext extends ASTValidationContext {
private _schema;
private _typeInfo;
private _variableUsages;
private _recursiveVariableUsages;
constructor(schema: GraphQLSchema, ast: DocumentNode, typeInfo: TypeInfo, onError: (error: GraphQLError) => void);
get [Symbol.toStringTag](): string;
getSchema(): GraphQLSchema;
getVariableUsages(node: NodeWithSelectionSet): ReadonlyArray<VariableUsage>;
getRecursiveVariableUsages(operation: OperationDefinitionNode): ReadonlyArray<VariableUsage>;
getType(): Maybe<GraphQLOutputType>;
getParentType(): Maybe<GraphQLCompositeType>;
getInputType(): Maybe<GraphQLInputType>;
getParentInputType(): Maybe<GraphQLInputType>;
getFieldDef(): Maybe<GraphQLField<unknown, unknown>>;
getDirective(): Maybe<GraphQLDirective>;
getArgument(): Maybe<GraphQLArgument>;
getEnumValue(): Maybe<GraphQLEnumValue>;
}
export declare type ValidationRule = (context: ValidationContext) => ASTVisitor;
export {};