strawberry-graphql 0.270.4__py3-none-any.whl → 0.270.6__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/ext/dataclasses/README.md +40 -0
- strawberry/subscriptions/protocols/graphql_transport_ws/handlers.py +9 -4
- strawberry/subscriptions/protocols/graphql_ws/handlers.py +7 -1
- strawberry/tools/create_type.py +8 -3
- {strawberry_graphql-0.270.4.dist-info → strawberry_graphql-0.270.6.dist-info}/METADATA +1 -1
- {strawberry_graphql-0.270.4.dist-info → strawberry_graphql-0.270.6.dist-info}/RECORD +9 -8
- {strawberry_graphql-0.270.4.dist-info → strawberry_graphql-0.270.6.dist-info}/LICENSE +0 -0
- {strawberry_graphql-0.270.4.dist-info → strawberry_graphql-0.270.6.dist-info}/WHEEL +0 -0
- {strawberry_graphql-0.270.4.dist-info → strawberry_graphql-0.270.6.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,40 @@
|
|
1
|
+
# Additional information
|
2
|
+
|
3
|
+
This folder contains file(s) or code that is originally taken from other
|
4
|
+
projects and got further adaptations by the maintainers of Strawberry.
|
5
|
+
|
6
|
+
## `dataclasses.py`
|
7
|
+
|
8
|
+
The file
|
9
|
+
[dataclasses.py](https://github.com/strawberry-graphql/strawberry/tree/main/strawberry/ext/dataclasses/dataclasses.py)
|
10
|
+
which is based on
|
11
|
+
https://github.com/python/cpython/blob/v3.9.6/Lib/dataclasses.py#L489-L536
|
12
|
+
but has got some small adjustments in the adopted function
|
13
|
+
`dataclass_init_fn()` so the functionality is fitting the desired
|
14
|
+
requirements within Strawberry.
|
15
|
+
|
16
|
+
From the docstring of `dataclass_init_fn()`:
|
17
|
+
|
18
|
+
```
|
19
|
+
"""
|
20
|
+
Create an __init__ function for a dataclass.
|
21
|
+
|
22
|
+
We create a custom __init__ function for the dataclasses that back
|
23
|
+
Strawberry object types to only accept keyword arguments. This allows us to
|
24
|
+
avoid the problem where a type cannot define a field with a default value
|
25
|
+
before a field that doesn't have a default value.
|
26
|
+
|
27
|
+
An example of the problem:
|
28
|
+
https://stackoverflow.com/questions/51575931/class-inheritance-in-python-3-7-dataclasses
|
29
|
+
|
30
|
+
Code is adapted from:
|
31
|
+
https://github.com/python/cpython/blob/v3.9.6/Lib/dataclasses.py#L489-L536
|
32
|
+
|
33
|
+
Note: in Python 3.10 and above we use the `kw_only` argument to achieve the
|
34
|
+
same result.
|
35
|
+
"""
|
36
|
+
```
|
37
|
+
|
38
|
+
The file was added so kwargs could be enforced on Python classes within
|
39
|
+
Strawberry.
|
40
|
+
See also the file LICENSE for copyright information.
|
@@ -216,13 +216,18 @@ class BaseGraphQLTransportWSHandler(Generic[Context, RootValue]):
|
|
216
216
|
await self.websocket.close(code=4400, reason=exc.message)
|
217
217
|
return
|
218
218
|
|
219
|
+
operation_name = message["payload"].get("operationName")
|
220
|
+
|
219
221
|
try:
|
220
|
-
operation_type = get_operation_type(
|
221
|
-
graphql_document, message["payload"].get("operationName")
|
222
|
-
)
|
222
|
+
operation_type = get_operation_type(graphql_document, operation_name)
|
223
223
|
except RuntimeError:
|
224
224
|
await self.websocket.close(
|
225
|
-
code=4400,
|
225
|
+
code=4400,
|
226
|
+
reason=(
|
227
|
+
f'Unknown operation named "{operation_name}".'
|
228
|
+
if operation_name
|
229
|
+
else "Can't get GraphQL operation type"
|
230
|
+
),
|
226
231
|
)
|
227
232
|
return
|
228
233
|
|
@@ -199,7 +199,13 @@ class BaseGraphQLWSHandler(Generic[Context, RootValue]):
|
|
199
199
|
ErrorMessage(
|
200
200
|
type="error",
|
201
201
|
id=operation_id,
|
202
|
-
payload={
|
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
|
+
},
|
203
209
|
)
|
204
210
|
)
|
205
211
|
except asyncio.CancelledError:
|
strawberry/tools/create_type.py
CHANGED
@@ -50,15 +50,20 @@ def create_type(
|
|
50
50
|
if not isinstance(field, StrawberryField):
|
51
51
|
raise TypeError("Field is not an instance of StrawberryField")
|
52
52
|
|
53
|
-
|
53
|
+
# Fields created using `strawberry.field` without a resolver don't have a
|
54
|
+
# `python_name`. In that case, we fall back to the field's `graphql_name`
|
55
|
+
# set via the `name` argument passed to `strawberry.field`.
|
56
|
+
field_name = field.python_name or field.graphql_name
|
57
|
+
|
58
|
+
if field_name is None:
|
54
59
|
raise ValueError(
|
55
60
|
"Field doesn't have a name. Fields passed to "
|
56
61
|
"`create_type` must define a name by passing the "
|
57
62
|
"`name` argument to `strawberry.field`."
|
58
63
|
)
|
59
64
|
|
60
|
-
namespace[
|
61
|
-
annotations[
|
65
|
+
namespace[field_name] = field
|
66
|
+
annotations[field_name] = field.type
|
62
67
|
|
63
68
|
namespace["__annotations__"] = annotations # type: ignore
|
64
69
|
|
@@ -84,6 +84,7 @@ strawberry/experimental/pydantic/utils.py,sha256=URSzmcK2KzNGsLv4RyFdFfJnr-ARNLk
|
|
84
84
|
strawberry/ext/LICENSE,sha256=_oY0TZg0b_sW0--0T44aMTpy2e2zF1Kiyn8E1qDiivo,1249
|
85
85
|
strawberry/ext/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
86
86
|
strawberry/ext/dataclasses/LICENSE,sha256=WZgm35K_3NJwLqxpEHJJi7CWxVrwTumEz5D3Dtd7WnA,13925
|
87
|
+
strawberry/ext/dataclasses/README.md,sha256=WE3523o9gBGpa18ikiQhgEUNuuBJWR5tMKmjicrLOHU,1389
|
87
88
|
strawberry/ext/dataclasses/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
88
89
|
strawberry/ext/dataclasses/dataclasses.py,sha256=bTW8nRwflW7_JtGhzXiKhe9Kajha_fgCfR0jVKrCzBw,2287
|
89
90
|
strawberry/ext/mypy_plugin.py,sha256=KqpEWUnQftmmlC0CtK33H1FMR7P-WdI-F9Evnc60Mm0,20458
|
@@ -184,15 +185,15 @@ strawberry/static/pathfinder.html,sha256=0DPx9AmJ2C_sJstFXnWOz9k5tVQHeHaK7qdVY4l
|
|
184
185
|
strawberry/subscriptions/__init__.py,sha256=1VGmiCzFepqRFyCikagkUoHHdoTG3XYlFu9GafoQMws,170
|
185
186
|
strawberry/subscriptions/protocols/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
186
187
|
strawberry/subscriptions/protocols/graphql_transport_ws/__init__.py,sha256=wN6dkMu6WiaIZTE19PGoN9xXpIN_RdDE_q7F7ZgjCxk,138
|
187
|
-
strawberry/subscriptions/protocols/graphql_transport_ws/handlers.py,sha256=
|
188
|
+
strawberry/subscriptions/protocols/graphql_transport_ws/handlers.py,sha256=8F93epfxwktsAgTF7_TwC-9kBnjrzOpF-McEV36xEVw,15257
|
188
189
|
strawberry/subscriptions/protocols/graphql_transport_ws/types.py,sha256=N9r2mXg5jmmjYoZV5rWf3lAzgylCOUrbKGmClXCoOso,2169
|
189
190
|
strawberry/subscriptions/protocols/graphql_ws/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
190
|
-
strawberry/subscriptions/protocols/graphql_ws/handlers.py,sha256=
|
191
|
+
strawberry/subscriptions/protocols/graphql_ws/handlers.py,sha256=5mFyfP3brn0aS3SmeF7-z2vWTS2NhsLTD3JVE1zbr6k,8891
|
191
192
|
strawberry/subscriptions/protocols/graphql_ws/types.py,sha256=Uumiz-1O5qQnx-ERBaQtaf7db5yx-V9LMypOn9oGKwM,2003
|
192
193
|
strawberry/test/__init__.py,sha256=lKVbKJDBnrYSPYHIKrg54UpaZcSoL93Z01zOpA1IzZM,115
|
193
194
|
strawberry/test/client.py,sha256=ILAttb6A3jplH5wJNMeyyT1u_Q8KnollfpYLP_BVZR4,6438
|
194
195
|
strawberry/tools/__init__.py,sha256=pdGpZx8wpq03VfUZJyF9JtYxZhGqzzxCiipsalWxJX4,127
|
195
|
-
strawberry/tools/create_type.py,sha256
|
196
|
+
strawberry/tools/create_type.py,sha256=y10LgJnWDFtZB-xHLqpVg5ySqvz5KSFC6PNflogie1Q,2329
|
196
197
|
strawberry/tools/merge_types.py,sha256=hUMRRNM28FyPp70jRA3d4svv9WoEBjaNpihBt3DaY0I,1023
|
197
198
|
strawberry/types/__init__.py,sha256=baWEdDkkmCcITOhkg2hNUOenrNV1OYdxGE5qgvIRwwU,351
|
198
199
|
strawberry/types/arguments.py,sha256=DVouyH70uvTcFP3PmRzo8QdMThoqXdigJbWE9Lgn5pU,9849
|
@@ -229,8 +230,8 @@ strawberry/utils/logging.py,sha256=U1cseHGquN09YFhFmRkiphfASKCyK0HUZREImPgVb0c,7
|
|
229
230
|
strawberry/utils/operation.py,sha256=s7ajvLg_q6v2mg47kEMQPjO_J-XluMKTCwo4d47mGvE,1195
|
230
231
|
strawberry/utils/str_converters.py,sha256=-eH1Cl16IO_wrBlsGM-km4IY0IKsjhjnSNGRGOwQjVM,897
|
231
232
|
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.
|
233
|
+
strawberry_graphql-0.270.6.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
|
234
|
+
strawberry_graphql-0.270.6.dist-info/METADATA,sha256=hiHH8w95HcNw-GZSfgFZYts7rHTL2zLBZiGtoBwaUP4,7757
|
235
|
+
strawberry_graphql-0.270.6.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
236
|
+
strawberry_graphql-0.270.6.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
|
237
|
+
strawberry_graphql-0.270.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|
{strawberry_graphql-0.270.4.dist-info → strawberry_graphql-0.270.6.dist-info}/entry_points.txt
RENAMED
File without changes
|