@@ -81,18 +81,20 @@ def dispatch_request(self):
81
81
)
82
82
83
83
data = self .parse_body (request )
84
+ is_batch = isinstance (data , list )
84
85
85
- show_graphiql = self .graphiql and self .can_display_graphiql (data )
86
+ show_graphiql = not is_batch and self .graphiql and self .can_display_graphiql (data )
86
87
87
- is_batch = isinstance (data , list )
88
- if is_batch :
89
- if not self .batch or show_graphiql :
90
- raise HttpError (
91
- 400 ,
92
- 'Batch requests are not allowed.'
93
- )
94
- else :
88
+ if not is_batch :
89
+ # print data
90
+ data = dict (data , ** request .args .to_dict ())
95
91
data = [data ]
92
+ elif not self .batch :
93
+ raise HttpError (
94
+ 400 ,
95
+ 'Batch requests are not allowed.'
96
+ )
97
+
96
98
responses = [self .get_response (request , entry , show_graphiql ) for entry in data ]
97
99
response , status_codes = zip (* responses )
98
100
status_code = max (status_codes )
@@ -185,10 +187,10 @@ def parse_body(self, request):
185
187
)
186
188
187
189
elif content_type == 'application/x-www-form-urlencoded' :
188
- return request .form
190
+ return request .form . to_dict ()
189
191
190
192
elif content_type == 'multipart/form-data' :
191
- return request .form
193
+ return request .form . to_dict ()
192
194
193
195
return {}
194
196
@@ -254,8 +256,8 @@ def request_wants_html(cls, request):
254
256
255
257
@staticmethod
256
258
def get_graphql_params (request , data ):
257
- query = request . args . get ( 'query' ) or data .get ('query' )
258
- variables = request . args . get ( 'variables' ) or data .get ('variables' )
259
+ query = data .get ('query' )
260
+ variables = data .get ('variables' )
259
261
id = data .get ('id' )
260
262
261
263
if variables and isinstance (variables , six .text_type ):
@@ -264,7 +266,7 @@ def get_graphql_params(request, data):
264
266
except :
265
267
raise HttpError (400 , 'Variables are invalid JSON.' )
266
268
267
- operation_name = request . args . get ( 'operationName' ) or data .get ('operationName' )
269
+ operation_name = data .get ('operationName' )
268
270
269
271
return query , variables , operation_name , id
270
272
0 commit comments