Skip to content

Commit

Permalink
Merge pull request #247 from mirumee/rename_invalid_response_error
Browse files Browse the repository at this point in the history
Rename invalid response error
  • Loading branch information
mat-sop authored Dec 4, 2023
2 parents a30d1b0 + 855e4ee commit 79ad7fc
Show file tree
Hide file tree
Showing 49 changed files with 98 additions and 97 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Added `include_all_enums` config flag to generate only enums used in supplied operations.
- Added `operationName` to payload sent by generated client's methods.
- Fixed base clients to pass `mypy --strict` without installed optional dependencies.
- Renamed `GraphQlClientInvalidResponseError` to `GraphQLClientInvalidResponseError` (breaking change).


## 0.10.0 (2023-11-15)
Expand Down
4 changes: 2 additions & 2 deletions EXAMPLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ from .exceptions import (
GraphQLClientGraphQLError,
GraphQLClientGraphQLMultiError,
GraphQLClientHttpError,
GraphQlClientInvalidResponseError,
GraphQLClientInvalidResponseError,
)
from .fragments import BasicUser, UserPersonalData
from .get_users_counter import GetUsersCounter
Expand All @@ -547,7 +547,7 @@ __all__ = [
"GraphQLClientGraphQLError",
"GraphQLClientGraphQLMultiError",
"GraphQLClientHttpError",
"GraphQlClientInvalidResponseError",
"GraphQLClientInvalidResponseError",
"ListAllUsers",
"ListAllUsersUsers",
"ListAllUsersUsersLocation",
Expand Down
2 changes: 1 addition & 1 deletion ariadne_codegen/client_generators/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
GRAPHQL_CLIENT_EXCEPTIONS_NAMES = [
"GraphQLClientError",
"GraphQLClientHttpError",
"GraphQlClientInvalidResponseError",
"GraphQLClientInvalidResponseError",
"GraphQLClientGraphQLError",
"GraphQLClientGraphQLMultiError",
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
GraphQLClientGraphQLMultiError,
GraphQLClientHttpError,
GraphQLClientInvalidMessageFormat,
GraphQlClientInvalidResponseError,
GraphQLClientInvalidResponseError,
)

try:
Expand Down Expand Up @@ -125,10 +125,10 @@ def get_data(self, response: httpx.Response) -> Dict[str, Any]:
try:
response_json = response.json()
except ValueError as exc:
raise GraphQlClientInvalidResponseError(response=response) from exc
raise GraphQLClientInvalidResponseError(response=response) from exc

if (not isinstance(response_json, dict)) or ("data" not in response_json):
raise GraphQlClientInvalidResponseError(response=response)
raise GraphQLClientInvalidResponseError(response=response)

data = response_json["data"]
errors = response_json.get("errors")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
GraphQLClientGraphQLMultiError,
GraphQLClientHttpError,
GraphQLClientInvalidMessageFormat,
GraphQlClientInvalidResponseError,
GraphQLClientInvalidResponseError,
)

try:
Expand Down Expand Up @@ -164,10 +164,10 @@ def get_data(self, response: httpx.Response) -> Dict[str, Any]:
try:
response_json = response.json()
except ValueError as exc:
raise GraphQlClientInvalidResponseError(response=response) from exc
raise GraphQLClientInvalidResponseError(response=response) from exc

if (not isinstance(response_json, dict)) or ("data" not in response_json):
raise GraphQlClientInvalidResponseError(response=response)
raise GraphQLClientInvalidResponseError(response=response)

data = response_json["data"]
errors = response_json.get("errors")
Expand Down
6 changes: 3 additions & 3 deletions ariadne_codegen/client_generators/dependencies/base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from .exceptions import (
GraphQLClientGraphQLMultiError,
GraphQLClientHttpError,
GraphQlClientInvalidResponseError,
GraphQLClientInvalidResponseError,
)

