Skip to content

Commit 2190059

Browse files
committed
Don't execute on GET for GraphiQL
We can also now return GraphiQL earlier in the request handling.
1 parent 9351626 commit 2190059

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

graphene_django/views.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ def dispatch(self, request, *args, **kwargs):
124124
data = self.parse_body(request)
125125
show_graphiql = self.graphiql and self.can_display_graphiql(request, data)
126126

127+
if show_graphiql:
128+
return self.render_graphiql(
129+
request,
130+
graphiql_version=self.graphiql_version,
131+
)
132+
127133
if self.batch:
128134
responses = [self.get_response(request, entry) for entry in data]
129135
result = "[{}]".format(
@@ -137,19 +143,6 @@ def dispatch(self, request, *args, **kwargs):
137143
else:
138144
result, status_code = self.get_response(request, data, show_graphiql)
139145

140-
if show_graphiql:
141-
query, variables, operation_name, id = self.get_graphql_params(
142-
request, data
143-
)
144-
return self.render_graphiql(
145-
request,
146-
graphiql_version=self.graphiql_version,
147-
query=query or "",
148-
variables=json.dumps(variables) or "",
149-
operation_name=operation_name or "",
150-
result=result or "",
151-
)
152-
153146
return HttpResponse(
154147
status=status_code, content=result, content_type="application/json"
155148
)

0 commit comments

Comments
 (0)