@@ -236,23 +236,23 @@ def get_response(
236
236
if not params .query :
237
237
raise HttpQueryError (400 , "Must provide query string." )
238
238
239
- # Parse document to trigger a new HttpQueryError if allow_only_query is True
240
- try :
241
- document = parse (params .query )
242
- except GraphQLError as e :
243
- return ExecutionResult (data = None , errors = [e ])
244
- except Exception as e :
245
- e = GraphQLError (str (e ), original_error = e )
246
- return ExecutionResult (data = None , errors = [e ])
247
-
248
239
if allow_only_query :
240
+ # Parse document to check that only query operations are used
241
+ try :
242
+ document = parse (params .query )
243
+ except GraphQLError as e :
244
+ return ExecutionResult (data = None , errors = [e ])
245
+ except Exception as e :
246
+ e = GraphQLError (str (e ), original_error = e )
247
+ return ExecutionResult (data = None , errors = [e ])
249
248
operation_ast = get_operation_ast (document , params .operation_name )
250
249
if operation_ast :
251
250
operation = operation_ast .operation .value
252
251
if operation != OperationType .QUERY .value :
253
252
raise HttpQueryError (
254
253
405 ,
255
- f"Can only perform a { operation } operation from a POST request." , # noqa
254
+ f"Can only perform a { operation } operation"
255
+ " from a POST request." ,
256
256
headers = {"Allow" : "POST" },
257
257
)
258
258
0 commit comments