44import  re 
55
66import  six 
7+ from  graphql  import  DirectiveNode 
8+ from  graphql  import  DocumentNode 
9+ from  graphql  import  FieldNode 
10+ from  graphql  import  FloatValueNode 
11+ from  graphql  import  FragmentDefinitionNode 
12+ from  graphql  import  FragmentSpreadNode 
13+ from  graphql  import  InlineFragmentNode 
14+ from  graphql  import  IntValueNode 
15+ from  graphql  import  ListValueNode 
16+ from  graphql  import  ObjectValueNode 
17+ from  graphql  import  OperationDefinitionNode 
718
819from  graphql  import  print_ast 
9- from  graphql .language .ast  import  Document , IntValue , FloatValue , StringValue , ListValue , ObjectValue , Field , \
10-     Directive , FragmentDefinition , InlineFragment , FragmentSpread , SelectionSet , OperationDefinition 
20+ from  graphql  import  SelectionSetNode 
21+ from  graphql  import  separate_operations 
22+ from  graphql  import  StringValueNode 
1123from  graphql .language .visitor  import  Visitor , visit 
1224
13- from  graphene_tornado .apollo_tooling .seperate_operations  import  separate_operations 
1425
15- 
16- def  hide_literals (ast : Document ) ->  Document :
26+ def  hide_literals (ast : DocumentNode ) ->  DocumentNode :
1727    """ 
1828    Replace numeric, string, list, and object literals with "empty" 
1929    values. Leaves enums alone (since there's no consistent "zero" enum). This 
@@ -26,7 +36,7 @@ def hide_literals(ast: Document) -> Document:
2636    return  ast 
2737
2838
29- def  hide_string_and_numeric_literals (ast : Document ) ->  Document :
39+ def  hide_string_and_numeric_literals (ast : DocumentNode ) ->  DocumentNode :
3040    """ 
3141    In the same spirit as the similarly named `hideLiterals` function, only 
3242    hide string and numeric literals. 
@@ -35,7 +45,7 @@ def hide_string_and_numeric_literals(ast: Document) -> Document:
3545    return  ast 
3646
3747
38- def  drop_unused_definitions (ast : Document , operation_name : str ) ->  Document :
48+ def  drop_unused_definitions (ast : DocumentNode , operation_name : str ) ->  DocumentNode :
3949    """ 
4050    A GraphQL query may contain multiple named operations, with the operation to 
4151    use specified separately by the client. This transformation drops unused 
@@ -49,7 +59,7 @@ def drop_unused_definitions(ast: Document, operation_name: str) -> Document:
4959    return  separated 
5060
5161
52- def  sort_ast (ast : Document ) ->  Document :
62+ def  sort_ast (ast : DocumentNode ) ->  DocumentNode :
5363    """ 
5464    sortAST sorts most multi-child nodes alphabetically. Using this as part of 
5565    your signature calculation function may make it easier to tell the difference 
@@ -61,7 +71,7 @@ def sort_ast(ast: Document) -> Document:
6171    return  ast 
6272
6373
64- def  remove_aliases (ast : Document ) ->  Document :
74+ def  remove_aliases (ast : DocumentNode ) ->  DocumentNode :
6575    """ 
6676    removeAliases gets rid of GraphQL aliases, a feature by which you can tell a 
6777    server to return a field's data under a different name from the field 
@@ -72,7 +82,7 @@ def remove_aliases(ast: Document) -> Document:
7282    return  ast 
7383
7484
75- def  print_with_reduced_whitespace (ast : Document ) ->  str :
85+ def  print_with_reduced_whitespace (ast : DocumentNode ) ->  str :
7686    """ 
7787    Like the graphql-js print function, but deleting whitespace wherever 
7888    feasible. Specifically, all whitespace (outside of string literals) is 
@@ -115,15 +125,15 @@ def __init__(self, only_string_and_numeric=False):
115125        self ._only_string_and_numeric  =  only_string_and_numeric 
116126
117127    def  enter (self , node , key , parent , path , ancestors ):
118-         if  isinstance (node , IntValue ):
128+         if  isinstance (node , IntValueNode ):
119129            node .value  =  0 
120-         elif  isinstance (node , FloatValue ):
130+         elif  isinstance (node , FloatValueNode ):
121131            node .value  =  0 
122-         elif  isinstance (node , StringValue ):
132+         elif  isinstance (node , StringValueNode ):
123133            node .value  =  "" 
124-         elif  not  self ._only_string_and_numeric  and  isinstance (node , ListValue ):
134+         elif  not  self ._only_string_and_numeric  and  isinstance (node , ListValueNode ):
125135            node .values  =  []
126-         elif  not  self ._only_string_and_numeric  and  isinstance (node , ObjectValue ):
136+         elif  not  self ._only_string_and_numeric  and  isinstance (node , ObjectValueNode ):
127137            node .fields  =  []
128138        return  node 
129139
@@ -135,7 +145,7 @@ def enter(self, node, key, parent, path, ancestors):
135145class  _RemoveAliasesVisitor (Visitor ):
136146
137147    def  enter (self , node , key , parent , path , ancestors ):
138-         if  isinstance (node , Field ):
148+         if  isinstance (node , FieldNode ):
139149           node .alias  =  None 
140150        return  node 
141151
@@ -146,7 +156,7 @@ def enter(self, node, key, parent, path, ancestors):
146156class  _HexConversionVisitor (Visitor ):
147157
148158    def  enter (self , node , key , parent , path , ancestors ):
149-         if  isinstance (node , StringValue ) and  node .value  is  not None :
159+         if  isinstance (node , StringValueNode ) and  node .value  is  not None :
150160            if  six .PY3 :
151161                encoded  =  node .value .encode ('utf-8' ).hex ()
152162            else :
@@ -161,26 +171,26 @@ def enter(self, node, key, parent, path, ancestors):
161171class  _SortingVisitor (Visitor ):
162172
163173    def  enter (self , node , key , parent , path , ancestors ):
164-         if  isinstance (node , Document ):
174+         if  isinstance (node , DocumentNode ):
165175            node .definitions  =  _sorted (node .definitions , lambda  x : (x .__class__ .__name__ , self ._by_name (x )))
166-         elif  isinstance (node , OperationDefinition ):
176+         elif  isinstance (node , OperationDefinitionNode ):
167177            node .variable_definitions  =  _sorted (node .variable_definitions , self ._by_variable_name )
168-         elif  isinstance (node , SelectionSet ):
178+         elif  isinstance (node , SelectionSetNode ):
169179            node .selections  =  _sorted (node .selections , lambda  x : (x .__class__ .__name__ , self ._by_name (x )))
170-         elif  isinstance (node , Field ):
180+         elif  isinstance (node , FieldNode ):
171181            node .arguments  =  _sorted (node .arguments , self ._by_name )
172-         elif  isinstance (node , FragmentSpread ):
182+         elif  isinstance (node , FragmentSpreadNode ):
173183            node .directives  =  _sorted (node .directives , self ._by_name )
174-         elif  isinstance (node , InlineFragment ):
184+         elif  isinstance (node , InlineFragmentNode ):
175185            node .directives  =  _sorted (node .directives , self ._by_type_definition )
176-         elif  isinstance (node , FragmentDefinition ):
186+         elif  isinstance (node , FragmentDefinitionNode ):
177187            node .directives  =  _sorted (node .directives , self ._by_name )
178-         elif  isinstance (node , Directive ):
188+         elif  isinstance (node , DirectiveNode ):
179189            node .arguments  =  _sorted (node .arguments , self ._by_name )
180190        return  node 
181191
182192    def  _by_name (self , node ):
183-         if  isinstance (node , InlineFragment ):
193+         if  isinstance (node , InlineFragmentNode ):
184194            return  self ._by_type_definition (node )
185195        elif  node .name  is  not None :
186196            return  node .name .value 
0 commit comments