strawberry-graphql 0.251.0__py3-none-any.whl → 0.253.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.
@@ -96,11 +96,11 @@ class AioHTTPWebSocketAdapter(AsyncWebSocketAdapter):
96
96
 
97
97
  async def iter_json(
98
98
  self, *, ignore_parsing_errors: bool = False
99
- ) -> AsyncGenerator[Dict[str, object], None]:
99
+ ) -> AsyncGenerator[object, None]:
100
100
  async for ws_message in self.ws:
101
101
  if ws_message.type == http.WSMsgType.TEXT:
102
102
  try:
103
- yield ws_message.json()
103
+ yield self.view.decode_json(ws_message.data)
104
104
  except JSONDecodeError:
105
105
  if not ignore_parsing_errors:
106
106
  raise NonJsonMessageReceived()
@@ -5,7 +5,6 @@ from datetime import timedelta
5
5
  from json import JSONDecodeError
6
6
  from typing import (
7
7
  TYPE_CHECKING,
8
- Any,
9
8
  AsyncGenerator,
10
9
  AsyncIterator,
11
10
  Callable,
@@ -95,11 +94,12 @@ class ASGIWebSocketAdapter(AsyncWebSocketAdapter):
95
94
 
96
95
  async def iter_json(
97
96
  self, *, ignore_parsing_errors: bool = False
98
- ) -> AsyncGenerator[Dict[str, object], None]:
97
+ ) -> AsyncGenerator[object, None]:
99
98
  try:
100
99
  while self.ws.application_state != WebSocketState.DISCONNECTED:
101
100
  try:
102
- yield await self.ws.receive_json()
101
+ text = await self.ws.receive_text()
102
+ yield self.view.decode_json(text)
103
103
  except JSONDecodeError: # noqa: PERF203
104
104
  if not ignore_parsing_errors:
105
105
  raise NonJsonMessageReceived()
