strawberry-graphql 0.250.1__py3-none-any.whl → 0.252.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/aiohttp/views.py +7 -4
- strawberry/asgi/__init__.py +8 -4
- strawberry/channels/handlers/ws_handler.py +10 -5
- strawberry/django/views.py +2 -2
- strawberry/http/async_base_view.py +7 -3
- strawberry/http/base.py +6 -4
- strawberry/litestar/controller.py +7 -4
- {strawberry_graphql-0.250.1.dist-info → strawberry_graphql-0.252.0.dist-info}/METADATA +1 -1
- {strawberry_graphql-0.250.1.dist-info → strawberry_graphql-0.252.0.dist-info}/RECORD +12 -12
- {strawberry_graphql-0.250.1.dist-info → strawberry_graphql-0.252.0.dist-info}/LICENSE +0 -0
- {strawberry_graphql-0.250.1.dist-info → strawberry_graphql-0.252.0.dist-info}/WHEEL +0 -0
- {strawberry_graphql-0.250.1.dist-info → strawberry_graphql-0.252.0.dist-info}/entry_points.txt +0 -0
strawberry/aiohttp/views.py
CHANGED
@@ -87,17 +87,20 @@ class AioHTTPRequestAdapter(AsyncHTTPRequestAdapter):
|
|
87
87
|
|
88
88
|
|
89
89
|
class AioHTTPWebSocketAdapter(AsyncWebSocketAdapter):
|
90
|
-
def __init__(
|
90
|
+
def __init__(
|
91
|
+
self, view: AsyncBaseHTTPView, request: web.Request, ws: web.WebSocketResponse
|
92
|
+
) -> None:
|
93
|
+
super().__init__(view)
|
91
94
|
self.request = request
|
92
95
|
self.ws = ws
|
93
96
|
|
94
97
|
async def iter_json(
|
95
98
|
self, *, ignore_parsing_errors: bool = False
|
96
|
-
) -> AsyncGenerator[
|
99
|
+
) -> AsyncGenerator[object, None]:
|
97
100
|
async for ws_message in self.ws:
|
98
101
|
if ws_message.type == http.WSMsgType.TEXT:
|
99
102
|
try:
|
100
|
-
yield ws_message.
|
103
|
+
yield self.view.decode_json(ws_message.data)
|
101
104
|
except JSONDecodeError:
|
102
105
|
if not ignore_parsing_errors:
|
103
106
|
raise NonJsonMessageReceived()
|
@@ -107,7 +110,7 @@ class AioHTTPWebSocketAdapter(AsyncWebSocketAdapter):
|
|
107
110
|
|
108
111
|
async def send_json(self, message: Mapping[str, object]) -> None:
|
109
112
|
try:
|
110
|
-
await self.ws.
|
113
|
+
await self.ws.send_str(self.view.encode_json(message))
|
111
114
|
except RuntimeError as exc:
|
112
115
|
raise WebSocketDisconnected from exc
|
113
116
|
|
strawberry/asgi/__init__.py
CHANGED
@@ -87,16 +87,20 @@ class ASGIRequestAdapter(AsyncHTTPRequestAdapter):
|
|
87
87
|
|
88
88
|
|
89
89
|
class ASGIWebSocketAdapter(AsyncWebSocketAdapter):
|
90
|
-
def __init__(
|
90
|
+
def __init__(
|
91
|
+
self, view: AsyncBaseHTTPView, request: WebSocket, response: WebSocket
|
92
|
+
) -> None:
|
93
|
+
super().__init__(view)
|
91
94
|
self.ws = response
|
92
95
|
|
93
96
|
async def iter_json(
|
94
97
|
self, *, ignore_parsing_errors: bool = False
|
95
|
-
) -> AsyncGenerator[
|
98
|
+
) -> AsyncGenerator[object, None]:
|
96
99
|
try:
|
97
100
|
while self.ws.application_state != WebSocketState.DISCONNECTED:
|
98
101
|
try:
|
99
|
-
|
102
|
+
text = await self.ws.receive_text()
|
103
|
+
yield self.view.decode_json(text)
|
100
104
|
except JSONDecodeError: # noqa: PERF203
|
101
105
|
if not ignore_parsing_errors:
|
102
106
|
raise NonJsonMessageReceived()
|
@@ -107,7 +111,7 @@ class ASGIWebSocketAdapter(AsyncWebSocketAdapter):
|
|
107
111
|
|
108
112
|
async def send_json(self, message: Mapping[str, object]) -> None:
|
109
113
|
try:
|
110
|
-
await self.ws.
|
114
|
+
await self.ws.send_text(self.view.encode_json(message))
|
111
115
|
except WebSocketDisconnect as exc:
|
112
116
|
raise WebSocketDisconnected from exc
|
113
117
|
|
@@ -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,
|
@@ -28,12 +27,18 @@ if TYPE_CHECKING:
|
|
28
27
|
|
29
28
|
|
30
29
|
class ChannelsWebSocketAdapter(AsyncWebSocketAdapter):
|
31
|
-
def __init__(
|
30
|
+
def __init__(
|
31
|
+
self,
|
32
|
+
view: AsyncBaseHTTPView,
|
33
|
+
request: GraphQLWSConsumer,
|
34
|
+
response: GraphQLWSConsumer,
|
35
|
+
) -> None:
|
36
|
+
super().__init__(view)
|
32
37
|
self.ws_consumer = response
|
33
38
|
|
34
39
|
async def iter_json(
|
35
40
|
self, *, ignore_parsing_errors: bool = False
|
36
|
-
) -> AsyncGenerator[
|
41
|
+
) -> AsyncGenerator[object, None]:
|
37
42
|
while True:
|
38
43
|
message = await self.ws_consumer.message_queue.get()
|
39
44
|
|
@@ -44,13 +49,13 @@ class ChannelsWebSocketAdapter(AsyncWebSocketAdapter):
|
|
44
49
|
raise NonTextMessageReceived()
|
45
50
|
|
46
51
|
try:
|
47
|
-
yield
|
52
|
+
yield self.view.decode_json(message["message"])
|
48
53
|
except json.JSONDecodeError:
|
49
54
|
if not ignore_parsing_errors:
|
50
55
|
raise NonJsonMessageReceived()
|
51
56
|
|
52
57
|
async def send_json(self, message: Mapping[str, object]) -> None:
|
53
|
-
serialized_message =
|
58
|
+
serialized_message = self.view.encode_json(message)
|
54
59
|
await self.ws_consumer.send(serialized_message)
|
55
60
|
|
56
61
|
async def close(self, code: int, reason: str) -> None:
|
strawberry/django/views.py
CHANGED
@@ -201,8 +201,8 @@ class BaseView:
|
|
201
201
|
},
|
202
202
|
)
|
203
203
|
|
204
|
-
def encode_json(self,
|
205
|
-
return json.dumps(
|
204
|
+
def encode_json(self, data: object) -> str:
|
205
|
+
return json.dumps(data, cls=DjangoJSONEncoder)
|
206
206
|
|
207
207
|
|
208
208
|
class GraphQLView(
|
@@ -80,10 +80,13 @@ class AsyncHTTPRequestAdapter(abc.ABC):
|
|
80
80
|
|
81
81
|
|
82
82
|
class AsyncWebSocketAdapter(abc.ABC):
|
83
|
+
def __init__(self, view: "AsyncBaseHTTPView") -> None:
|
84
|
+
self.view = view
|
85
|
+
|
83
86
|
@abc.abstractmethod
|
84
87
|
def iter_json(
|
85
88
|
self, *, ignore_parsing_errors: bool = False
|
86
|
-
) -> AsyncGenerator[
|
89
|
+
) -> AsyncGenerator[object, None]: ...
|
87
90
|
|
88
91
|
@abc.abstractmethod
|
89
92
|
async def send_json(self, message: Mapping[str, object]) -> None: ...
|
@@ -113,7 +116,8 @@ class AsyncBaseHTTPView(
|
|
113
116
|
connection_init_wait_timeout: timedelta = timedelta(minutes=1)
|
114
117
|
request_adapter_class: Callable[[Request], AsyncHTTPRequestAdapter]
|
115
118
|
websocket_adapter_class: Callable[
|
116
|
-
[WebSocketRequest, WebSocketResponse],
|
119
|
+
["AsyncBaseHTTPView", WebSocketRequest, WebSocketResponse],
|
120
|
+
AsyncWebSocketAdapter,
|
117
121
|
]
|
118
122
|
graphql_transport_ws_handler_class = BaseGraphQLTransportWSHandler
|
119
123
|
graphql_ws_handler_class = BaseGraphQLWSHandler
|
@@ -265,7 +269,7 @@ class AsyncBaseHTTPView(
|
|
265
269
|
websocket_response = await self.create_websocket_response(
|
266
270
|
request, websocket_subprotocol
|
267
271
|
)
|
268
|
-
websocket = self.websocket_adapter_class(request, websocket_response)
|
272
|
+
websocket = self.websocket_adapter_class(self, request, websocket_response)
|
269
273
|
|
270
274
|
context = (
|
271
275
|
await self.get_context(request, response=websocket_response)
|
strawberry/http/base.py
CHANGED
@@ -2,7 +2,6 @@ import json
|
|
2
2
|
from typing import Any, Dict, Generic, List, Mapping, Optional, Union
|
3
3
|
from typing_extensions import Protocol
|
4
4
|
|
5
|
-
from strawberry.http import GraphQLHTTPResponse
|
6
5
|
from strawberry.http.ides import GraphQL_IDE, get_graphql_ide_html
|
7
6
|
from strawberry.http.types import HTTPMethod, QueryParams
|
8
7
|
|
@@ -40,12 +39,15 @@ class BaseView(Generic[Request]):
|
|
40
39
|
|
41
40
|
def parse_json(self, data: Union[str, bytes]) -> Any:
|
42
41
|
try:
|
43
|
-
return
|
42
|
+
return self.decode_json(data)
|
44
43
|
except json.JSONDecodeError as e:
|
45
44
|
raise HTTPException(400, "Unable to parse request body as JSON") from e
|
46
45
|
|
47
|
-
def
|
48
|
-
return json.
|
46
|
+
def decode_json(self, data: Union[str, bytes]) -> object:
|
47
|
+
return json.loads(data)
|
48
|
+
|
49
|
+
def encode_json(self, data: object) -> str:
|
50
|
+
return json.dumps(data)
|
49
51
|
|
50
52
|
def parse_query_params(self, params: QueryParams) -> Dict[str, Any]:
|
51
53
|
params = dict(params)
|
@@ -194,12 +194,15 @@ class LitestarRequestAdapter(AsyncHTTPRequestAdapter):
|
|
194
194
|
|
195
195
|
|
196
196
|
class LitestarWebSocketAdapter(AsyncWebSocketAdapter):
|
197
|
-
def __init__(
|
197
|
+
def __init__(
|
198
|
+
self, view: AsyncBaseHTTPView, request: WebSocket, response: WebSocket
|
199
|
+
) -> None:
|
200
|
+
super().__init__(view)
|
198
201
|
self.ws = response
|
199
202
|
|
200
203
|
async def iter_json(
|
201
204
|
self, *, ignore_parsing_errors: bool = False
|
202
|
-
) -> AsyncGenerator[
|
205
|
+
) -> AsyncGenerator[object, None]:
|
203
206
|
try:
|
204
207
|
while self.ws.connection_state != "disconnect":
|
205
208
|
text = await self.ws.receive_text()
|
@@ -209,7 +212,7 @@ class LitestarWebSocketAdapter(AsyncWebSocketAdapter):
|
|
209
212
|
raise NonTextMessageReceived()
|
210
213
|
|
211
214
|
try:
|
212
|
-
yield
|
215
|
+
yield self.view.decode_json(text)
|
213
216
|
except json.JSONDecodeError:
|
214
217
|
if not ignore_parsing_errors:
|
215
218
|
raise NonJsonMessageReceived()
|
@@ -218,7 +221,7 @@ class LitestarWebSocketAdapter(AsyncWebSocketAdapter):
|
|
218
221
|
|
219
222
|
async def send_json(self, message: Mapping[str, object]) -> None:
|
220
223
|
try:
|
221
|
-
await self.ws.
|
224
|
+
await self.ws.send_data(data=self.view.encode_json(message))
|
222
225
|
except WebSocketDisconnect as exc:
|
223
226
|
raise WebSocketDisconnected from exc
|
224
227
|
|
@@ -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=
|
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=
|
8
|
+
strawberry/asgi/__init__.py,sha256=Pixb9ldPltXl-TChhF6zkmiyjxol-zu8PPmfWeDqExA,8130
|
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=
|
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=
|
52
|
+
strawberry/django/views.py,sha256=jPb_J6-bXd_xb478Cv0nR5eLtRZN8CgvxlopkhckgJQ,9542
|
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
|
@@ -131,8 +131,8 @@ strawberry/file_uploads/utils.py,sha256=2zsXg3QsKgGLD7of2dW-vgQn_Naf7I3Men9PhEAF
|
|
131
131
|
strawberry/flask/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
132
132
|
strawberry/flask/views.py,sha256=3gd1Xgxg3IT72dz2nrMBK094dMNxTUHciu3oofGOAG4,6235
|
133
133
|
strawberry/http/__init__.py,sha256=GSvHUDXl1cHfLnb37PXOAnxfoXhvz0f467P1O8uDatM,1620
|
134
|
-
strawberry/http/async_base_view.py,sha256=
|
135
|
-
strawberry/http/base.py,sha256=
|
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=
|
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.
|
233
|
-
strawberry_graphql-0.
|
234
|
-
strawberry_graphql-0.
|
235
|
-
strawberry_graphql-0.
|
236
|
-
strawberry_graphql-0.
|
232
|
+
strawberry_graphql-0.252.0.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
|
233
|
+
strawberry_graphql-0.252.0.dist-info/METADATA,sha256=mMPtQtkqL-J5eRrC7agzkiowJdN2Ld-mXt0MW5_28Nc,7758
|
234
|
+
strawberry_graphql-0.252.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
235
|
+
strawberry_graphql-0.252.0.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
|
236
|
+
strawberry_graphql-0.252.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
{strawberry_graphql-0.250.1.dist-info → strawberry_graphql-0.252.0.dist-info}/entry_points.txt
RENAMED
File without changes
|