strawberry-graphql 0.270.1__py3-none-any.whl → 0.270.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- strawberry/schema/exceptions.py +8 -1
- strawberry/schema/schema.py +8 -3
- strawberry/subscriptions/protocols/graphql_ws/handlers.py +9 -0
- {strawberry_graphql-0.270.1.dist-info → strawberry_graphql-0.270.3.dist-info}/METADATA +2 -2
- {strawberry_graphql-0.270.1.dist-info → strawberry_graphql-0.270.3.dist-info}/RECORD +8 -8
- {strawberry_graphql-0.270.1.dist-info → strawberry_graphql-0.270.3.dist-info}/LICENSE +0 -0
- {strawberry_graphql-0.270.1.dist-info → strawberry_graphql-0.270.3.dist-info}/WHEEL +0 -0
- {strawberry_graphql-0.270.1.dist-info → strawberry_graphql-0.270.3.dist-info}/entry_points.txt +0 -0
strawberry/schema/exceptions.py
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
from strawberry.types.graphql import OperationType
|
2
2
|
|
3
3
|
|
4
|
+
class CannotGetOperationTypeError(Exception):
|
5
|
+
"""Internal error raised when we cannot get the operation type from a GraphQL document."""
|
6
|
+
|
7
|
+
|
4
8
|
class InvalidOperationTypeError(Exception):
|
5
9
|
def __init__(self, operation_type: OperationType) -> None:
|
6
10
|
self.operation_type = operation_type
|
@@ -15,4 +19,7 @@ class InvalidOperationTypeError(Exception):
|
|
15
19
|
return f"{operation_type} are not allowed when using {method}"
|
16
20
|
|
17
21
|
|
18
|
-
__all__ = [
|
22
|
+
__all__ = [
|
23
|
+
"CannotGetOperationTypeError",
|
24
|
+
"InvalidOperationTypeError",
|
25
|
+
]
|
strawberry/schema/schema.py
CHANGED
@@ -71,7 +71,7 @@ from strawberry.utils.await_maybe import await_maybe
|
|
71
71
|
from . import compat
|
72
72
|
from .base import BaseSchema
|
73
73
|
from .config import StrawberryConfig
|
74
|
-
from .exceptions import InvalidOperationTypeError
|
74
|
+
from .exceptions import CannotGetOperationTypeError, InvalidOperationTypeError
|
75
75
|
|
76
76
|
if TYPE_CHECKING:
|
77
77
|
from collections.abc import Iterable, Mapping
|
@@ -495,8 +495,13 @@ class Schema(BaseSchema):
|
|
495
495
|
context.errors = [error]
|
496
496
|
return PreExecutionError(data=None, errors=[error])
|
497
497
|
|
498
|
-
|
499
|
-
|
498
|
+
try:
|
499
|
+
operation_type = context.operation_type
|
500
|
+
except RuntimeError as error:
|
501
|
+
raise CannotGetOperationTypeError from error
|
502
|
+
|
503
|
+
if operation_type not in context.allowed_operations:
|
504
|
+
raise InvalidOperationTypeError(operation_type)
|
500
505
|
|
501
506
|
async with extensions_runner.validation():
|
502
507
|
_run_validation(context)
|
@@ -14,6 +14,7 @@ from typing import (
|
|
14
14
|
from strawberry.exceptions import ConnectionRejectionError
|
15
15
|
from strawberry.http.exceptions import NonTextMessageReceived, WebSocketDisconnected
|
16
16
|
from strawberry.http.typevars import Context, RootValue
|
17
|
+
from strawberry.schema.exceptions import CannotGetOperationTypeError
|
17
18
|
from strawberry.subscriptions.protocols.graphql_ws.types import (
|
18
19
|
CompleteMessage,
|
19
20
|
ConnectionInitMessage,
|
@@ -193,6 +194,14 @@ class BaseGraphQLWSHandler(Generic[Context, RootValue]):
|
|
193
194
|
|
194
195
|
await self.send_message(CompleteMessage(type="complete", id=operation_id))
|
195
196
|
|
197
|
+
except CannotGetOperationTypeError:
|
198
|
+
await self.send_message(
|
199
|
+
ErrorMessage(
|
200
|
+
type="error",
|
201
|
+
id=operation_id,
|
202
|
+
payload={"message": f'Unknown operation named "{operation_name}".'},
|
203
|
+
)
|
204
|
+
)
|
196
205
|
except asyncio.CancelledError:
|
197
206
|
await self.send_message(CompleteMessage(type="complete", id=operation_id))
|
198
207
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: strawberry-graphql
|
3
|
-
Version: 0.270.
|
3
|
+
Version: 0.270.3
|
4
4
|
Summary: A library for creating GraphQL APIs
|
5
5
|
License: MIT
|
6
6
|
Keywords: graphql,api,rest,starlette,async
|
@@ -42,7 +42,7 @@ Requires-Dist: channels (>=3.0.5) ; extra == "channels"
|
|
42
42
|
Requires-Dist: fastapi (>=0.65.2) ; extra == "fastapi"
|
43
43
|
Requires-Dist: flask (>=1.1) ; extra == "flask"
|
44
44
|
Requires-Dist: graphql-core (>=3.2.0,<3.4.0) ; python_version >= "3.9" and python_version < "4.0"
|
45
|
-
Requires-Dist: libcst (>=0.4.7) ; extra == "debug" or extra == "debug-server" or extra == "cli"
|
45
|
+
Requires-Dist: libcst (>=0.4.7,<1.8.0) ; extra == "debug" or extra == "debug-server" or extra == "cli"
|
46
46
|
Requires-Dist: litestar (>=2) ; (python_version >= "3.10" and python_version < "4.0") and (extra == "litestar")
|
47
47
|
Requires-Dist: opentelemetry-api (<2) ; extra == "opentelemetry"
|
48
48
|
Requires-Dist: opentelemetry-sdk (<2) ; extra == "opentelemetry"
|
@@ -165,9 +165,9 @@ strawberry/schema/__init__.py,sha256=u1QCyDVQExUVDA20kyosKPz3TS5HMCN2NrXclhiFAL4
|
|
165
165
|
strawberry/schema/base.py,sha256=wqvEOQ_aVkfebk9SlG9zg1YXl3MlwxGZhxFRoIkAxu0,4053
|
166
166
|
strawberry/schema/compat.py,sha256=xNpOEDfi-MODpplMGaKuKeQIVcr-tcAaKaU3TlBc1Zs,1873
|
167
167
|
strawberry/schema/config.py,sha256=KeZ1Pc1gvYK0fOx9Aghx7m0Av8sWexycl3HJGFgHPvg,969
|
168
|
-
strawberry/schema/exceptions.py,sha256=
|
168
|
+
strawberry/schema/exceptions.py,sha256=xXq-2wXfeGualEJObXja6yVIKzFTh_iDXCIWttpIOSE,769
|
169
169
|
strawberry/schema/name_converter.py,sha256=xFOXEgqldFkxXRkIQvsJN1dPkWbEUaIrTYNOMYSEVwQ,6945
|
170
|
-
strawberry/schema/schema.py,sha256=
|
170
|
+
strawberry/schema/schema.py,sha256=pTs_dfhqsftecPblY_jCPU7my8RKB1QnleicCJL35WE,37287
|
171
171
|
strawberry/schema/schema_converter.py,sha256=_lKctaIfNcncVCan8AElYngGxMS8vf4Wy27tXfkr0Mk,39011
|
172
172
|
strawberry/schema/types/__init__.py,sha256=oHO3COWhL3L1KLYCJNY1XFf5xt2GGtHiMC-UaYbFfnA,68
|
173
173
|
strawberry/schema/types/base_scalars.py,sha256=JRUq0WjEkR9dFewstZnqnZKp0uOEipo4UXNF5dzRf4M,1971
|
@@ -187,7 +187,7 @@ strawberry/subscriptions/protocols/graphql_transport_ws/__init__.py,sha256=wN6dk
|
|
187
187
|
strawberry/subscriptions/protocols/graphql_transport_ws/handlers.py,sha256=PFJDEYOXqqROkczVKZ8k4yWJbib1cE6ySx9GIR5hAVI,15079
|
188
188
|
strawberry/subscriptions/protocols/graphql_transport_ws/types.py,sha256=N9r2mXg5jmmjYoZV5rWf3lAzgylCOUrbKGmClXCoOso,2169
|
189
189
|
strawberry/subscriptions/protocols/graphql_ws/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
190
|
-
strawberry/subscriptions/protocols/graphql_ws/handlers.py,sha256=
|
190
|
+
strawberry/subscriptions/protocols/graphql_ws/handlers.py,sha256=MWSipEW-mnklAvdqfmTdQZ4w3Dtk7lMLpIIuI4wyNz8,8675
|
191
191
|
strawberry/subscriptions/protocols/graphql_ws/types.py,sha256=Uumiz-1O5qQnx-ERBaQtaf7db5yx-V9LMypOn9oGKwM,2003
|
192
192
|
strawberry/test/__init__.py,sha256=lKVbKJDBnrYSPYHIKrg54UpaZcSoL93Z01zOpA1IzZM,115
|
193
193
|
strawberry/test/client.py,sha256=ILAttb6A3jplH5wJNMeyyT1u_Q8KnollfpYLP_BVZR4,6438
|
@@ -229,8 +229,8 @@ strawberry/utils/logging.py,sha256=U1cseHGquN09YFhFmRkiphfASKCyK0HUZREImPgVb0c,7
|
|
229
229
|
strawberry/utils/operation.py,sha256=s7ajvLg_q6v2mg47kEMQPjO_J-XluMKTCwo4d47mGvE,1195
|
230
230
|
strawberry/utils/str_converters.py,sha256=-eH1Cl16IO_wrBlsGM-km4IY0IKsjhjnSNGRGOwQjVM,897
|
231
231
|
strawberry/utils/typing.py,sha256=SDvX-Du-9HAV3-XXjqi7Q5f5qPDDFd_gASIITiwBQT4,14073
|
232
|
-
strawberry_graphql-0.270.
|
233
|
-
strawberry_graphql-0.270.
|
234
|
-
strawberry_graphql-0.270.
|
235
|
-
strawberry_graphql-0.270.
|
236
|
-
strawberry_graphql-0.270.
|
232
|
+
strawberry_graphql-0.270.3.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
|
233
|
+
strawberry_graphql-0.270.3.dist-info/METADATA,sha256=nBJgasFC21zrKkwnL1wgCkSIrZJo8yUI0FNdUmtveV0,7686
|
234
|
+
strawberry_graphql-0.270.3.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
235
|
+
strawberry_graphql-0.270.3.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
|
236
|
+
strawberry_graphql-0.270.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
{strawberry_graphql-0.270.1.dist-info → strawberry_graphql-0.270.3.dist-info}/entry_points.txt
RENAMED
File without changes
|