1 | import Maybe from "../tsutils/Maybe";
|
2 | import { GraphQLError } from "../error";
|
3 | import {
|
4 | DocumentNode,
|
5 | OperationDefinitionNode,
|
6 | VariableNode,
|
7 | SelectionSetNode,
|
8 | FragmentSpreadNode,
|
9 | FragmentDefinitionNode,
|
10 | } from "../language/ast";
|
11 | import { GraphQLSchema } from "../type/schema";
|
12 | import {
|
13 | GraphQLInputType,
|
14 | GraphQLOutputType,
|
15 | GraphQLCompositeType,
|
16 | GraphQLField,
|
17 | GraphQLArgument,
|
18 | } from "../type/definition";
|
19 | import { GraphQLDirective } from "../type/directives";
|
20 | import { TypeInfo } from "../utilities/TypeInfo";
|
21 | import { ASTVisitor } from "../language/visitor";
|
22 |
|
23 | type NodeWithSelectionSet = OperationDefinitionNode | FragmentDefinitionNode;
|
24 | type VariableUsage = {
|
25 | readonly node: VariableNode;
|
26 | readonly type: Maybe<GraphQLInputType>;
|
27 | readonly defaultValue: Maybe<any>;
|
28 | };
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 | export class ASTValidationContext {
|
36 | constructor(ast: DocumentNode);
|
37 |
|
38 | reportError(error: GraphQLError): undefined;
|
39 |
|
40 | getErrors(): ReadonlyArray<GraphQLError>;
|
41 |
|
42 | getDocument(): DocumentNode;
|
43 | }
|
44 |
|
45 | export class SDLValidationContext extends ASTValidationContext {
|
46 | constructor(ast: DocumentNode, schema?: Maybe<GraphQLSchema>);
|
47 |
|
48 | getSchema(): Maybe<GraphQLSchema>;
|
49 | }
|
50 |
|
51 | export type SDLValidationRule = (context: SDLValidationContext) => ASTVisitor;
|
52 |
|
53 | export class ValidationContext extends ASTValidationContext {
|
54 | constructor(schema: GraphQLSchema, ast: DocumentNode, typeInfo: TypeInfo);
|
55 |
|
56 | getSchema(): GraphQLSchema;
|
57 |
|
58 | getFragment(name: string): Maybe<FragmentDefinitionNode>;
|
59 |
|
60 | getFragmentSpreads(node: SelectionSetNode): ReadonlyArray<FragmentSpreadNode>;
|
61 |
|
62 | getRecursivelyReferencedFragments(operation: OperationDefinitionNode): ReadonlyArray<FragmentDefinitionNode>;
|
63 |
|
64 | getVariableUsages(node: NodeWithSelectionSet): ReadonlyArray<VariableUsage>;
|
65 |
|
66 | getRecursiveVariableUsages(operation: OperationDefinitionNode): ReadonlyArray<VariableUsage>;
|
67 |
|
68 | getType(): Maybe<GraphQLOutputType>;
|
69 |
|
70 | getParentType(): Maybe<GraphQLCompositeType>;
|
71 |
|
72 | getInputType(): Maybe<GraphQLInputType>;
|
73 |
|
74 | getParentInputType(): Maybe<GraphQLInputType>;
|
75 |
|
76 | getFieldDef(): Maybe<GraphQLField<any, any>>;
|
77 |
|
78 | getDirective(): Maybe<GraphQLDirective>;
|
79 |
|
80 | getArgument(): Maybe<GraphQLArgument>;
|
81 | }
|
82 |
|
83 | export type ValidationRule = (context: ValidationContext) => ASTVisitor;
|