strawberry-graphql 0.288.1__py3-none-any.whl → 0.288.3__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/types/arguments.py +10 -0
- strawberry/types/maybe.py +5 -2
- strawberry/types/object_type.py +9 -2
- {strawberry_graphql-0.288.1.dist-info → strawberry_graphql-0.288.3.dist-info}/METADATA +1 -1
- {strawberry_graphql-0.288.1.dist-info → strawberry_graphql-0.288.3.dist-info}/RECORD +8 -8
- {strawberry_graphql-0.288.1.dist-info → strawberry_graphql-0.288.3.dist-info}/WHEEL +0 -0
- {strawberry_graphql-0.288.1.dist-info → strawberry_graphql-0.288.3.dist-info}/entry_points.txt +0 -0
- {strawberry_graphql-0.288.1.dist-info → strawberry_graphql-0.288.3.dist-info}/licenses/LICENSE +0 -0
strawberry/types/arguments.py
CHANGED
|
@@ -195,6 +195,16 @@ def convert_argument(
|
|
|
195
195
|
|
|
196
196
|
return Some(res)
|
|
197
197
|
|
|
198
|
+
if value is None:
|
|
199
|
+
from strawberry.exceptions import StrawberryGraphQLError
|
|
200
|
+
|
|
201
|
+
type_name = getattr(type_.of_type, "__name__", str(type_.of_type))
|
|
202
|
+
raise StrawberryGraphQLError(
|
|
203
|
+
f"Expected value of type '{type_name}', found null. "
|
|
204
|
+
f"Field of type 'Maybe[{type_name}]' cannot be explicitly set to null. "
|
|
205
|
+
f"Use 'Maybe[{type_name} | None]' if you need to allow null values."
|
|
206
|
+
)
|
|
207
|
+
|
|
198
208
|
# This is Maybe[T] - validation for null values is handled by MaybeNullValidationRule
|
|
199
209
|
# Convert the value and wrap in Some()
|
|
200
210
|
res = convert_argument(value, type_.of_type, scalar_registry, config)
|
strawberry/types/maybe.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import re
|
|
2
2
|
import typing
|
|
3
|
-
from typing import TYPE_CHECKING, Any, Generic, TypeAlias, TypeVar
|
|
3
|
+
from typing import TYPE_CHECKING, Annotated, Any, Generic, TypeAlias, TypeVar
|
|
4
4
|
|
|
5
5
|
T = TypeVar("T")
|
|
6
6
|
|
|
@@ -47,7 +47,10 @@ def _annotation_is_maybe(annotation: Any) -> bool:
|
|
|
47
47
|
# Checking for the pattern should be good enough for now.
|
|
48
48
|
return _maybe_re.match(annotation) is not None
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
orig = typing.get_origin(annotation)
|
|
51
|
+
if orig is Annotated:
|
|
52
|
+
return _annotation_is_maybe(typing.get_args(annotation)[0])
|
|
53
|
+
return orig is Maybe
|
|
51
54
|
|
|
52
55
|
|
|
53
56
|
__all__ = [
|
strawberry/types/object_type.py
CHANGED
|
@@ -109,8 +109,15 @@ def _inject_default_for_maybe_annotations(
|
|
|
109
109
|
) -> None:
|
|
110
110
|
"""Inject `= None` for fields with `Maybe` annotations and no default value."""
|
|
111
111
|
for name, annotation in annotations.copy().items():
|
|
112
|
-
if _annotation_is_maybe(annotation)
|
|
113
|
-
|
|
112
|
+
if _annotation_is_maybe(annotation):
|
|
113
|
+
if not hasattr(cls, name):
|
|
114
|
+
setattr(cls, name, None)
|
|
115
|
+
elif (
|
|
116
|
+
isinstance(attr := getattr(cls, name), StrawberryField)
|
|
117
|
+
and attr.default is dataclasses.MISSING
|
|
118
|
+
and attr.default_factory is dataclasses.MISSING
|
|
119
|
+
):
|
|
120
|
+
attr.default = None
|
|
114
121
|
|
|
115
122
|
|
|
116
123
|
def _process_type(
|
|
@@ -206,7 +206,7 @@ strawberry/tools/__init__.py,sha256=pdGpZx8wpq03VfUZJyF9JtYxZhGqzzxCiipsalWxJX4,
|
|
|
206
206
|
strawberry/tools/create_type.py,sha256=lYnqXMaecEWc0CtC2lGhX2mE--6S22q_V8GiIkHlGqw,2295
|
|
207
207
|
strawberry/tools/merge_types.py,sha256=hUMRRNM28FyPp70jRA3d4svv9WoEBjaNpihBt3DaY0I,1023
|
|
208
208
|
strawberry/types/__init__.py,sha256=baWEdDkkmCcITOhkg2hNUOenrNV1OYdxGE5qgvIRwwU,351
|
|
209
|
-
strawberry/types/arguments.py,sha256=
|
|
209
|
+
strawberry/types/arguments.py,sha256=3Rt1WlVDMc0KKYmJOnMUckeTB0egJv96Uw7RMopM4DM,11996
|
|
210
210
|
strawberry/types/auto.py,sha256=4sDflIg-Kz-QpK7Qo7bCSFblw7VE-0752rgayukFznU,2954
|
|
211
211
|
strawberry/types/base.py,sha256=Hubo7u6OsU1v1v-w-vBCwlNVTqHaNn4zPOJuX93WR5U,15699
|
|
212
212
|
strawberry/types/cast.py,sha256=fx86MkLW77GIximBAwUk5vZxSGwDqUA6XicXvz8EXwQ,916
|
|
@@ -218,10 +218,10 @@ strawberry/types/fields/resolver.py,sha256=sWG4nO8XpsvELna0uLU-rwKzUGiMgwHPzg8N7
|
|
|
218
218
|
strawberry/types/graphql.py,sha256=gXKzawwKiow7hvoJhq5ApNJOMUCnKmvTiHaKY5CK1Lw,867
|
|
219
219
|
strawberry/types/info.py,sha256=1MTarr040KSsPPdrVx8sDHtKudEfH0LRgQ4adk_1FKA,4698
|
|
220
220
|
strawberry/types/lazy_type.py,sha256=GYy4PnKtZ48ywW-_A-6Ul8sbHRlB0Tc39ui5DMIja4U,5077
|
|
221
|
-
strawberry/types/maybe.py,sha256=
|
|
221
|
+
strawberry/types/maybe.py,sha256=ZBNHGDMuVcorpErPAMjJku4W3I2ygPf_3ZLw-N2O_UU,1610
|
|
222
222
|
strawberry/types/mutation.py,sha256=vcrKt1VpcS6SLl1WKfcR-NTAqfQ12LpzjwgT5Bx-U3Q,11549
|
|
223
223
|
strawberry/types/nodes.py,sha256=bM88j05rMIQ5OTS4RqKeU3kjo38MM-hA3Hrmh3IreV0,5121
|
|
224
|
-
strawberry/types/object_type.py,sha256=
|
|
224
|
+
strawberry/types/object_type.py,sha256=CTBVBM7wD4y76lC_2mTFnpdTqADEA7nFIRrF93UhvII,15457
|
|
225
225
|
strawberry/types/private.py,sha256=DhJs50XVGtOXlxWZFkRpMxQ5_6oki0-x_WQsV1bGUxk,518
|
|
226
226
|
strawberry/types/scalar.py,sha256=OgWRFV5x-qTM4-FJC-sAKix-DhMtGRrJTxU7ry4VOlA,8651
|
|
227
227
|
strawberry/types/type_resolver.py,sha256=fH2ZOK4dAGgu8AMPi-JAXe_kEAbvvw2MCYXqbpx-kTc,6529
|
|
@@ -238,8 +238,8 @@ strawberry/utils/logging.py,sha256=Dnivjd0ZhK_lAvjvuyCDkEWDhuURBoK9d3Kt_mIqbRg,7
|
|
|
238
238
|
strawberry/utils/operation.py,sha256=Qs3ttbuC415xEVqmJ6YsWQpJNUo8CZJq9AoMB-yV65w,1215
|
|
239
239
|
strawberry/utils/str_converters.py,sha256=-eH1Cl16IO_wrBlsGM-km4IY0IKsjhjnSNGRGOwQjVM,897
|
|
240
240
|
strawberry/utils/typing.py,sha256=eE9NeMfASeXRstbjLnQFfOPymcSX8xwg3FGw_HCp95E,11828
|
|
241
|
-
strawberry_graphql-0.288.
|
|
242
|
-
strawberry_graphql-0.288.
|
|
243
|
-
strawberry_graphql-0.288.
|
|
244
|
-
strawberry_graphql-0.288.
|
|
245
|
-
strawberry_graphql-0.288.
|
|
241
|
+
strawberry_graphql-0.288.3.dist-info/METADATA,sha256=3J3c_1M5jyi-DmVmNV0QVPWpgWG3OueKWrfp37AEhbM,7647
|
|
242
|
+
strawberry_graphql-0.288.3.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
243
|
+
strawberry_graphql-0.288.3.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
|
|
244
|
+
strawberry_graphql-0.288.3.dist-info/licenses/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
|
|
245
|
+
strawberry_graphql-0.288.3.dist-info/RECORD,,
|
|
File without changes
|
{strawberry_graphql-0.288.1.dist-info → strawberry_graphql-0.288.3.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{strawberry_graphql-0.288.1.dist-info → strawberry_graphql-0.288.3.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|