Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sgqlc/endpoint/httpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class HTTPXEndpoint(HTTPEndpoint):
:errors: list of errors, which are objects with the key "message" and
optionally others, such as "location" (for errors matching GraphQL
input). Instead of raising exceptions, such as
:exc:`requests.exceptions.HTTPError` or
:exc:`requests.exceptions.HTTPStatusError` or
:exc:`json.JSONDecodeError` those are stored in the
"exception" key.

Expand Down Expand Up @@ -152,7 +152,7 @@ async def runner():
try:
response = await self.client.send(req)
return self._parse_httpx_response(query, response)
except httpx.HTTPError as exc:
except httpx.HTTPStatusError as exc:
return self._log_httpx_error(query, req, exc)

return runner()
Expand Down
9 changes: 8 additions & 1 deletion tests/test-endpoint-httpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ def test_server_http_non_conforming_json(respx_mock):
check_respx_route(route)


def test_server_http_transport_error(respx_mock):
async def test_server_http_transport_error(respx_mock):
'Test if a transport error will get passed back to the caller'

route = respx_mock.route(name='graphql', method='POST', url=test_url).mock(
Expand All @@ -566,6 +566,13 @@ def test_server_http_transport_error(respx_mock):

check_respx_route(route)

endpoint = HTTPXEndpoint(test_url, client=httpx.AsyncClient())

with pytest.raises(httpx.RemoteProtocolError):
await endpoint(graphql_query)

check_respx_route(route)


def test_server_error_broken_json(respx_mock):
'Test if HTTP error with broken JSON payload is handled'
Expand Down