strawberry-graphql 0.273.3__py3-none-any.whl → 0.274.0__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/http/async_base_view.py +6 -1
- strawberry/http/sync_base_view.py +6 -1
- strawberry/schema/exceptions.py +12 -0
- strawberry/schema/schema.py +20 -5
- strawberry/subscriptions/protocols/graphql_transport_ws/handlers.py +6 -5
- strawberry/subscriptions/protocols/graphql_ws/handlers.py +2 -8
- strawberry/types/execution.py +1 -1
- strawberry/utils/operation.py +1 -1
- {strawberry_graphql-0.273.3.dist-info → strawberry_graphql-0.274.0.dist-info}/METADATA +1 -1
- {strawberry_graphql-0.273.3.dist-info → strawberry_graphql-0.274.0.dist-info}/RECORD +13 -13
- {strawberry_graphql-0.273.3.dist-info → strawberry_graphql-0.274.0.dist-info}/LICENSE +0 -0
- {strawberry_graphql-0.273.3.dist-info → strawberry_graphql-0.274.0.dist-info}/WHEEL +0 -0
- {strawberry_graphql-0.273.3.dist-info → strawberry_graphql-0.274.0.dist-info}/entry_points.txt +0 -0
@@ -26,7 +26,10 @@ from strawberry.http import (
|
|
26
26
|
)
|
27
27
|
from strawberry.http.ides import GraphQL_IDE
|
28
28
|
from strawberry.schema.base import BaseSchema
|
29
|
-
from strawberry.schema.exceptions import
|
29
|
+
from strawberry.schema.exceptions import (
|
30
|
+
CannotGetOperationTypeError,
|
31
|
+
InvalidOperationTypeError,
|
32
|
+
)
|
30
33
|
from strawberry.subscriptions import GRAPHQL_TRANSPORT_WS_PROTOCOL, GRAPHQL_WS_PROTOCOL
|
31
34
|
from strawberry.subscriptions.protocols.graphql_transport_ws.handlers import (
|
32
35
|
BaseGraphQLTransportWSHandler,
|
@@ -330,6 +333,8 @@ class AsyncBaseHTTPView(
|
|
330
333
|
result = await self.execute_operation(
|
331
334
|
request=request, context=context, root_value=root_value
|
332
335
|
)
|
336
|
+
except CannotGetOperationTypeError as e:
|
337
|
+
raise HTTPException(400, e.as_http_error_reason()) from e
|
333
338
|
except InvalidOperationTypeError as e:
|
334
339
|
raise HTTPException(
|
335
340
|
400, e.as_http_error_reason(request_adapter.method)
|
@@ -20,7 +20,10 @@ from strawberry.http import (
|
|
20
20
|
)
|
21
21
|
from strawberry.http.ides import GraphQL_IDE
|
22
22
|
from strawberry.schema import BaseSchema
|
23
|
-
from strawberry.schema.exceptions import
|
23
|
+
from strawberry.schema.exceptions import (
|
24
|
+
CannotGetOperationTypeError,
|
25
|
+
InvalidOperationTypeError,
|
26
|
+
)
|
24
27
|
from strawberry.types import ExecutionResult
|
25
28
|
from strawberry.types.graphql import OperationType
|
26
29
|
from strawberry.types.unset import UNSET
|
@@ -193,6 +196,8 @@ class SyncBaseHTTPView(
|
|
193
196
|
context=context,
|
194
197
|
root_value=root_value,
|
195
198
|
)
|
199
|
+
except CannotGetOperationTypeError as e:
|
200
|
+
raise HTTPException(400, e.as_http_error_reason()) from e
|
196
201
|
except InvalidOperationTypeError as e:
|
197
202
|
raise HTTPException(
|
198
203
|
400, e.as_http_error_reason(request_adapter.method)
|
strawberry/schema/exceptions.py
CHANGED
@@ -1,9 +1,21 @@
|
|
1
|
+
from typing import Optional
|
2
|
+
|
1
3
|
from strawberry.types.graphql import OperationType
|
2
4
|
|
3
5
|
|
4
6
|
class CannotGetOperationTypeError(Exception):
|
5
7
|
"""Internal error raised when we cannot get the operation type from a GraphQL document."""
|
6
8
|
|
9
|
+
def __init__(self, operation_name: Optional[str]) -> None:
|
10
|
+
self.operation_name = operation_name
|
11
|
+
|
12
|
+
def as_http_error_reason(self) -> str:
|
13
|
+
return (
|
14
|
+
"Can't get GraphQL operation type"
|
15
|
+
if self.operation_name is None
|
16
|
+
else f'Unknown operation named "{self.operation_name}".'
|
17
|
+
)
|
18
|
+
|
7
19
|
|
8
20
|
class InvalidOperationTypeError(Exception):
|
9
21
|
def __init__(self, operation_type: OperationType) -> None:
|
strawberry/schema/schema.py
CHANGED
@@ -498,7 +498,7 @@ class Schema(BaseSchema):
|
|
498
498
|
try:
|
499
499
|
operation_type = context.operation_type
|
500
500
|
except RuntimeError as error:
|
501
|
-
raise CannotGetOperationTypeError from error
|
501
|
+
raise CannotGetOperationTypeError(context.operation_name) from error
|
502
502
|
|
503
503
|
if operation_type not in context.allowed_operations:
|
504
504
|
raise InvalidOperationTypeError(operation_type)
|
@@ -609,7 +609,11 @@ class Schema(BaseSchema):
|
|
609
609
|
# only return a sanitised version to the client.
|
610
610
|
self._process_errors(result.errors, execution_context)
|
611
611
|
|
612
|
-
except (
|
612
|
+
except (
|
613
|
+
MissingQueryError,
|
614
|
+
CannotGetOperationTypeError,
|
615
|
+
InvalidOperationTypeError,
|
616
|
+
):
|
613
617
|
raise
|
614
618
|
except Exception as exc: # noqa: BLE001
|
615
619
|
return await self._handle_execution_result(
|
@@ -677,8 +681,15 @@ class Schema(BaseSchema):
|
|
677
681
|
extensions=extensions_runner.get_extensions_results_sync(),
|
678
682
|
)
|
679
683
|
|
680
|
-
|
681
|
-
|
684
|
+
try:
|
685
|
+
operation_type = execution_context.operation_type
|
686
|
+
except RuntimeError as error:
|
687
|
+
raise CannotGetOperationTypeError(
|
688
|
+
execution_context.operation_name
|
689
|
+
) from error
|
690
|
+
|
691
|
+
if operation_type not in execution_context.allowed_operations:
|
692
|
+
raise InvalidOperationTypeError(operation_type) # noqa: TRY301
|
682
693
|
|
683
694
|
with extensions_runner.validation():
|
684
695
|
_run_validation(execution_context)
|
@@ -725,7 +736,11 @@ class Schema(BaseSchema):
|
|
725
736
|
# extension). That way we can log the original errors but
|
726
737
|
# only return a sanitised version to the client.
|
727
738
|
self._process_errors(result.errors, execution_context)
|
728
|
-
except (
|
739
|
+
except (
|
740
|
+
MissingQueryError,
|
741
|
+
CannotGetOperationTypeError,
|
742
|
+
InvalidOperationTypeError,
|
743
|
+
):
|
729
744
|
raise
|
730
745
|
except Exception as exc: # noqa: BLE001
|
731
746
|
errors = [_coerce_error(exc)]
|
@@ -20,6 +20,7 @@ from strawberry.http.exceptions import (
|
|
20
20
|
WebSocketDisconnected,
|
21
21
|
)
|
22
22
|
from strawberry.http.typevars import Context, RootValue
|
23
|
+
from strawberry.schema.exceptions import CannotGetOperationTypeError
|
23
24
|
from strawberry.subscriptions.protocols.graphql_transport_ws.types import (
|
24
25
|
CompleteMessage,
|
25
26
|
ConnectionInitMessage,
|
@@ -221,13 +222,13 @@ class BaseGraphQLTransportWSHandler(Generic[Context, RootValue]):
|
|
221
222
|
try:
|
222
223
|
operation_type = get_operation_type(graphql_document, operation_name)
|
223
224
|
except RuntimeError:
|
225
|
+
# Unlike in the other protocol implementations, we access the operation type
|
226
|
+
# before executing the operation. Therefore, we don't get a nice
|
227
|
+
# CannotGetOperationTypeError, but rather the underlying RuntimeError.
|
228
|
+
e = CannotGetOperationTypeError(operation_name)
|
224
229
|
await self.websocket.close(
|
225
230
|
code=4400,
|
226
|
-
reason=(
|
227
|
-
f'Unknown operation named "{operation_name}".'
|
228
|
-
if operation_name
|
229
|
-
else "Can't get GraphQL operation type"
|
230
|
-
),
|
231
|
+
reason=e.as_http_error_reason(),
|
231
232
|
)
|
232
233
|
return
|
233
234
|
|
@@ -194,18 +194,12 @@ class BaseGraphQLWSHandler(Generic[Context, RootValue]):
|
|
194
194
|
|
195
195
|
await self.send_message(CompleteMessage(type="complete", id=operation_id))
|
196
196
|
|
197
|
-
except CannotGetOperationTypeError:
|
197
|
+
except CannotGetOperationTypeError as e:
|
198
198
|
await self.send_message(
|
199
199
|
ErrorMessage(
|
200
200
|
type="error",
|
201
201
|
id=operation_id,
|
202
|
-
payload={
|
203
|
-
"message": (
|
204
|
-
f'Unknown operation named "{operation_name}".'
|
205
|
-
if operation_name
|
206
|
-
else "Can't get GraphQL operation type"
|
207
|
-
)
|
208
|
-
},
|
202
|
+
payload={"message": e.as_http_error_reason()},
|
209
203
|
)
|
210
204
|
)
|
211
205
|
except asyncio.CancelledError:
|
strawberry/types/execution.py
CHANGED
strawberry/utils/operation.py
CHANGED
@@ -25,7 +25,7 @@ def get_operation_type(
|
|
25
25
|
) -> OperationType:
|
26
26
|
definition: Optional[OperationDefinitionNode] = None
|
27
27
|
|
28
|
-
if operation_name:
|
28
|
+
if operation_name is not None:
|
29
29
|
for d in graphql_document.definitions:
|
30
30
|
if not isinstance(d, OperationDefinitionNode):
|
31
31
|
continue
|
@@ -134,12 +134,12 @@ strawberry/file_uploads/utils.py,sha256=-c6TbqUI-Dkb96hWCrZabh6TL2OabBuQNkCarOqg
|
|
134
134
|
strawberry/flask/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
135
135
|
strawberry/flask/views.py,sha256=MCvAsNgTZLU8RvTYKWfnLU2w7Wv1ZZpxW9W3TyTZuPY,6355
|
136
136
|
strawberry/http/__init__.py,sha256=ytAirKk7K7D5knY21tpCGeZ-sCPgwMsijL5AxmOy-94,1163
|
137
|
-
strawberry/http/async_base_view.py,sha256=
|
137
|
+
strawberry/http/async_base_view.py,sha256=fEJGBPqEOnEiYc0bBT4vroqyidoHNBnfF-1iScmOQi0,20124
|
138
138
|
strawberry/http/base.py,sha256=MiX0-RqOkhRvlfpmuvgTHp4tygbUmG8fnLc0uCrOllU,2550
|
139
139
|
strawberry/http/exceptions.py,sha256=9E2dreS1crRoJVUEPuHyx23NcDELDHNzkAOa-rGv-8I,348
|
140
140
|
strawberry/http/ides.py,sha256=WjU0nsMDgr3Bd1ebWkUEkO2d1hk0dI16mLqXyCHqklA,613
|
141
141
|
strawberry/http/parse_content_type.py,sha256=CYHO8F9b9DP1gJ1xxPjc9L2GkBwsyC1O_GCEp1QOuG0,381
|
142
|
-
strawberry/http/sync_base_view.py,sha256=
|
142
|
+
strawberry/http/sync_base_view.py,sha256=_lYjw3uAQoYJ8QEWBWr7g6a88aM5NX8YFTFeZ5qzH88,7424
|
143
143
|
strawberry/http/temporal_response.py,sha256=HTt65g-YxqlPGxjqvH5bzGoU1b3CctVR-9cmCRo5dUo,196
|
144
144
|
strawberry/http/types.py,sha256=H0wGOdCO-5tNKZM_6cAtNRwZAjoEXnAC5N0Q7b70AtU,398
|
145
145
|
strawberry/http/typevars.py,sha256=Uu6NkKe3h7o29ZWwldq6sJy4ioSSeXODTCDRvY2hUpE,489
|
@@ -168,9 +168,9 @@ strawberry/schema/__init__.py,sha256=u1QCyDVQExUVDA20kyosKPz3TS5HMCN2NrXclhiFAL4
|
|
168
168
|
strawberry/schema/base.py,sha256=wqvEOQ_aVkfebk9SlG9zg1YXl3MlwxGZhxFRoIkAxu0,4053
|
169
169
|
strawberry/schema/compat.py,sha256=xNpOEDfi-MODpplMGaKuKeQIVcr-tcAaKaU3TlBc1Zs,1873
|
170
170
|
strawberry/schema/config.py,sha256=6d2MPrAgq97-7aze555dRcB3yw-aeUexYMP3KVN22c0,1024
|
171
|
-
strawberry/schema/exceptions.py,sha256=
|
171
|
+
strawberry/schema/exceptions.py,sha256=8gsMxxFDynMvRkUDuVL9Wwxk_zsmo6QoJ2l4NPxd64M,1137
|
172
172
|
strawberry/schema/name_converter.py,sha256=xFOXEgqldFkxXRkIQvsJN1dPkWbEUaIrTYNOMYSEVwQ,6945
|
173
|
-
strawberry/schema/schema.py,sha256=
|
173
|
+
strawberry/schema/schema.py,sha256=dnmSxoNdlrT02mca32Crtl0F55eweIqE-VOC77kuGjE,37723
|
174
174
|
strawberry/schema/schema_converter.py,sha256=vxFghA8c4vPLx0XM07gjIbWqMWUnaognzmsuCWTSkTk,39112
|
175
175
|
strawberry/schema/types/__init__.py,sha256=oHO3COWhL3L1KLYCJNY1XFf5xt2GGtHiMC-UaYbFfnA,68
|
176
176
|
strawberry/schema/types/base_scalars.py,sha256=JRUq0WjEkR9dFewstZnqnZKp0uOEipo4UXNF5dzRf4M,1971
|
@@ -187,10 +187,10 @@ strawberry/static/pathfinder.html,sha256=0DPx9AmJ2C_sJstFXnWOz9k5tVQHeHaK7qdVY4l
|
|
187
187
|
strawberry/subscriptions/__init__.py,sha256=1VGmiCzFepqRFyCikagkUoHHdoTG3XYlFu9GafoQMws,170
|
188
188
|
strawberry/subscriptions/protocols/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
189
189
|
strawberry/subscriptions/protocols/graphql_transport_ws/__init__.py,sha256=wN6dkMu6WiaIZTE19PGoN9xXpIN_RdDE_q7F7ZgjCxk,138
|
190
|
-
strawberry/subscriptions/protocols/graphql_transport_ws/handlers.py,sha256=
|
190
|
+
strawberry/subscriptions/protocols/graphql_transport_ws/handlers.py,sha256=XJYPq_Nl6PWYu-u_uAmh-AO1k2wD3gAQjGMhRjkcwbo,15475
|
191
191
|
strawberry/subscriptions/protocols/graphql_transport_ws/types.py,sha256=N9r2mXg5jmmjYoZV5rWf3lAzgylCOUrbKGmClXCoOso,2169
|
192
192
|
strawberry/subscriptions/protocols/graphql_ws/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
193
|
-
strawberry/subscriptions/protocols/graphql_ws/handlers.py,sha256=
|
193
|
+
strawberry/subscriptions/protocols/graphql_ws/handlers.py,sha256=4o_ptDXL1gMLVQUfxJYO8Xfm_I3gt-Y1Z2CsOb7K1yw,8658
|
194
194
|
strawberry/subscriptions/protocols/graphql_ws/types.py,sha256=Uumiz-1O5qQnx-ERBaQtaf7db5yx-V9LMypOn9oGKwM,2003
|
195
195
|
strawberry/test/__init__.py,sha256=lKVbKJDBnrYSPYHIKrg54UpaZcSoL93Z01zOpA1IzZM,115
|
196
196
|
strawberry/test/client.py,sha256=ILAttb6A3jplH5wJNMeyyT1u_Q8KnollfpYLP_BVZR4,6438
|
@@ -203,7 +203,7 @@ strawberry/types/auto.py,sha256=WZ2cQAI8nREUigBzpzFqIKGjJ_C2VqpAPNe8vPjTciM,3007
|
|
203
203
|
strawberry/types/base.py,sha256=Bfa-5Wen8qR7m6tlSMRRGlGE-chRGMHjQMopfNdbbrk,15197
|
204
204
|
strawberry/types/cast.py,sha256=fx86MkLW77GIximBAwUk5vZxSGwDqUA6XicXvz8EXwQ,916
|
205
205
|
strawberry/types/enum.py,sha256=IcCz0FLswJtDC_bU8aG1cjreawcqHywAzzVRBZUSAqs,6229
|
206
|
-
strawberry/types/execution.py,sha256=
|
206
|
+
strawberry/types/execution.py,sha256=m27VlmvaRLQsMnWWymxMMPOlaf0lUge4ZXea_OsoH2k,3761
|
207
207
|
strawberry/types/field.py,sha256=vxb7JvkHfRmDCYsjhDmVnO2lMbtSOteQm3jQUeSFu6g,21605
|
208
208
|
strawberry/types/fields/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
209
209
|
strawberry/types/fields/resolver.py,sha256=b6lxfw6AMOUFWm7vs7a9KzNkpR8b_S110DoIosrrWDQ,14679
|
@@ -229,11 +229,11 @@ strawberry/utils/graphql_lexer.py,sha256=JUVJrJ6Ax0t7m6-DTWFzf4cvXrC02VPmL1NS2zM
|
|
229
229
|
strawberry/utils/importer.py,sha256=NtTgNaNSW4TnlLo_S34nxXq14RxUAec-QlEZ0LON28M,629
|
230
230
|
strawberry/utils/inspect.py,sha256=-aFT65PkQ9KXo5w8Q2uveBJ8jEpi40sTqRipRQVdYR8,3406
|
231
231
|
strawberry/utils/logging.py,sha256=U1cseHGquN09YFhFmRkiphfASKCyK0HUZREImPgVb0c,746
|
232
|
-
strawberry/utils/operation.py,sha256=
|
232
|
+
strawberry/utils/operation.py,sha256=ZgVOw3K2jQuLjNOYUHauF7itJD0QDNoPw9PBi0IYf6k,1234
|
233
233
|
strawberry/utils/str_converters.py,sha256=-eH1Cl16IO_wrBlsGM-km4IY0IKsjhjnSNGRGOwQjVM,897
|
234
234
|
strawberry/utils/typing.py,sha256=SDvX-Du-9HAV3-XXjqi7Q5f5qPDDFd_gASIITiwBQT4,14073
|
235
|
-
strawberry_graphql-0.
|
236
|
-
strawberry_graphql-0.
|
237
|
-
strawberry_graphql-0.
|
238
|
-
strawberry_graphql-0.
|
239
|
-
strawberry_graphql-0.
|
235
|
+
strawberry_graphql-0.274.0.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
|
236
|
+
strawberry_graphql-0.274.0.dist-info/METADATA,sha256=Qi_EBzRuPvmFcfFTQWmxWId7EoPQVqlgJusjp9345kk,7444
|
237
|
+
strawberry_graphql-0.274.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
238
|
+
strawberry_graphql-0.274.0.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
|
239
|
+
strawberry_graphql-0.274.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
{strawberry_graphql-0.273.3.dist-info → strawberry_graphql-0.274.0.dist-info}/entry_points.txt
RENAMED
File without changes
|