Self = TypeVar("Self", bound="BaseClient")
Expand Down Expand Up @@ -73,10 +73,10 @@ def get_data(self, response: httpx.Response) -> dict[str, Any]:
try:
response_json = response.json()
except ValueError as exc:
raise GraphQlClientInvalidResponseError(response=response) from exc
raise GraphQLClientInvalidResponseError(response=response) from exc

if (not isinstance(response_json, dict)) or ("data" not in response_json):
raise GraphQlClientInvalidResponseError(response=response)
raise GraphQLClientInvalidResponseError(response=response)

data = response_json["data"]
errors = response_json.get("errors")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from .exceptions import (
GraphQLClientGraphQLMultiError,
GraphQLClientHttpError,
GraphQlClientInvalidResponseError,
GraphQLClientInvalidResponseError,
)

try:
Expand Down Expand Up @@ -96,10 +96,10 @@ def get_data(self, response: httpx.Response) -> dict[str, Any]:
try:
response_json = response.json()
except ValueError as exc:
raise GraphQlClientInvalidResponseError(response=response) from exc
raise GraphQLClientInvalidResponseError(response=response) from exc

if (not isinstance(response_json, dict)) or ("data" not in response_json):
raise GraphQlClientInvalidResponseError(response=response)
raise GraphQLClientInvalidResponseError(response=response)

data = response_json["data"]
errors = response_json.get("errors")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __str__(self) -> str:
return f"HTTP status code: {self.status_code}"


class GraphQlClientInvalidResponseError(GraphQLClientError):
class GraphQLClientInvalidResponseError(GraphQLClientError):
def __init__(self, response: httpx.Response) -> None:
self.response = response

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from ariadne_codegen.client_generators.dependencies.exceptions import (
GraphQLClientGraphQLMultiError,
GraphQLClientHttpError,
GraphQlClientInvalidResponseError,
GraphQLClientInvalidResponseError,
)

from ...utils import decode_multipart_request
Expand Down Expand Up @@ -513,7 +513,7 @@ def test_get_data_raises_graphql_client_invalid_response_error(
client = AsyncBaseClient(url="base_url", http_client=mocker.MagicMock())
response = httpx.Response(status_code=200, content=json.dumps(response_content))

with pytest.raises(GraphQlClientInvalidResponseError) as exc:
with pytest.raises(GraphQLClientInvalidResponseError) as exc:
client.get_data(response)
assert exc.response == response

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from ariadne_codegen.client_generators.dependencies.exceptions import (
GraphQLClientGraphQLMultiError,
GraphQLClientHttpError,
GraphQlClientInvalidResponseError,
GraphQLClientInvalidResponseError,
)

from ...utils import decode_multipart_request
Expand Down Expand Up @@ -530,7 +530,7 @@ def test_get_data_raises_graphql_client_invalid_response_error(
)
response = httpx.Response(status_code=200, content=json.dumps(response_content))

with pytest.raises(GraphQlClientInvalidResponseError) as exc:
with pytest.raises(GraphQLClientInvalidResponseError) as exc:
client.get_data(response)
assert exc.response == response

Expand Down
4 changes: 2 additions & 2 deletions tests/client_generators/dependencies/test_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from ariadne_codegen.client_generators.dependencies.exceptions import (
GraphQLClientGraphQLMultiError,
GraphQLClientHttpError,
GraphQlClientInvalidResponseError,
GraphQLClientInvalidResponseError,
)

from ...utils import decode_multipart_request
Expand Down Expand Up @@ -486,7 +486,7 @@ def test_get_data_raises_graphql_client_invalid_response_error(
client = BaseClient(url="base_url", http_client=mocker.MagicMock())
response = httpx.Response(status_code=200, content=json.dumps(response_content))

with pytest.raises(GraphQlClientInvalidResponseError) as exc:
with pytest.raises(GraphQLClientInvalidResponseError) as exc:
client.get_data(response)
assert exc.response == response

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from ariadne_codegen.client_generators.dependencies.exceptions import (
GraphQLClientGraphQLMultiError,
GraphQLClientHttpError,
GraphQlClientInvalidResponseError,
GraphQLClientInvalidResponseError,
)

from ...utils import decode_multipart_request
Expand Down Expand Up @@ -499,7 +499,7 @@ def test_get_data_raises_graphql_client_invalid_response_error(
client = BaseClientOpenTelemetry(url="base_url", http_client=mocker.MagicMock())
response = httpx.Response(status_code=200, content=json.dumps(response_content))

with pytest.raises(GraphQlClientInvalidResponseError) as exc:
with pytest.raises(GraphQLClientInvalidResponseError) as exc:
client.get_data(response)
assert exc.response == response

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def test_generate_creates_files_with_correct_imports(
"GraphQLClientGraphQLError",
"GraphQLClientGraphQLMultiError",
"GraphQLClientHttpError",
"GraphQlClientInvalidResponseError",
"GraphQLClientInvalidResponseError",
"Upload",
]
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
GraphQLClientGraphQLError,
GraphQLClientGraphQLMultiError,
GraphQLClientHttpError,
GraphQlClientInvalidResponseError,
GraphQLClientInvalidResponseError,
)
from .test import Test

Expand All @@ -18,7 +18,7 @@
"GraphQLClientGraphQLError",
"GraphQLClientGraphQLMultiError",
"GraphQLClientHttpError",
"GraphQlClientInvalidResponseError",
"GraphQLClientInvalidResponseError",
"Test",
"Upload",
]
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
GraphQLClientGraphQLMultiError,
GraphQLClientHttpError,
GraphQLClientInvalidMessageFormat,
GraphQlClientInvalidResponseError,
GraphQLClientInvalidResponseError,
)

