strawberry-graphql 0.263.0.dev1743450741__py3-none-any.whl → 0.263.0.dev1743582446__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/__init__.py +2 -0
- strawberry/annotation.py +7 -0
- strawberry/http/async_base_view.py +5 -3
- strawberry/streamable.py +36 -0
- {strawberry_graphql-0.263.0.dev1743450741.dist-info → strawberry_graphql-0.263.0.dev1743582446.dist-info}/METADATA +1 -1
- {strawberry_graphql-0.263.0.dev1743450741.dist-info → strawberry_graphql-0.263.0.dev1743582446.dist-info}/RECORD +9 -8
- {strawberry_graphql-0.263.0.dev1743450741.dist-info → strawberry_graphql-0.263.0.dev1743582446.dist-info}/LICENSE +0 -0
- {strawberry_graphql-0.263.0.dev1743450741.dist-info → strawberry_graphql-0.263.0.dev1743582446.dist-info}/WHEEL +0 -0
- {strawberry_graphql-0.263.0.dev1743450741.dist-info → strawberry_graphql-0.263.0.dev1743582446.dist-info}/entry_points.txt +0 -0
strawberry/__init__.py
CHANGED
@@ -11,6 +11,7 @@ from .permission import BasePermission
|
|
11
11
|
from .scalars import ID
|
12
12
|
from .schema import Schema
|
13
13
|
from .schema_directive import schema_directive
|
14
|
+
from .streamable import Streamable
|
14
15
|
from .types.arguments import argument
|
15
16
|
from .types.auto import auto
|
16
17
|
from .types.cast import cast
|
@@ -34,6 +35,7 @@ __all__ = [
|
|
34
35
|
"Parent",
|
35
36
|
"Private",
|
36
37
|
"Schema",
|
38
|
+
"Streamable",
|
37
39
|
"argument",
|
38
40
|
"asdict",
|
39
41
|
"auto",
|
strawberry/annotation.py
CHANGED
@@ -17,6 +17,7 @@ from typing import (
|
|
17
17
|
)
|
18
18
|
from typing_extensions import Self, get_args, get_origin
|
19
19
|
|
20
|
+
from strawberry.streamable import StrawberryStreamable
|
20
21
|
from strawberry.types.base import (
|
21
22
|
StrawberryList,
|
22
23
|
StrawberryObjectDefinition,
|
@@ -141,6 +142,8 @@ class StrawberryAnnotation:
|
|
141
142
|
|
142
143
|
if self._is_lazy_type(evaled_type):
|
143
144
|
return evaled_type
|
145
|
+
if self._is_streamable(evaled_type, args):
|
146
|
+
return self.create_list(list[evaled_type])
|
144
147
|
if self._is_list(evaled_type):
|
145
148
|
return self.create_list(evaled_type)
|
146
149
|
|
@@ -310,6 +313,10 @@ class StrawberryAnnotation:
|
|
310
313
|
or is_list
|
311
314
|
)
|
312
315
|
|
316
|
+
@classmethod
|
317
|
+
def _is_streamable(cls, annotation: Any, args: list[Any]) -> bool:
|
318
|
+
return any(isinstance(arg, StrawberryStreamable) for arg in args)
|
319
|
+
|
313
320
|
@classmethod
|
314
321
|
def _is_strawberry_type(cls, evaled_type: Any) -> bool:
|
315
322
|
# Prevent import cycles
|
@@ -367,6 +367,8 @@ class AsyncBaseHTTPView(
|
|
367
367
|
|
368
368
|
yield self.encode_multipart_data(response, "-")
|
369
369
|
|
370
|
+
all_pending = result.initial_result.pending
|
371
|
+
|
370
372
|
async for value in result.subsequent_results:
|
371
373
|
response = {
|
372
374
|
"hasNext": value.has_next,
|
@@ -382,11 +384,13 @@ class AsyncBaseHTTPView(
|
|
382
384
|
if value.incremental:
|
383
385
|
incremental = []
|
384
386
|
|
387
|
+
all_pending.extend(value.pending)
|
388
|
+
|
385
389
|
for incremental_value in value.incremental:
|
386
390
|
pending_value = next(
|
387
391
|
(
|
388
392
|
v
|
389
|
-
for v in
|
393
|
+
for v in all_pending
|
390
394
|
if v.id == incremental_value.id
|
391
395
|
),
|
392
396
|
None,
|
@@ -397,8 +401,6 @@ class AsyncBaseHTTPView(
|
|
397
401
|
incremental.append(
|
398
402
|
{
|
399
403
|
**incremental_value.formatted,
|
400
|
-
# for Apollo
|
401
|
-
# content type is `multipart/mixed;deferSpec=20220824,application/json`
|
402
404
|
"path": pending_value.path,
|
403
405
|
"label": pending_value.label,
|
404
406
|
}
|
strawberry/streamable.py
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
from collections.abc import AsyncGenerator
|
2
|
+
from typing import Annotated, TypeVar
|
3
|
+
|
4
|
+
|
5
|
+
class StrawberryStreamable: ...
|
6
|
+
|
7
|
+
|
8
|
+
T = TypeVar("T")
|
9
|
+
|
10
|
+
Streamable = Annotated[AsyncGenerator[T, None], StrawberryStreamable()]
|
11
|
+
"""Represents a list that can be streamed using @stream.
|
12
|
+
|
13
|
+
Example:
|
14
|
+
|
15
|
+
```python
|
16
|
+
import strawberry
|
17
|
+
from dataclasses import dataclass
|
18
|
+
|
19
|
+
|
20
|
+
@strawberry.type
|
21
|
+
class Comment:
|
22
|
+
id: strawberry.ID
|
23
|
+
content: str
|
24
|
+
|
25
|
+
|
26
|
+
@strawberry.type
|
27
|
+
class Article:
|
28
|
+
@strawberry.field
|
29
|
+
@staticmethod
|
30
|
+
async def comments() -> strawberry.Streamable[Comment]:
|
31
|
+
for comment in fetch_comments():
|
32
|
+
yield comment
|
33
|
+
```
|
34
|
+
"""
|
35
|
+
|
36
|
+
__all__ = ["Streamable"]
|
@@ -1,10 +1,10 @@
|
|
1
|
-
strawberry/__init__.py,sha256=
|
1
|
+
strawberry/__init__.py,sha256=HqViVAW5hyZLiG0CvWgLvdBotbbDAimuGgKSzevP-O8,1482
|
2
2
|
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=8FKZTnvawxYpgEICOri-34O3wHRHLhRpjH_Ktp2EupQ,1801
|
6
6
|
strawberry/aiohttp/views.py,sha256=JXYd_qO_LD4QbRJ7iAnZbEsezwvPOmTujTGNAb75bRU,7885
|
7
|
-
strawberry/annotation.py,sha256=
|
7
|
+
strawberry/annotation.py,sha256=V7OrkVk8anXg1teACmxr3tWA7Q9daT-1Xeo-kN0P1fc,13362
|
8
8
|
strawberry/asgi/__init__.py,sha256=55tsJmqIPlQgeScDUQuADalLlN5ymdHOeFHWzyII7aY,8167
|
9
9
|
strawberry/asgi/test/__init__.py,sha256=4xxdUZtIISSOwjrcnmox7AvT4WWjowCm5bUuPdQneMg,71
|
10
10
|
strawberry/asgi/test/client.py,sha256=kp2O5znHWuAB5VVYO8p4XPSTEDDXBSjNz5WHqW0r6GM,1473
|
@@ -131,7 +131,7 @@ strawberry/file_uploads/utils.py,sha256=-c6TbqUI-Dkb96hWCrZabh6TL2OabBuQNkCarOqg
|
|
131
131
|
strawberry/flask/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
132
132
|
strawberry/flask/views.py,sha256=HmkqZrO6KSBSM-yNbJkBR34Q5n7oVsTsuCzt2Og5Zws,6351
|
133
133
|
strawberry/http/__init__.py,sha256=ElFPdSzecCIEFCyaqvlWVrc_NQCuRaa8CcAj0YlL9Qc,1225
|
134
|
-
strawberry/http/async_base_view.py,sha256=
|
134
|
+
strawberry/http/async_base_view.py,sha256=FqhtxyzidawBaVnsPdHuikhZQ-g1BXC34imzbkPSgsY,19149
|
135
135
|
strawberry/http/base.py,sha256=Lz-u5SWg2uQp3l5GMKZDPQuJOR42LXHgjV1PZHwiapE,2373
|
136
136
|
strawberry/http/exceptions.py,sha256=9E2dreS1crRoJVUEPuHyx23NcDELDHNzkAOa-rGv-8I,348
|
137
137
|
strawberry/http/ides.py,sha256=WjU0nsMDgr3Bd1ebWkUEkO2d1hk0dI16mLqXyCHqklA,613
|
@@ -182,6 +182,7 @@ strawberry/schema_directives.py,sha256=KGKFWCODjm1Ah9qNV_bBwbic7Mld4qLWnWQkev-PG
|
|
182
182
|
strawberry/static/apollo-sandbox.html,sha256=2XzkbE0dqsFHqehE-jul9_J9TFOpwA6Ylrlo0Kdx_9w,973
|
183
183
|
strawberry/static/graphiql.html,sha256=0e3pvTnAet-lNEqA_pgJ8Ak2CdMt34zPKMMMzpAkEVU,4257
|
184
184
|
strawberry/static/pathfinder.html,sha256=0DPx9AmJ2C_sJstFXnWOz9k5tVQHeHaK7qdVY4lAlmk,1547
|
185
|
+
strawberry/streamable.py,sha256=ylfMt5lfX7RRKGi86wWokvIgYQk5jZCvQVc3shK0epk,645
|
185
186
|
strawberry/subscriptions/__init__.py,sha256=1VGmiCzFepqRFyCikagkUoHHdoTG3XYlFu9GafoQMws,170
|
186
187
|
strawberry/subscriptions/protocols/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
187
188
|
strawberry/subscriptions/protocols/graphql_transport_ws/__init__.py,sha256=wN6dkMu6WiaIZTE19PGoN9xXpIN_RdDE_q7F7ZgjCxk,138
|
@@ -229,8 +230,8 @@ strawberry/utils/logging.py,sha256=U1cseHGquN09YFhFmRkiphfASKCyK0HUZREImPgVb0c,7
|
|
229
230
|
strawberry/utils/operation.py,sha256=SSXxN-vMqdHO6W2OZtip-1z7y4_A-eTVFdhDvhKeLCk,1193
|
230
231
|
strawberry/utils/str_converters.py,sha256=-eH1Cl16IO_wrBlsGM-km4IY0IKsjhjnSNGRGOwQjVM,897
|
231
232
|
strawberry/utils/typing.py,sha256=Ux0Hl46lhuXvOKK-C5hj6nlz3zDn8P4CUGH2nUVD2vU,13373
|
232
|
-
strawberry_graphql-0.263.0.
|
233
|
-
strawberry_graphql-0.263.0.
|
234
|
-
strawberry_graphql-0.263.0.
|
235
|
-
strawberry_graphql-0.263.0.
|
236
|
-
strawberry_graphql-0.263.0.
|
233
|
+
strawberry_graphql-0.263.0.dev1743582446.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
|
234
|
+
strawberry_graphql-0.263.0.dev1743582446.dist-info/METADATA,sha256=73gMhx8_cf8CTQ1R9ZUYPqZZyKDtMAbSMAsizaroWpg,7693
|
235
|
+
strawberry_graphql-0.263.0.dev1743582446.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
|
236
|
+
strawberry_graphql-0.263.0.dev1743582446.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
|
237
|
+
strawberry_graphql-0.263.0.dev1743582446.dist-info/RECORD,,
|
File without changes
|
File without changes
|