From 5b7ef345234bbfbb55ea72522c6b0b9ef7f55960 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sun, 14 Oct 2018 20:40:31 -0400 Subject: [PATCH] fix #45 --- responder/api.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/responder/api.py b/responder/api.py index 7931715..434ebe8 100644 --- a/responder/api.py +++ b/responder/api.py @@ -109,7 +109,7 @@ class API: try: # GraphQL Schema. assert hasattr(view, "execute") - self.graphql_response(req, resp, schema=view) + await self.graphql_response(req, resp, schema=view) except AssertionError: # WSGI App. # try: @@ -175,9 +175,9 @@ class API: resp.headers.update({"Location": location}) @staticmethod - def _resolve_graphql_query(req): + async def _resolve_graphql_query(req): if "json" in req.mimetype: - return req.json()["query"] + return await req.media("json")["query"] # Support query/q in form data. # Form data is awaiting https://github.com/encode/starlette/pull/102 @@ -196,8 +196,8 @@ class API: # TODO: Make some assertions about content-type here. return req.text - def graphql_response(self, req, resp, schema): - query = self._resolve_graphql_query(req) + async def graphql_response(self, req, resp, schema): + query = await self._resolve_graphql_query(req) result = schema.execute(query) result, status_code = encode_execution_results( [result],