@@ -67,51 +67,14 @@ class ASTValidationContext:
67
67
def __init__ (self , ast : DocumentNode ) -> None :
68
68
self .document = ast
69
69
self .errors = []
70
-
71
- def report_error (self , error : GraphQLError ):
72
- self .errors .append (error )
73
-
74
-
75
- class SDLValidationContext (ASTValidationContext ):
76
- """Utility class providing a context for validation of an SDL ast.
77
-
78
- An instance of this class is passed as the context attribute to all Validators,
79
- allowing access to commonly useful contextual information from within a validation
80
- rule.
81
- """
82
-
83
- schema : Optional [GraphQLSchema ]
84
-
85
- def __init__ (self , ast : DocumentNode , schema : GraphQLSchema = None ) -> None :
86
- super ().__init__ (ast )
87
- self .schema = schema
88
-
89
-
90
- class ValidationContext (ASTValidationContext ):
91
- """Utility class providing a context for validation using a GraphQL schema.
92
-
93
- An instance of this class is passed as the context attribute to all Validators,
94
- allowing access to commonly useful contextual information from within a validation
95
- rule.
96
- """
97
-
98
- schema : GraphQLSchema
99
-
100
- def __init__ (
101
- self , schema : GraphQLSchema , ast : DocumentNode , type_info : TypeInfo
102
- ) -> None :
103
- super ().__init__ (ast )
104
- self .schema = schema
105
- self ._type_info = type_info
106
70
self ._fragments : Optional [Dict [str , FragmentDefinitionNode ]] = None
107
71
self ._fragment_spreads : Dict [SelectionSetNode , List [FragmentSpreadNode ]] = {}
108
72
self ._recursively_referenced_fragments : Dict [
109
73
OperationDefinitionNode , List [FragmentDefinitionNode ]
110
74
] = {}
111
- self ._variable_usages : Dict [NodeWithSelectionSet , List [VariableUsage ]] = {}
112
- self ._recursive_variable_usages : Dict [
113
- OperationDefinitionNode , List [VariableUsage ]
114
- ] = {}
75
+
76
+ def report_error (self , error : GraphQLError ):
77
+ self .errors .append (error )
115
78
116
79
def get_fragment (self , name : str ) -> Optional [FragmentDefinitionNode ]:
117
80
fragments = self ._fragments
@@ -172,6 +135,43 @@ def get_recursively_referenced_fragments(
172
135
self ._recursively_referenced_fragments [operation ] = fragments
173
136
return fragments
174
137
138
+
139
+ class SDLValidationContext (ASTValidationContext ):
140
+ """Utility class providing a context for validation of an SDL ast.
141
+
142
+ An instance of this class is passed as the context attribute to all Validators,
143
+ allowing access to commonly useful contextual information from within a validation
144
+ rule.
145
+ """
146
+
147
+ schema : Optional [GraphQLSchema ]
148
+
149
+ def __init__ (self , ast : DocumentNode , schema : GraphQLSchema = None ) -> None :
150
+ super ().__init__ (ast )
151
+ self .schema = schema
152
+
153
+
154
+ class ValidationContext (ASTValidationContext ):
155
+ """Utility class providing a context for validation using a GraphQL schema.
156
+
157
+ An instance of this class is passed as the context attribute to all Validators,
158
+ allowing access to commonly useful contextual information from within a validation
159
+ rule.
160
+ """
161
+
162
+ schema : GraphQLSchema
163
+
164
+ def __init__ (
165
+ self , schema : GraphQLSchema , ast : DocumentNode , type_info : TypeInfo
166
+ ) -> None :
167
+ super ().__init__ (ast )
168
+ self .schema = schema
169
+ self ._type_info = type_info
170
+ self ._variable_usages : Dict [NodeWithSelectionSet , List [VariableUsage ]] = {}
171
+ self ._recursive_variable_usages : Dict [
172
+ OperationDefinitionNode , List [VariableUsage ]
173
+ ] = {}
174
+
175
175
def get_variable_usages (self , node : NodeWithSelectionSet ) -> List [VariableUsage ]:
176
176
usages = self ._variable_usages .get (node )
177
177
if usages is None :
0 commit comments