try:
Expand Down Expand Up @@ -125,10 +125,10 @@ def get_data(self, response: httpx.Response) -> Dict[str, Any]:
try:
response_json = response.json()
except ValueError as exc:
raise GraphQlClientInvalidResponseError(response=response) from exc
raise GraphQLClientInvalidResponseError(response=response) from exc

if (not isinstance(response_json, dict)) or ("data" not in response_json):
raise GraphQlClientInvalidResponseError(response=response)
raise GraphQLClientInvalidResponseError(response=response)

data = response_json["data"]
errors = response_json.get("errors")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __str__(self) -> str:
return f"HTTP status code: {self.status_code}"


class GraphQlClientInvalidResponseError(GraphQLClientError):
class GraphQLClientInvalidResponseError(GraphQLClientError):
def __init__(self, response: httpx.Response) -> None:
self.response = response

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
GraphQLClientGraphQLError,
GraphQLClientGraphQLMultiError,
GraphQLClientHttpError,
GraphQlClientInvalidResponseError,
GraphQLClientInvalidResponseError,
)
from .get_query_a import GetQueryA, GetQueryAQueryA

Expand All @@ -22,7 +22,7 @@
"GraphQLClientGraphQLError",
"GraphQLClientGraphQLMultiError",
"GraphQLClientHttpError",
"GraphQlClientInvalidResponseError",
"GraphQLClientInvalidResponseError",
"Upload",
"enumA",
"inputA",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
GraphQLClientGraphQLMultiError,
GraphQLClientHttpError,
GraphQLClientInvalidMessageFormat,
GraphQlClientInvalidResponseError,
GraphQLClientInvalidResponseError,
)

try:
Expand Down Expand Up @@ -125,10 +125,10 @@ def get_data(self, response: httpx.Response) -> Dict[str, Any]:
try:
response_json = response.json()
except ValueError as exc:
raise GraphQlClientInvalidResponseError(response=response) from exc
raise GraphQLClientInvalidResponseError(response=response) from exc

