@@ -115,25 +115,26 @@ def validate_root_types(self) -> None:
115
115
elif not is_object_type (query_type ):
116
116
self .report_error (
117
117
f"Query root type must be Object type, it cannot be { query_type } ." ,
118
- get_operation_type_node (schema , query_type , OperationType .QUERY ),
118
+ get_operation_type_node (schema , OperationType .QUERY )
119
+ or query_type .ast_node ,
119
120
)
120
121
121
122
mutation_type = schema .mutation_type
122
123
if mutation_type and not is_object_type (mutation_type ):
123
124
self .report_error (
124
125
"Mutation root type must be Object type if provided,"
125
126
f" it cannot be { mutation_type } ." ,
126
- get_operation_type_node (schema , mutation_type , OperationType .MUTATION ),
127
+ get_operation_type_node (schema , OperationType .MUTATION )
128
+ or mutation_type .ast_node ,
127
129
)
128
130
129
131
subscription_type = schema .subscription_type
130
132
if subscription_type and not is_object_type (subscription_type ):
131
133
self .report_error (
132
134
"Subscription root type must be Object type if provided,"
133
135
f" it cannot be { subscription_type } ." ,
134
- get_operation_type_node (
135
- schema , subscription_type , OperationType .SUBSCRIPTION
136
- ),
136
+ get_operation_type_node (schema , OperationType .SUBSCRIPTION )
137
+ or subscription_type .ast_node ,
137
138
)
138
139
139
140
def validate_directives (self ) -> None :
@@ -458,7 +459,7 @@ def validate_input_fields(self, input_obj: GraphQLInputObjectType) -> None:
458
459
459
460
460
461
def get_operation_type_node (
461
- schema : GraphQLSchema , type_ : GraphQLObjectType , operation : OperationType
462
+ schema : GraphQLSchema , operation : OperationType
462
463
) -> Optional [Node ]:
463
464
operation_nodes = cast (
464
465
List [OperationTypeDefinitionNode ],
@@ -467,7 +468,7 @@ def get_operation_type_node(
467
468
for node in operation_nodes :
468
469
if node .operation == operation :
469
470
return node .type
470
- return type_ . ast_node
471
+ return None
471
472
472
473
473
474
class InputObjectCircularRefsValidator :
0 commit comments