@@ -184,7 +184,9 @@ class GraphQL(
184
184
  else: # pragma: no cover
185
185
  raise ValueError("Unknown scope type: {!r}".format(scope["type"]))
186
186
 
187
- async def get_root_value(self, request: Union[Request, WebSocket]) -> Optional[Any]:
187
+ async def get_root_value(
188
+ self, request: Union[Request, WebSocket]
189
+ ) -> Optional[RootValue]:
188
190
  return None
189
191
 
190
192
  async def get_context(
@@ -6,7 +6,6 @@ import json
6
6
  from typing import (
7
7
  TYPE_CHECKING,
8
8
  AsyncGenerator,
9
- Dict,
10
9
  Mapping,
11
10
  Optional,
12
11
  Tuple,
@@ -39,7 +38,7 @@ class ChannelsWebSocketAdapter(AsyncWebSocketAdapter):
39
38
 
40
39
  async def iter_json(
41
40
  self, *, ignore_parsing_errors: bool = False
42
- ) -> AsyncGenerator[Dict[str, object], None]:
41
+ ) -> AsyncGenerator[object, None]:
43
42
  while True:
44
43
  message = await self.ws_consumer.message_queue.get()
45
44
 
@@ -50,7 +49,7 @@ class ChannelsWebSocketAdapter(AsyncWebSocketAdapter):
50
49
  raise NonTextMessageReceived()
51
50
 
52
51
  try:
53
- yield json.loads(message["message"])
52
+ yield self.view.decode_json(message["message"])
54
53
  except json.JSONDecodeError:
55
54
  if not ignore_parsing_errors:
56
55
  raise NonJsonMessageReceived()
@@ -221,8 +221,8 @@ class GraphQLView(
221
221
  def get_root_value(self, request: HttpRequest) -> Optional[RootValue]:
222
222
  return None
223
223
 
224
- def get_context(self, request: HttpRequest, response: HttpResponse) -> Any:
225
- return StrawberryDjangoContext(request=request, response=response)
224
+ def get_context(self, request: HttpRequest, response: HttpResponse) -> Context:
225
+ return StrawberryDjangoContext(request=request, response=response) # type: ignore
226
226
 
227
227
  def get_sub_response(self, request: HttpRequest) -> TemporalHttpResponse:
228
228
  return TemporalHttpResponse()
@@ -276,11 +276,13 @@ class AsyncGraphQLView(
276
276
 
277
277
  return view
278
278
 
279
- async def get_root_value(self, request: HttpRequest) -> Any:
279
+ async def get_root_value(self, request: HttpRequest) -> Optional[RootValue]:
280
280
  return None
281
281
 
282
- async def get_context(self, request: HttpRequest, response: HttpResponse) -> Any:
283
- return StrawberryDjangoContext(request=request, response=response)
282
+ async def get_context(
283
+ self, request: HttpRequest, response: HttpResponse
284
+ ) -> Context:
285
+ return StrawberryDjangoContext(request=request, response=response) # type: ignore
284
286
 
285
287
  async def get_sub_response(self, request: HttpRequest) -> TemporalHttpResponse:
286
288
  return TemporalHttpResponse()
@@ -38,7 +38,6 @@ from fastapi.utils import generate_unique_id
38
38
  from strawberry.asgi import ASGIRequestAdapter, ASGIWebSocketAdapter
39
39
  from strawberry.exceptions import InvalidCustomContext
40
40
  from strawberry.fastapi.context import BaseContext, CustomContext
41
- from strawberry.http import process_result
42
41
  from strawberry.http.async_base_view import AsyncBaseHTTPView
43
42
  from strawberry.http.exceptions import HTTPException
44
43
  from strawberry.http.typevars import Context, RootValue
@@ -54,7 +53,6 @@ if TYPE_CHECKING:
54
53
  from strawberry.http import GraphQLHTTPResponse
55
54
  from strawberry.http.ides import GraphQL_IDE
56
55
  from strawberry.schema import BaseSchema
57
- from strawberry.types import ExecutionResult
58
56
 
59
57
 
60
58
  class GraphQLRouter(
@@ -268,11 +266,6 @@ class GraphQLRouter(
268
266
  async def render_graphql_ide(self, request: Request) -> HTMLResponse:
269
267
  return HTMLResponse(self.graphql_ide_html)
270
268
 
271
- async def process_result(
272
- self, request: Request, result: ExecutionResult
273
- ) -> GraphQLHTTPResponse:
274
- return process_result(result)
275
-
276
269
  async def get_context(
277
270
  self, request: Union[Request, WebSocket], response: Union[Response, WebSocket]
278
271
  ) -> Context: # pragma: no cover
@@ -1,8 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
- import json
4
3
  from dataclasses import dataclass
5
- from typing import TYPE_CHECKING, Any, Dict, List, Mapping, Optional
4
+ from typing import TYPE_CHECKING, Any, Dict, List, Optional
6
5
  from typing_extensions import Literal, TypedDict
7
6
 
8
7
  if TYPE_CHECKING:
@@ -36,25 +35,8 @@ class GraphQLRequestData:
36
35
  protocol: Literal["http", "multipart-subscription"] = "http"
37
36
 
38
37
 
39
- def parse_query_params(params: Dict[str, str]) -> Dict[str, Any]:
40
- if "variables" in params:
41
- params["variables"] = json.loads(params["variables"])
42
-
43
- return params
44
-
45
-
46
- def parse_request_data(data: Mapping[str, Any]) -> GraphQLRequestData:
47
- return GraphQLRequestData(
48
- query=data.get("query"),
49
- variables=data.get("variables"),
50
- operation_name=data.get("operationName"),
51
- )
52
-
53
-
54
38
  __all__ = [
55
39
  "GraphQLHTTPResponse",
56
40
  "process_result",
57
41
  "GraphQLRequestData",
58
- "parse_query_params",
59
- "parse_request_data",
60
42
  ]
@@ -86,7 +86,7 @@ class AsyncWebSocketAdapter(abc.ABC):
86
86
  @abc.abstractmethod
87
87
  def iter_json(
88
88
  self, *, ignore_parsing_errors: bool = False
89
- ) -> AsyncGenerator[Dict[str, object], None]: ...
89
+ ) -> AsyncGenerator[object, None]: ...
90
90
 
91
91
  @abc.abstractmethod
92
92
  async def send_json(self, message: Mapping[str, object]) -> None: ...
strawberry/http/base.py CHANGED
@@ -39,10 +39,13 @@ class BaseView(Generic[Request]):
39
39
 
40
40
  def parse_json(self, data: Union[str, bytes]) -> Any:
41
41
  try:
42
- return json.loads(data)
42
+ return self.decode_json(data)
43
43
  except json.JSONDecodeError as e:
44
44
  raise HTTPException(400, "Unable to parse request body as JSON") from e
45
45
 
46
+ def decode_json(self, data: Union[str, bytes]) -> object:
47
+ return json.loads(data)
48
+
46
49
  def encode_json(self, data: object) -> str:
47
50
  return json.dumps(data)
48
51
 
@@ -202,7 +202,7 @@ class LitestarWebSocketAdapter(AsyncWebSocketAdapter):
202
202
 
203
203
  async def iter_json(
204
204
  self, *, ignore_parsing_errors: bool = False
205
- ) -> AsyncGenerator[Dict[str, object], None]:
205
+ ) -> AsyncGenerator[object, None]:
206
206
  try:
207
207
  while self.ws.connection_state != "disconnect":
208
208
  text = await self.ws.receive_text()
@@ -212,7 +212,7 @@ class LitestarWebSocketAdapter(AsyncWebSocketAdapter):
212
212
  raise NonTextMessageReceived()
213
213
 
214
214
  try:
215
- yield json.loads(text)
215
+ yield self.view.decode_json(text)
216
216
  except json.JSONDecodeError:
217
217
  if not ignore_parsing_errors:
218
218
  raise NonJsonMessageReceived()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: strawberry-graphql
3
- Version: 0.251.0
3
+ Version: 0.253.0
4
4
  Summary: A library for creating GraphQL APIs
5
5
  Home-page: https://strawberry.rocks/
6
6
  License: MIT
@@ -3,9 +3,9 @@ strawberry/__main__.py,sha256=3U77Eu21mJ-LY27RG-JEnpbh6Z63wGOom4i-EoLtUcY,59
3
3
  strawberry/aiohttp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  strawberry/aiohttp/test/__init__.py,sha256=4xxdUZtIISSOwjrcnmox7AvT4WWjowCm5bUuPdQneMg,71
5
5
  strawberry/aiohttp/test/client.py,sha256=xPwOo1V0XbC86LWHiSRTLcGNOa796flz49wzWmdkvSs,1775
6
- strawberry/aiohttp/views.py,sha256=-D1SWYgXbF9UUpt3BnvzSOTrqAZOSQrPQmP_H4736IQ,7857
6
+ strawberry/aiohttp/views.py,sha256=q0L5JwIk-8TTnyy_4nfmBIve3DHnRb8YwOBP4qmvDLE,7867
7
7
  strawberry/annotation.py,sha256=u5rkFs6CDUaiJZMK7jp_VDUWdZZ3HXQEbR2ocruDpxA,13065
8
- strawberry/asgi/__init__.py,sha256=49JPYO-DRXpFqxRYBYhqvoFA2GbIjXBM-nBvrOI88O8,8086
8
+ strawberry/asgi/__init__.py,sha256=t8K3UIhSnyeI2yCxAh1BQwYfDCeaC4A-YhiMePoFMJo,8141
9
9
  strawberry/asgi/test/__init__.py,sha256=4xxdUZtIISSOwjrcnmox7AvT4WWjowCm5bUuPdQneMg,71
10
10
  strawberry/asgi/test/client.py,sha256=VolupxMna9ktF1lYgV_dUQAIN53DNzVyWTeWTbwsxqE,1448
11
11
  strawberry/chalice/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -14,7 +14,7 @@ strawberry/channels/__init__.py,sha256=-9ENTIu1AILbqffJ663qH6AwpZgLrJx_kaokS7RrC
14
14
  strawberry/channels/handlers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  strawberry/channels/handlers/base.py,sha256=KV4KA0eF5NRtikV9m4ssoPI5pmCZvDuRkfoTxwh42qI,7853
16
16
  strawberry/channels/handlers/http_handler.py,sha256=fnQcPwdUz2CboVlnI3s1urQ_ZnZyNZvRx7SM_xPLLEA,11577
17
- strawberry/channels/handlers/ws_handler.py,sha256=YvrbaYtF6arDSGFYE3TMWddmHjdkTtHHzVRh7Y3uS3M,6158
17
+ strawberry/channels/handlers/ws_handler.py,sha256=_oTCfu2LYczBNVqFxbChGU-4weix86pHcFphFz3CYQg,6148
18
18
  strawberry/channels/router.py,sha256=DKIbl4zuRBhfvViUVpyu0Rf_WRT41E6uZC-Yic9Ltvo,2024
19
19
  strawberry/channels/testing.py,sha256=0q7XQi3uOa-WbqXTkZKWwsLH2B8IHfP3JAXF-b-1qM4,6490
20
20
  strawberry/cli/__init__.py,sha256=byS5VrEiTJatAH6YS4V1Kd4SOwMRAQO2M1oJdIddivg,585
@@ -49,7 +49,7 @@ strawberry/django/apps.py,sha256=ZWw3Mzv1Cgy0T9xT8Jr2_dkCTZjT5WQABb34iqnu5pc,135
49
49
  strawberry/django/context.py,sha256=XL85jDGAVnb2pwgm5uRUvIXwlGia3i-8ZVfKihf0T24,655
50
50
  strawberry/django/test/__init__.py,sha256=4xxdUZtIISSOwjrcnmox7AvT4WWjowCm5bUuPdQneMg,71
51
51
  strawberry/django/test/client.py,sha256=6dorWECd0wdn8fu3dabE-dfGK3uza58mGrdJ-xPct-w,626
52
- strawberry/django/views.py,sha256=jPb_J6-bXd_xb478Cv0nR5eLtRZN8CgvxlopkhckgJQ,9542
52
+ strawberry/django/views.py,sha256=ySmuTx5ZKBAyC4LPziMqzLJoRimLDF4bRsnrUYWf_oM,9612
53
53
  strawberry/exceptions/__init__.py,sha256=-yYcgv3cxEyDSxWyFId9j-yy2pNnXQC4lIpk7bHr8fs,6257
54
54
  strawberry/exceptions/conflicting_arguments.py,sha256=68f6kMSXdjuEjZkoe8o2I9PSIjwTS1kXsSGaQBPk_hI,1587
55
55
  strawberry/exceptions/duplicated_type_name.py,sha256=-FG5qG_Mvkd7ROdOxCB9bijf8QR6Olryf07mbAFC0-U,2210
@@ -110,7 +110,7 @@ strawberry/extensions/utils.py,sha256=YPiacKNLQXvpYj-HI6fR5ORFdM9RrcdabGeM7F8vBG
110
110
  strawberry/extensions/validation_cache.py,sha256=CZ-brPYA1grL_lW38Rq4TxEVKlHM2n1DC6q9BHlSF4g,1398
111
111
  strawberry/fastapi/__init__.py,sha256=p5qg9AlkYjNOWKcT4uRiebIpR6pIb1HqDMiDfF5O3tg,147
112
112
  strawberry/fastapi/context.py,sha256=07991DShQoYMBVyQl9Mh5xvXQSNQI2RXT2ZQ5fWiga4,690
113
- strawberry/fastapi/router.py,sha256=XdVgpNKyUfwNiqVSheXyWTNoODIbyxXY3imrLBZ_bYU,12242
113
+ strawberry/fastapi/router.py,sha256=yzu_z7jncHF4lmELpcosXC7W3NfQppn6bsHdsIMFGSg,11995
114
114
  strawberry/federation/__init__.py,sha256=FeUxLiBVuk9TKBmJJi51SeUaI8c80rS8hbl9No-hjII,535
115
115
  strawberry/federation/argument.py,sha256=2m_wgp7uFQDimTDDCBBqSoWeTop4MD1-KjjYrumEJIw,833
116
116
  strawberry/federation/enum.py,sha256=1rx50FiSMS-NjEFErhRSYB5no8TPsGMA_cH7hVbxAFI,3015
@@ -130,9 +130,9 @@ strawberry/file_uploads/scalars.py,sha256=NRDeB7j8aotqIkz9r62ISTf4DrxQxEZYUuHsX5
130
130
  strawberry/file_uploads/utils.py,sha256=2zsXg3QsKgGLD7of2dW-vgQn_Naf7I3Men9PhEAFYwM,1160
131
131
  strawberry/flask/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
132
132
  strawberry/flask/views.py,sha256=3gd1Xgxg3IT72dz2nrMBK094dMNxTUHciu3oofGOAG4,6235
133
- strawberry/http/__init__.py,sha256=GSvHUDXl1cHfLnb37PXOAnxfoXhvz0f467P1O8uDatM,1620
134
- strawberry/http/async_base_view.py,sha256=K9NAOd9pw2D-7bAAgU_o59mjIb5XlL0Ojrrm9ylhASY,15863
135
- strawberry/http/base.py,sha256=tEG39pgz4StQ_Xwk1CfOu0wxu9cb53zMfHhc4jaXHSM,2257
133
+ strawberry/http/__init__.py,sha256=ANVqO7G43gUzY4RCBvm1xyNZibf1SSfYnEdbdzxLhRI,1134
134
+ strawberry/http/async_base_view.py,sha256=prPO8MfNwPjoOIEQLHkC-miL-mprg7XYcrJI4JBYTbs,15852
135
+ strawberry/http/base.py,sha256=rfOH64-_b040YWRwqTCCA3ALjPoGxc110rmCxqfS4M4,2358
136
136
  strawberry/http/exceptions.py,sha256=9E2dreS1crRoJVUEPuHyx23NcDELDHNzkAOa-rGv-8I,348
137
137
  strawberry/http/ides.py,sha256=njYI2b5R0PnY27ll1ePdIvgPQU3m6Aod_JTBrcZYs0U,638
138
138
  strawberry/http/parse_content_type.py,sha256=sgtcOO_ZOFg7WWWibYyLc4SU58K-SErcW56kQczQmKU,412
@@ -141,7 +141,7 @@ strawberry/http/temporal_response.py,sha256=QrGYSg7Apu7Mh-X_uPKDZby-UicXw2J_ywxa
141
141
  strawberry/http/types.py,sha256=cAuaiUuvaMI_XhZ2Ey6Ej23WyQKqMGFxzzpVHDjVazY,371
142
142
  strawberry/http/typevars.py,sha256=8hK5PfNPZXb2EhZmqlobYyfwJJcO2Wb96T91MlLEVJs,450
143
143
  strawberry/litestar/__init__.py,sha256=zsXzg-mglCGUVO9iNXLm-yadoDSCK7k-zuyRqyvAh1w,237
144
- strawberry/litestar/controller.py,sha256=IsIZoRiuaoDfoioye6lifys4_9xX8sRjOV_7gM_x6x4,14090
144
+ strawberry/litestar/controller.py,sha256=5F7J0mbVzyDJCP1MJFpDp3kS6b82xrN33DA9ONHEOLs,14090
145
145
  strawberry/parent.py,sha256=sXURm0lauSpjUADsmfNGY-Zl7kHs0A67BFcWuWKzRxw,771
146
146
  strawberry/permission.py,sha256=rCJLK21cRNDQ6N9eSqcEiIUZiuCvF3FVOK3onXGai9E,7543
147
147
  strawberry/printer/__init__.py,sha256=DmepjmgtkdF5RxK_7yC6qUyRWn56U-9qeZMbkztYB9w,62
@@ -229,8 +229,8 @@ strawberry/utils/logging.py,sha256=U1cseHGquN09YFhFmRkiphfASKCyK0HUZREImPgVb0c,7
229
229
  strawberry/utils/operation.py,sha256=SSXxN-vMqdHO6W2OZtip-1z7y4_A-eTVFdhDvhKeLCk,1193
230
230
  strawberry/utils/str_converters.py,sha256=KGd7QH90RevaJjH6SQEkiVVsb8KuhJr_wv5AsI7UzQk,897
231
231
  strawberry/utils/typing.py,sha256=G6k2wWD1TDQ9WFk-Togekj_hTVFqHV-g7Phf2Wu41ms,14380
232
- strawberry_graphql-0.251.0.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
233
- strawberry_graphql-0.251.0.dist-info/METADATA,sha256=zGnSUBu5qpT4aH6iRSSagrmXlvJ4EhUOAIbQvZqSm_Q,7758
234
- strawberry_graphql-0.251.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
235
- strawberry_graphql-0.251.0.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
236
- strawberry_graphql-0.251.0.dist-info/RECORD,,
232
+ strawberry_graphql-0.253.0.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
233
+ strawberry_graphql-0.253.0.dist-info/METADATA,sha256=OaINI2ZdA8XCXFpWK_YH-v-3wMEM_62tr_tBlf7Cr6s,7758
234
+ strawberry_graphql-0.253.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
235
+ strawberry_graphql-0.253.0.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
236
+ strawberry_graphql-0.253.0.dist-info/RECORD,,