if (not isinstance(response_json, dict)) or ("data" not in response_json):
raise GraphQlClientInvalidResponseError(response=response)
raise GraphQLClientInvalidResponseError(response=response)

data = response_json["data"]
errors = response_json.get("errors")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __str__(self) -> str:
return f"HTTP status code: {self.status_code}"


class GraphQlClientInvalidResponseError(GraphQLClientError):
class GraphQLClientInvalidResponseError(GraphQLClientError):
def __init__(self, response: httpx.Response) -> None:
self.response = response

Expand Down
4 changes: 2 additions & 2 deletions tests/main/clients/custom_scalars/expected_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
GraphQLClientGraphQLError,
GraphQLClientGraphQLMultiError,
GraphQLClientHttpError,
GraphQlClientInvalidResponseError,
GraphQLClientInvalidResponseError,
)
from .get_a import GetA, GetATestQuery
from .input_types import TestInput
Expand All @@ -21,7 +21,7 @@
"GraphQLClientGraphQLError",
"GraphQLClientGraphQLMultiError",
"GraphQLClientHttpError",
"GraphQlClientInvalidResponseError",
"GraphQLClientInvalidResponseError",
"TestInput",
"Upload",
]
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
GraphQLClientGraphQLMultiError,
GraphQLClientHttpError,
GraphQLClientInvalidMessageFormat,
GraphQlClientInvalidResponseError,
GraphQLClientInvalidResponseError,
)

try:
Expand Down Expand Up @@ -125,10 +125,10 @@ def get_data(self, response: httpx.Response) -> Dict[str, Any]:
try:
response_json = response.json()
except ValueError as exc:
raise GraphQlClientInvalidResponseError(response=response) from exc
raise GraphQLClientInvalidResponseError(response=response) from exc

if (not isinstance(response_json, dict)) or ("data" not in response_json):
raise GraphQlClientInvalidResponseError(response=response)
raise GraphQLClientInvalidResponseError(response=response)

data = response_json["data"]
errors = response_json.get("errors")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __str__(self) -> str:
return f"HTTP status code: {self.status_code}"


class GraphQlClientInvalidResponseError(GraphQLClientError):
class GraphQLClientInvalidResponseError(GraphQLClientError):
def __init__(self, response: httpx.Response) -> None:
self.response = response

Expand Down
4 changes: 2 additions & 2 deletions tests/main/clients/example/expected_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
GraphQLClientGraphQLError,
GraphQLClientGraphQLMultiError,
GraphQLClientHttpError,
GraphQlClientInvalidResponseError,
GraphQLClientInvalidResponseError,
)
from .fragments import BasicUser, UserPersonalData
from .get_users_counter import GetUsersCounter
Expand All @@ -35,7 +35,7 @@
"GraphQLClientGraphQLError",
"GraphQLClientGraphQLMultiError",
"GraphQLClientHttpError",
"GraphQlClientInvalidResponseError",
"GraphQLClientInvalidResponseError",
"ListAllUsers",
"ListAllUsersUsers",
"ListAllUsersUsersLocation",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
GraphQLClientGraphQLMultiError,
GraphQLClientHttpError,
GraphQLClientInvalidMessageFormat,
GraphQlClientInvalidResponseError,
GraphQLClientInvalidResponseError,
)

try:
Expand Down Expand Up @@ -125,10 +125,10 @@ def get_data(self, response: httpx.Response) -> Dict[str, Any]:
try:
response_json = response.json()
except ValueError as exc:
raise GraphQlClientInvalidResponseError(response=response) from exc
raise GraphQLClientInvalidResponseError(response=response) from exc

if (not isinstance(response_json, dict)) or ("data" not in response_json):
raise GraphQlClientInvalidResponseError(response=response)
raise GraphQLClientInvalidResponseError(response=response)

data = response_json["data"]
errors = response_json.get("errors")
Expand Down
Loading

0 comments on commit 79ad7fc

Please sign in to comment.