Skip to content

Commit 7992721

Browse files
authored
AIOHTTPTransport ignore backend mimetype (#248)
1 parent 3db7a86 commit 7992721

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

gql/transport/aiohttp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ async def raise_response_error(resp: aiohttp.ClientResponse, reason: str):
225225
)
226226

227227
try:
228-
result = await resp.json()
228+
result = await resp.json(content_type=None)
229229

230230
if log.isEnabledFor(logging.INFO):
231231
result_text = await resp.text()

tests/test_aiohttp.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,35 @@ async def handler(request):
6969
assert africa["code"] == "AF"
7070

7171

72+
@pytest.mark.asyncio
73+
async def test_aiohttp_ignore_backend_content_type(event_loop, aiohttp_server):
74+
from aiohttp import web
75+
from gql.transport.aiohttp import AIOHTTPTransport
76+
77+
async def handler(request):
78+
return web.Response(text=query1_server_answer, content_type="text/plain")
79+
80+
app = web.Application()
81+
app.router.add_route("POST", "/", handler)
82+
server = await aiohttp_server(app)
83+
84+
url = server.make_url("/")
85+
86+
sample_transport = AIOHTTPTransport(url=url, timeout=10)
87+
88+
async with Client(transport=sample_transport,) as session:
89+
90+
query = gql(query1_str)
91+
92+
result = await session.execute(query)
93+
94+
continents = result["continents"]
95+
96+
africa = continents[0]
97+
98+
assert africa["code"] == "AF"
99+
100+
72101
@pytest.mark.asyncio
73102
async def test_aiohttp_cookies(event_loop, aiohttp_server):
74103
from aiohttp import web

0 commit comments

Comments
 (0)