strawberry-graphql 0.267.0__py3-none-any.whl → 0.268.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/scalars.py +3 -1
- strawberry/schema/compat.py +2 -1
- strawberry/schema/config.py +1 -0
- strawberry/schema/schema.py +6 -13
- strawberry/schema/schema_converter.py +49 -7
- strawberry/schema/types/scalar.py +2 -16
- strawberry/types/arguments.py +2 -2
- {strawberry_graphql-0.267.0.dist-info → strawberry_graphql-0.268.0.dist-info}/METADATA +1 -1
- {strawberry_graphql-0.267.0.dist-info → strawberry_graphql-0.268.0.dist-info}/RECORD +12 -12
- {strawberry_graphql-0.267.0.dist-info → strawberry_graphql-0.268.0.dist-info}/LICENSE +0 -0
- {strawberry_graphql-0.267.0.dist-info → strawberry_graphql-0.268.0.dist-info}/WHEEL +0 -0
- {strawberry_graphql-0.267.0.dist-info → strawberry_graphql-0.268.0.dist-info}/entry_points.txt +0 -0
strawberry/scalars.py
CHANGED
@@ -6,6 +6,8 @@ from typing import TYPE_CHECKING, Any, NewType, Union
|
|
6
6
|
from strawberry.types.scalar import scalar
|
7
7
|
|
8
8
|
if TYPE_CHECKING:
|
9
|
+
from collections.abc import Mapping
|
10
|
+
|
9
11
|
from strawberry.types.scalar import ScalarDefinition, ScalarWrapper
|
10
12
|
|
11
13
|
|
@@ -57,7 +59,7 @@ Base64 = scalar(
|
|
57
59
|
|
58
60
|
def is_scalar(
|
59
61
|
annotation: Any,
|
60
|
-
scalar_registry:
|
62
|
+
scalar_registry: Mapping[object, Union[ScalarWrapper, ScalarDefinition]],
|
61
63
|
) -> bool:
|
62
64
|
if annotation in scalar_registry:
|
63
65
|
return True
|
strawberry/schema/compat.py
CHANGED
@@ -10,6 +10,7 @@ from strawberry.types.base import StrawberryType, has_object_definition
|
|
10
10
|
# TYPE_CHECKING is enabled.
|
11
11
|
|
12
12
|
if TYPE_CHECKING:
|
13
|
+
from collections.abc import Mapping
|
13
14
|
from typing_extensions import TypeGuard
|
14
15
|
|
15
16
|
from strawberry.types.scalar import ScalarDefinition, ScalarWrapper
|
@@ -29,7 +30,7 @@ def is_interface_type(type_: Union[StrawberryType, type]) -> TypeGuard[type]:
|
|
29
30
|
|
30
31
|
def is_scalar(
|
31
32
|
type_: Union[StrawberryType, type],
|
32
|
-
scalar_registry:
|
33
|
+
scalar_registry: Mapping[object, Union[ScalarWrapper, ScalarDefinition]],
|
33
34
|
) -> TypeGuard[type]:
|
34
35
|
return is_strawberry_scalar(type_, scalar_registry)
|
35
36
|
|
strawberry/schema/config.py
CHANGED
@@ -14,6 +14,7 @@ class StrawberryConfig:
|
|
14
14
|
name_converter: NameConverter = field(default_factory=NameConverter)
|
15
15
|
default_resolver: Callable[[Any, str], object] = getattr
|
16
16
|
relay_max_results: int = 100
|
17
|
+
relay_use_legacy_global_id: bool = False
|
17
18
|
disable_field_suggestions: bool = False
|
18
19
|
info_class: type[Info] = Info
|
19
20
|
|
strawberry/schema/schema.py
CHANGED
@@ -46,7 +46,6 @@ from strawberry.extensions.directives import (
|
|
46
46
|
from strawberry.extensions.runner import SchemaExtensionsRunner
|
47
47
|
from strawberry.printer import print_schema
|
48
48
|
from strawberry.schema.schema_converter import GraphQLCoreConverter
|
49
|
-
from strawberry.schema.types.scalar import DEFAULT_SCALAR_REGISTRY
|
50
49
|
from strawberry.schema.validation_rules.one_of import OneOfInputValidationRule
|
51
50
|
from strawberry.types.base import (
|
52
51
|
StrawberryObjectDefinition,
|
@@ -69,7 +68,7 @@ from .config import StrawberryConfig
|
|
69
68
|
from .exceptions import InvalidOperationTypeError
|
70
69
|
|
71
70
|
if TYPE_CHECKING:
|
72
|
-
from collections.abc import Iterable
|
71
|
+
from collections.abc import Iterable, Mapping
|
73
72
|
from typing_extensions import TypeAlias
|
74
73
|
|
75
74
|
from graphql import ExecutionContext as GraphQLExecutionContext
|
@@ -151,7 +150,7 @@ class Schema(BaseSchema):
|
|
151
150
|
execution_context_class: Optional[type[GraphQLExecutionContext]] = None,
|
152
151
|
config: Optional[StrawberryConfig] = None,
|
153
152
|
scalar_overrides: Optional[
|
154
|
-
|
153
|
+
Mapping[object, Union[type, ScalarWrapper, ScalarDefinition]],
|
155
154
|
] = None,
|
156
155
|
schema_directives: Iterable[object] = (),
|
157
156
|
) -> None:
|
@@ -199,18 +198,12 @@ class Schema(BaseSchema):
|
|
199
198
|
self.execution_context_class = execution_context_class
|
200
199
|
self.config = config or StrawberryConfig()
|
201
200
|
|
202
|
-
SCALAR_OVERRIDES_DICT_TYPE = dict[
|
203
|
-
object, Union["ScalarWrapper", "ScalarDefinition"]
|
204
|
-
]
|
205
|
-
|
206
|
-
scalar_registry: SCALAR_OVERRIDES_DICT_TYPE = {**DEFAULT_SCALAR_REGISTRY}
|
207
|
-
if scalar_overrides:
|
208
|
-
# TODO: check that the overrides are valid
|
209
|
-
scalar_registry.update(cast("SCALAR_OVERRIDES_DICT_TYPE", scalar_overrides))
|
210
|
-
|
211
201
|
self.schema_converter = GraphQLCoreConverter(
|
212
|
-
self.config,
|
202
|
+
self.config,
|
203
|
+
scalar_overrides=scalar_overrides or {}, # type: ignore
|
204
|
+
get_fields=self.get_fields,
|
213
205
|
)
|
206
|
+
|
214
207
|
self.directives = directives
|
215
208
|
self.schema_directives = list(schema_directives)
|
216
209
|
|
@@ -23,6 +23,7 @@ from graphql import (
|
|
23
23
|
GraphQLEnumValue,
|
24
24
|
GraphQLError,
|
25
25
|
GraphQLField,
|
26
|
+
GraphQLID,
|
26
27
|
GraphQLInputField,
|
27
28
|
GraphQLInputObjectType,
|
28
29
|
GraphQLInterfaceType,
|
@@ -30,6 +31,7 @@ from graphql import (
|
|
30
31
|
GraphQLNamedType,
|
31
32
|
GraphQLNonNull,
|
32
33
|
GraphQLObjectType,
|
34
|
+
GraphQLScalarType,
|
33
35
|
GraphQLType,
|
34
36
|
GraphQLUnionType,
|
35
37
|
Undefined,
|
@@ -48,7 +50,12 @@ from strawberry.exceptions import (
|
|
48
50
|
UnresolvedFieldTypeError,
|
49
51
|
)
|
50
52
|
from strawberry.extensions.field_extension import build_field_extension_resolvers
|
51
|
-
from strawberry.
|
53
|
+
from strawberry.relay.types import GlobalID
|
54
|
+
from strawberry.schema.types.scalar import (
|
55
|
+
DEFAULT_SCALAR_REGISTRY,
|
56
|
+
_get_scalar_definition,
|
57
|
+
_make_scalar_type,
|
58
|
+
)
|
52
59
|
from strawberry.types.arguments import StrawberryArgument, convert_arguments
|
53
60
|
from strawberry.types.base import (
|
54
61
|
StrawberryList,
|
@@ -64,7 +71,7 @@ from strawberry.types.enum import EnumDefinition
|
|
64
71
|
from strawberry.types.field import UNRESOLVED
|
65
72
|
from strawberry.types.lazy_type import LazyType
|
66
73
|
from strawberry.types.private import is_private
|
67
|
-
from strawberry.types.scalar import ScalarWrapper
|
74
|
+
from strawberry.types.scalar import ScalarWrapper, scalar
|
68
75
|
from strawberry.types.union import StrawberryUnion
|
69
76
|
from strawberry.types.unset import UNSET
|
70
77
|
from strawberry.utils.await_maybe import await_maybe
|
@@ -73,14 +80,13 @@ from . import compat
|
|
73
80
|
from .types.concrete_type import ConcreteType
|
74
81
|
|
75
82
|
if TYPE_CHECKING:
|
76
|
-
from collections.abc import Awaitable
|
83
|
+
from collections.abc import Awaitable, Mapping
|
77
84
|
|
78
85
|
from graphql import (
|
79
86
|
GraphQLInputType,
|
80
87
|
GraphQLNullableType,
|
81
88
|
GraphQLOutputType,
|
82
89
|
GraphQLResolveInfo,
|
83
|
-
GraphQLScalarType,
|
84
90
|
)
|
85
91
|
|
86
92
|
from strawberry.directive import StrawberryDirective
|
@@ -186,7 +192,7 @@ def get_arguments(
|
|
186
192
|
info: Info,
|
187
193
|
kwargs: Any,
|
188
194
|
config: StrawberryConfig,
|
189
|
-
scalar_registry:
|
195
|
+
scalar_registry: Mapping[object, Union[ScalarWrapper, ScalarDefinition]],
|
190
196
|
) -> tuple[list[Any], dict[str, Any]]:
|
191
197
|
# TODO: An extension might have changed the resolver arguments,
|
192
198
|
# but we need them here since we are calling it.
|
@@ -243,14 +249,42 @@ class GraphQLCoreConverter:
|
|
243
249
|
def __init__(
|
244
250
|
self,
|
245
251
|
config: StrawberryConfig,
|
246
|
-
|
252
|
+
scalar_overrides: Mapping[object, Union[ScalarWrapper, ScalarDefinition]],
|
247
253
|
get_fields: Callable[[StrawberryObjectDefinition], list[StrawberryField]],
|
248
254
|
) -> None:
|
249
255
|
self.type_map: dict[str, ConcreteType] = {}
|
250
256
|
self.config = config
|
251
|
-
self.scalar_registry =
|
257
|
+
self.scalar_registry = self._get_scalar_registry(scalar_overrides)
|
252
258
|
self.get_fields = get_fields
|
253
259
|
|
260
|
+
def _get_scalar_registry(
|
261
|
+
self,
|
262
|
+
scalar_overrides: Mapping[object, Union[ScalarWrapper, ScalarDefinition]],
|
263
|
+
) -> Mapping[object, Union[ScalarWrapper, ScalarDefinition]]:
|
264
|
+
scalar_registry = {**DEFAULT_SCALAR_REGISTRY}
|
265
|
+
|
266
|
+
global_id_name = "GlobalID" if self.config.relay_use_legacy_global_id else "ID"
|
267
|
+
|
268
|
+
scalar_registry[GlobalID] = _get_scalar_definition(
|
269
|
+
scalar(
|
270
|
+
GlobalID,
|
271
|
+
name=global_id_name,
|
272
|
+
description=GraphQLID.description,
|
273
|
+
parse_literal=lambda v, vars=None: GlobalID.from_id( # noqa: A006
|
274
|
+
GraphQLID.parse_literal(v, vars)
|
275
|
+
),
|
276
|
+
parse_value=GlobalID.from_id,
|
277
|
+
serialize=str,
|
278
|
+
specified_by_url=("https://relay.dev/graphql/objectidentification.htm"),
|
279
|
+
)
|
280
|
+
)
|
281
|
+
|
282
|
+
if scalar_overrides:
|
283
|
+
# TODO: check that the overrides are valid
|
284
|
+
scalar_registry.update(scalar_overrides) # type: ignore
|
285
|
+
|
286
|
+
return scalar_registry
|
287
|
+
|
254
288
|
def from_argument(self, argument: StrawberryArgument) -> GraphQLArgument:
|
255
289
|
argument_type = cast(
|
256
290
|
"GraphQLInputType", self.from_maybe_optional(argument.type)
|
@@ -784,12 +818,20 @@ class GraphQLCoreConverter:
|
|
784
818
|
scalar_name = self.config.name_converter.from_type(scalar_definition)
|
785
819
|
|
786
820
|
if scalar_name not in self.type_map:
|
821
|
+
from strawberry.relay import GlobalID
|
822
|
+
|
823
|
+
if scalar is GlobalID and hasattr(GraphQLNamedType, "reserved_types"):
|
824
|
+
GraphQLNamedType.reserved_types.pop("ID")
|
825
|
+
|
787
826
|
implementation = (
|
788
827
|
scalar_definition.implementation
|
789
828
|
if scalar_definition.implementation is not None
|
790
829
|
else _make_scalar_type(scalar_definition)
|
791
830
|
)
|
792
831
|
|
832
|
+
if scalar is GlobalID and hasattr(GraphQLNamedType, "reserved_types"):
|
833
|
+
GraphQLNamedType.reserved_types["ID"] = implementation
|
834
|
+
|
793
835
|
self.type_map[scalar_name] = ConcreteType(
|
794
836
|
definition=scalar_definition, implementation=implementation
|
795
837
|
)
|
@@ -12,10 +12,9 @@ from graphql import (
|
|
12
12
|
)
|
13
13
|
|
14
14
|
from strawberry.file_uploads.scalars import Upload
|
15
|
-
from strawberry.relay.types import GlobalID
|
16
15
|
from strawberry.scalars import ID
|
17
16
|
from strawberry.schema.types import base_scalars
|
18
|
-
from strawberry.types.scalar import ScalarDefinition
|
17
|
+
from strawberry.types.scalar import ScalarDefinition
|
19
18
|
|
20
19
|
|
21
20
|
def _make_scalar_type(definition: ScalarDefinition) -> GraphQLScalarType:
|
@@ -62,22 +61,9 @@ DEFAULT_SCALAR_REGISTRY: dict[object, ScalarDefinition] = {
|
|
62
61
|
datetime.datetime: _get_scalar_definition(base_scalars.DateTime),
|
63
62
|
datetime.time: _get_scalar_definition(base_scalars.Time),
|
64
63
|
decimal.Decimal: _get_scalar_definition(base_scalars.Decimal),
|
65
|
-
# We can't wrap GlobalID with @scalar because it has custom attributes/methods
|
66
|
-
GlobalID: _get_scalar_definition(
|
67
|
-
scalar(
|
68
|
-
GlobalID,
|
69
|
-
name="GlobalID",
|
70
|
-
description=GraphQLID.description,
|
71
|
-
parse_literal=lambda v, vars=None: GlobalID.from_id( # noqa: A006
|
72
|
-
GraphQLID.parse_literal(v, vars)
|
73
|
-
),
|
74
|
-
parse_value=GlobalID.from_id,
|
75
|
-
serialize=str,
|
76
|
-
specified_by_url=("https://relay.dev/graphql/objectidentification.htm"),
|
77
|
-
)
|
78
|
-
),
|
79
64
|
}
|
80
65
|
|
66
|
+
|
81
67
|
__all__ = [
|
82
68
|
"DEFAULT_SCALAR_REGISTRY",
|
83
69
|
"_get_scalar_definition",
|
strawberry/types/arguments.py
CHANGED
@@ -147,7 +147,7 @@ class StrawberryArgument:
|
|
147
147
|
def convert_argument(
|
148
148
|
value: object,
|
149
149
|
type_: Union[StrawberryType, type],
|
150
|
-
scalar_registry:
|
150
|
+
scalar_registry: Mapping[object, Union[ScalarWrapper, ScalarDefinition]],
|
151
151
|
config: StrawberryConfig,
|
152
152
|
) -> object:
|
153
153
|
# TODO: move this somewhere else and make it first class
|
@@ -207,7 +207,7 @@ def convert_argument(
|
|
207
207
|
def convert_arguments(
|
208
208
|
value: dict[str, Any],
|
209
209
|
arguments: list[StrawberryArgument],
|
210
|
-
scalar_registry:
|
210
|
+
scalar_registry: Mapping[object, Union[ScalarWrapper, ScalarDefinition]],
|
211
211
|
config: StrawberryConfig,
|
212
212
|
) -> dict[str, Any]:
|
213
213
|
"""Converts a nested dictionary to a dictionary of actual types.
|
@@ -160,19 +160,19 @@ strawberry/sanic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,
|
|
160
160
|
strawberry/sanic/context.py,sha256=qN7I9K_qIqgdbG_FbDl8XMb9aM1PyjIxSo8IAg2Uq8o,844
|
161
161
|
strawberry/sanic/utils.py,sha256=XjUVBFuBWfECBCZbx_YtrjQnFTUyIGTo7aISIeB22Gc,1007
|
162
162
|
strawberry/sanic/views.py,sha256=F5ZrKt-R3135evKLfhQuPd1isOexI0Lrzevm_6Te4Eg,7069
|
163
|
-
strawberry/scalars.py,sha256=
|
163
|
+
strawberry/scalars.py,sha256=CGkG8CIfurXiYhidmW3qwy6M5BF_Mhih3wAEcWx_iBU,2278
|
164
164
|
strawberry/schema/__init__.py,sha256=u1QCyDVQExUVDA20kyosKPz3TS5HMCN2NrXclhiFAL4,92
|
165
165
|
strawberry/schema/base.py,sha256=q5UAw6do4Ele5Cf8dNAouiPjNmZoCBNFqh5Vl05caCI,3864
|
166
|
-
strawberry/schema/compat.py,sha256=
|
167
|
-
strawberry/schema/config.py,sha256=
|
166
|
+
strawberry/schema/compat.py,sha256=xNpOEDfi-MODpplMGaKuKeQIVcr-tcAaKaU3TlBc1Zs,1873
|
167
|
+
strawberry/schema/config.py,sha256=KeZ1Pc1gvYK0fOx9Aghx7m0Av8sWexycl3HJGFgHPvg,969
|
168
168
|
strawberry/schema/exceptions.py,sha256=rqVNb_oYrKM0dHPgvAemqCG6Um282LPPu4zwQ5cZqs4,584
|
169
169
|
strawberry/schema/name_converter.py,sha256=xFOXEgqldFkxXRkIQvsJN1dPkWbEUaIrTYNOMYSEVwQ,6945
|
170
|
-
strawberry/schema/schema.py,sha256=
|
171
|
-
strawberry/schema/schema_converter.py,sha256=
|
170
|
+
strawberry/schema/schema.py,sha256=rDfNclXSRHqn3NNGzPAovZoVeMh0VC5wVCCUprwZJV8,34215
|
171
|
+
strawberry/schema/schema_converter.py,sha256=yuYafNwa9zs6l-GmuGtxdjYwawxjiU6zmwIgJ-aLhV4,39308
|
172
172
|
strawberry/schema/types/__init__.py,sha256=oHO3COWhL3L1KLYCJNY1XFf5xt2GGtHiMC-UaYbFfnA,68
|
173
173
|
strawberry/schema/types/base_scalars.py,sha256=JRUq0WjEkR9dFewstZnqnZKp0uOEipo4UXNF5dzRf4M,1971
|
174
174
|
strawberry/schema/types/concrete_type.py,sha256=axIyFZgdwNv-XYkiqX67464wuFX6Vp0jYATwnBZSUvM,750
|
175
|
-
strawberry/schema/types/scalar.py,sha256=
|
175
|
+
strawberry/schema/types/scalar.py,sha256=X_9R7tLDINcs9UeExUUqq3_U2JkhCVJBeEhDFDUt3Tc,2347
|
176
176
|
strawberry/schema/validation_rules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
177
177
|
strawberry/schema/validation_rules/one_of.py,sha256=fPuYzCyLT7p9y7dHF_sWTImArTQaEhyF664lZijB1Gw,2629
|
178
178
|
strawberry/schema_codegen/__init__.py,sha256=mN4Qmu5Iakht6nHpRpt9hCs8e--oTPlVtDJZJpzgHR4,24364
|
@@ -195,7 +195,7 @@ strawberry/tools/__init__.py,sha256=pdGpZx8wpq03VfUZJyF9JtYxZhGqzzxCiipsalWxJX4,
|
|
195
195
|
strawberry/tools/create_type.py,sha256=--DgfZOmXJBKGcVxehNISyvpw1HzwFvRtUUPc0634MA,2056
|
196
196
|
strawberry/tools/merge_types.py,sha256=hUMRRNM28FyPp70jRA3d4svv9WoEBjaNpihBt3DaY0I,1023
|
197
197
|
strawberry/types/__init__.py,sha256=baWEdDkkmCcITOhkg2hNUOenrNV1OYdxGE5qgvIRwwU,351
|
198
|
-
strawberry/types/arguments.py,sha256=
|
198
|
+
strawberry/types/arguments.py,sha256=Ut4H60a7SRuPtCUAa6gS6gJigaNqhCSesCPoeb0xDYE,9706
|
199
199
|
strawberry/types/auto.py,sha256=WZ2cQAI8nREUigBzpzFqIKGjJ_C2VqpAPNe8vPjTciM,3007
|
200
200
|
strawberry/types/base.py,sha256=tZSqxtrxXa1Y964HS2uakCbCgLyGO9A4WpODiegWzF8,15122
|
201
201
|
strawberry/types/cast.py,sha256=fx86MkLW77GIximBAwUk5vZxSGwDqUA6XicXvz8EXwQ,916
|
@@ -229,8 +229,8 @@ strawberry/utils/logging.py,sha256=U1cseHGquN09YFhFmRkiphfASKCyK0HUZREImPgVb0c,7
|
|
229
229
|
strawberry/utils/operation.py,sha256=s7ajvLg_q6v2mg47kEMQPjO_J-XluMKTCwo4d47mGvE,1195
|
230
230
|
strawberry/utils/str_converters.py,sha256=-eH1Cl16IO_wrBlsGM-km4IY0IKsjhjnSNGRGOwQjVM,897
|
231
231
|
strawberry/utils/typing.py,sha256=SDvX-Du-9HAV3-XXjqi7Q5f5qPDDFd_gASIITiwBQT4,14073
|
232
|
-
strawberry_graphql-0.
|
233
|
-
strawberry_graphql-0.
|
234
|
-
strawberry_graphql-0.
|
235
|
-
strawberry_graphql-0.
|
236
|
-
strawberry_graphql-0.
|
232
|
+
strawberry_graphql-0.268.0.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
|
233
|
+
strawberry_graphql-0.268.0.dist-info/METADATA,sha256=fJm7Ywqawb8NQPG8GK7RUdtiqbrlOIIHJ8Q2sSaQlPw,7679
|
234
|
+
strawberry_graphql-0.268.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
235
|
+
strawberry_graphql-0.268.0.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
|
236
|
+
strawberry_graphql-0.268.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
{strawberry_graphql-0.267.0.dist-info → strawberry_graphql-0.268.0.dist-info}/entry_points.txt
RENAMED
File without changes
|