1
1
import Maybe from '../tsutils/Maybe' ;
2
2
import { GraphQLError } from '../error' ;
3
+ import { ASTVisitor } from '../language/visitor' ;
3
4
import {
4
5
DocumentNode ,
5
6
OperationDefinitionNode ,
@@ -9,16 +10,15 @@ import {
9
10
FragmentDefinitionNode ,
10
11
} from '../language/ast' ;
11
12
import { GraphQLSchema } from '../type/schema' ;
13
+ import { GraphQLDirective } from '../type/directives' ;
12
14
import {
13
15
GraphQLInputType ,
14
16
GraphQLOutputType ,
15
17
GraphQLCompositeType ,
16
18
GraphQLField ,
17
19
GraphQLArgument ,
18
20
} from '../type/definition' ;
19
- import { GraphQLDirective } from '../type/directives' ;
20
21
import { TypeInfo } from '../utilities/TypeInfo' ;
21
- import { ASTVisitor } from '../language/visitor' ;
22
22
23
23
type NodeWithSelectionSet = OperationDefinitionNode | FragmentDefinitionNode ;
24
24
type VariableUsage = {
@@ -40,35 +40,44 @@ export class ASTValidationContext {
40
40
getErrors ( ) : ReadonlyArray < GraphQLError > ;
41
41
42
42
getDocument ( ) : DocumentNode ;
43
+
44
+ getFragment ( name : string ) : Maybe < FragmentDefinitionNode > ;
45
+
46
+ getFragmentSpreads ( node : SelectionSetNode ) : ReadonlyArray < FragmentSpreadNode > ;
47
+
48
+ getRecursivelyReferencedFragments (
49
+ operation : OperationDefinitionNode ,
50
+ ) : ReadonlyArray < FragmentDefinitionNode > ;
43
51
}
44
52
45
53
export class SDLValidationContext extends ASTValidationContext {
46
- constructor ( ast : DocumentNode , schema ?: Maybe < GraphQLSchema > ) ;
54
+ constructor (
55
+ ast : DocumentNode ,
56
+ schema : Maybe < GraphQLSchema > ,
57
+ onError ?: ( err : GraphQLError ) => void ,
58
+ ) ;
47
59
48
60
getSchema ( ) : Maybe < GraphQLSchema > ;
49
61
}
50
62
51
63
export type SDLValidationRule = ( context : SDLValidationContext ) => ASTVisitor ;
52
64
53
65
export class ValidationContext extends ASTValidationContext {
54
- constructor ( schema : GraphQLSchema , ast : DocumentNode , typeInfo : TypeInfo ) ;
66
+ constructor (
67
+ schema : GraphQLSchema ,
68
+ ast : DocumentNode ,
69
+ typeInfo : TypeInfo ,
70
+ onError ?: ( err : GraphQLError ) => void ,
71
+ ) ;
55
72
56
73
getSchema ( ) : GraphQLSchema ;
57
74
58
- getFragment ( name : string ) : Maybe < FragmentDefinitionNode > ;
59
-
60
- getFragmentSpreads ( node : SelectionSetNode ) : ReadonlyArray < FragmentSpreadNode > ;
75
+ getVariableUsages ( node : NodeWithSelectionSet ) : ReadonlyArray < VariableUsage > ;
61
76
62
77
getRecursivelyReferencedFragments (
63
78
operation : OperationDefinitionNode ,
64
79
) : ReadonlyArray < FragmentDefinitionNode > ;
65
80
66
- getVariableUsages ( node : NodeWithSelectionSet ) : ReadonlyArray < VariableUsage > ;
67
-
68
- getRecursiveVariableUsages (
69
- operation : OperationDefinitionNode ,
70
- ) : ReadonlyArray < VariableUsage > ;
71
-
72
81
getType ( ) : Maybe < GraphQLOutputType > ;
73
82
74
83
getParentType ( ) : Maybe < GraphQLCompositeType > ;
0 commit comments