strawberry-graphql 0.235.1.dev1719337273__py3-none-any.whl → 0.236.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/__init__.py +17 -11
- strawberry/aiohttp/handlers/graphql_transport_ws_handler.py +3 -0
- strawberry/aiohttp/handlers/graphql_ws_handler.py +3 -0
- strawberry/aiohttp/test/client.py +3 -0
- strawberry/aiohttp/views.py +3 -0
- strawberry/annotation.py +19 -22
- strawberry/asgi/__init__.py +3 -3
- strawberry/asgi/handlers/graphql_transport_ws_handler.py +3 -0
- strawberry/asgi/handlers/graphql_ws_handler.py +3 -0
- strawberry/asgi/test/client.py +3 -0
- strawberry/chalice/views.py +12 -3
- strawberry/channels/handlers/__init__.py +0 -0
- strawberry/channels/handlers/base.py +5 -5
- strawberry/channels/handlers/graphql_transport_ws_handler.py +3 -0
- strawberry/channels/handlers/graphql_ws_handler.py +3 -0
- strawberry/channels/handlers/http_handler.py +5 -2
- strawberry/channels/handlers/ws_handler.py +4 -1
- strawberry/channels/router.py +9 -5
- strawberry/channels/testing.py +11 -4
- strawberry/cli/commands/upgrade/__init__.py +13 -5
- strawberry/cli/commands/upgrade/_fake_progress.py +2 -1
- strawberry/cli/commands/upgrade/_run_codemod.py +18 -1
- strawberry/codegen/exceptions.py +8 -0
- strawberry/codegen/query_codegen.py +16 -7
- strawberry/codegen/types.py +32 -1
- strawberry/codemods/update_imports.py +136 -0
- strawberry/dataloader.py +13 -0
- strawberry/directive.py +52 -4
- strawberry/django/context.py +4 -1
- strawberry/django/test/client.py +3 -0
- strawberry/django/views.py +3 -0
- strawberry/exceptions/__init__.py +5 -5
- strawberry/exceptions/duplicated_type_name.py +1 -1
- strawberry/exceptions/invalid_argument_type.py +3 -3
- strawberry/exceptions/invalid_union_type.py +5 -6
- strawberry/exceptions/missing_arguments_annotations.py +1 -1
- strawberry/exceptions/missing_dependencies.py +10 -2
- strawberry/exceptions/missing_return_annotation.py +1 -1
- strawberry/exceptions/permission_fail_silently_requires_optional.py +3 -3
- strawberry/exceptions/scalar_already_registered.py +1 -1
- strawberry/exceptions/unresolved_field_type.py +2 -2
- strawberry/exceptions/utils/source_finder.py +5 -2
- strawberry/experimental/pydantic/conversion.py +5 -5
- strawberry/experimental/pydantic/conversion_types.py +4 -2
- strawberry/experimental/pydantic/error_type.py +2 -2
- strawberry/experimental/pydantic/fields.py +2 -2
- strawberry/experimental/pydantic/object_type.py +11 -7
- strawberry/experimental/pydantic/utils.py +4 -5
- strawberry/ext/dataclasses/dataclasses.py +2 -1
- strawberry/ext/mypy_plugin.py +10 -8
- strawberry/extensions/add_validation_rules.py +27 -23
- strawberry/extensions/base_extension.py +6 -4
- strawberry/extensions/directives.py +4 -1
- strawberry/extensions/disable_validation.py +15 -12
- strawberry/extensions/field_extension.py +11 -5
- strawberry/extensions/mask_errors.py +3 -0
- strawberry/extensions/max_aliases.py +21 -19
- strawberry/extensions/max_tokens.py +14 -16
- strawberry/extensions/parser_cache.py +22 -19
- strawberry/extensions/pyinstrument.py +4 -8
- strawberry/extensions/query_depth_limiter.py +22 -23
- strawberry/extensions/runner.py +3 -0
- strawberry/extensions/tracing/apollo.py +3 -0
- strawberry/extensions/tracing/datadog.py +7 -2
- strawberry/extensions/tracing/opentelemetry.py +3 -0
- strawberry/extensions/tracing/sentry.py +3 -0
- strawberry/extensions/tracing/utils.py +3 -0
- strawberry/extensions/utils.py +3 -0
- strawberry/extensions/validation_cache.py +23 -20
- strawberry/fastapi/context.py +3 -0
- strawberry/fastapi/handlers/graphql_transport_ws_handler.py +3 -0
- strawberry/fastapi/handlers/graphql_ws_handler.py +3 -0
- strawberry/fastapi/router.py +3 -0
- strawberry/federation/argument.py +4 -1
- strawberry/federation/enum.py +5 -3
- strawberry/federation/field.py +6 -3
- strawberry/federation/mutation.py +2 -0
- strawberry/federation/object_type.py +7 -4
- strawberry/federation/scalar.py +43 -20
- strawberry/federation/schema.py +12 -9
- strawberry/federation/schema_directive.py +2 -2
- strawberry/federation/schema_directives.py +19 -1
- strawberry/federation/types.py +5 -2
- strawberry/federation/union.py +27 -8
- strawberry/field_extensions/input_mutation.py +5 -2
- strawberry/file_uploads/scalars.py +3 -1
- strawberry/file_uploads/utils.py +3 -0
- strawberry/flask/views.py +8 -2
- strawberry/http/__init__.py +9 -0
- strawberry/http/async_base_view.py +4 -3
- strawberry/http/base.py +5 -7
- strawberry/http/exceptions.py +3 -0
- strawberry/http/ides.py +3 -0
- strawberry/http/sync_base_view.py +4 -3
- strawberry/http/temporal_response.py +3 -0
- strawberry/http/types.py +5 -2
- strawberry/http/typevars.py +3 -0
- strawberry/litestar/controller.py +6 -0
- strawberry/litestar/handlers/__init__.py +0 -0
- strawberry/litestar/handlers/graphql_transport_ws_handler.py +3 -0
- strawberry/litestar/handlers/graphql_ws_handler.py +3 -0
- strawberry/parent.py +27 -21
- strawberry/permission.py +70 -27
- strawberry/printer/ast_from_value.py +4 -1
- strawberry/printer/printer.py +8 -5
- strawberry/quart/views.py +3 -0
- strawberry/relay/exceptions.py +7 -0
- strawberry/relay/fields.py +70 -45
- strawberry/relay/types.py +78 -78
- strawberry/relay/utils.py +10 -1
- strawberry/resolvers.py +3 -0
- strawberry/sanic/context.py +3 -0
- strawberry/sanic/utils.py +10 -8
- strawberry/sanic/views.py +5 -9
- strawberry/scalars.py +6 -2
- strawberry/schema/base.py +7 -4
- strawberry/schema/compat.py +12 -2
- strawberry/schema/config.py +3 -0
- strawberry/schema/exceptions.py +3 -0
- strawberry/schema/execute.py +3 -0
- strawberry/schema/name_converter.py +12 -9
- strawberry/schema/schema.py +46 -9
- strawberry/schema/schema_converter.py +16 -14
- strawberry/schema/types/base_scalars.py +3 -1
- strawberry/schema/types/concrete_type.py +4 -4
- strawberry/schema/types/scalar.py +8 -1
- strawberry/schema/validation_rules/one_of.py +3 -0
- strawberry/schema_codegen/__init__.py +3 -0
- strawberry/schema_directive.py +2 -2
- strawberry/starlite/controller.py +3 -0
- strawberry/starlite/handlers/__init__.py +0 -0
- strawberry/starlite/handlers/graphql_transport_ws_handler.py +3 -0
- strawberry/starlite/handlers/graphql_ws_handler.py +3 -0
- strawberry/subscriptions/__init__.py +6 -0
- strawberry/subscriptions/protocols/graphql_transport_ws/__init__.py +5 -0
- strawberry/subscriptions/protocols/graphql_transport_ws/handlers.py +12 -17
- strawberry/subscriptions/protocols/graphql_transport_ws/types.py +21 -25
- strawberry/subscriptions/protocols/graphql_ws/__init__.py +14 -0
- strawberry/subscriptions/protocols/graphql_ws/handlers.py +8 -5
- strawberry/subscriptions/protocols/graphql_ws/types.py +11 -0
- strawberry/test/client.py +44 -29
- strawberry/tools/create_type.py +27 -8
- strawberry/tools/merge_types.py +5 -3
- strawberry/types/__init__.py +8 -1
- strawberry/{arguments.py → types/arguments.py} +44 -13
- strawberry/{auto.py → types/auto.py} +21 -3
- strawberry/types/{types.py → base.py} +234 -10
- strawberry/{enum.py → types/enum.py} +69 -9
- strawberry/types/execution.py +3 -0
- strawberry/{field.py → types/field.py} +46 -23
- strawberry/types/fields/resolver.py +2 -2
- strawberry/types/graphql.py +3 -0
- strawberry/types/info.py +50 -7
- strawberry/{lazy_type.py → types/lazy_type.py} +50 -0
- strawberry/types/mutation.py +351 -0
- strawberry/types/nodes.py +4 -2
- strawberry/{object_type.py → types/object_type.py} +108 -29
- strawberry/{private.py → types/private.py} +13 -6
- strawberry/{custom_scalar.py → types/scalar.py} +39 -23
- strawberry/types/type_resolver.py +21 -16
- strawberry/{union.py → types/union.py} +24 -9
- strawberry/{unset.py → types/unset.py} +20 -0
- strawberry/utils/aio.py +8 -0
- strawberry/utils/await_maybe.py +3 -0
- strawberry/utils/dataclasses.py +3 -0
- strawberry/utils/debug.py +5 -2
- strawberry/utils/deprecations.py +3 -0
- strawberry/utils/graphql_lexer.py +3 -0
- strawberry/utils/importer.py +3 -0
- strawberry/utils/inspect.py +39 -30
- strawberry/utils/logging.py +3 -0
- strawberry/utils/operation.py +3 -0
- strawberry/utils/str_converters.py +3 -0
- strawberry/utils/typing.py +33 -16
- {strawberry_graphql-0.235.1.dev1719337273.dist-info → strawberry_graphql-0.236.0.dist-info}/METADATA +1 -1
- strawberry_graphql-0.236.0.dist-info/RECORD +255 -0
- strawberry/mutation.py +0 -8
- strawberry/type.py +0 -232
- strawberry_graphql-0.235.1.dev1719337273.dist-info/RECORD +0 -252
- {strawberry_graphql-0.235.1.dev1719337273.dist-info → strawberry_graphql-0.236.0.dist-info}/LICENSE +0 -0
- {strawberry_graphql-0.235.1.dev1719337273.dist-info → strawberry_graphql-0.236.0.dist-info}/WHEEL +0 -0
- {strawberry_graphql-0.235.1.dev1719337273.dist-info → strawberry_graphql-0.236.0.dist-info}/entry_points.txt +0 -0
strawberry/fastapi/router.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
from typing import Iterable, Optional
|
2
2
|
|
3
|
-
from strawberry.arguments import StrawberryArgumentAnnotation
|
3
|
+
from strawberry.types.arguments import StrawberryArgumentAnnotation
|
4
4
|
|
5
5
|
|
6
6
|
def argument(
|
@@ -27,3 +27,6 @@ def argument(
|
|
27
27
|
deprecation_reason=deprecation_reason,
|
28
28
|
directives=directives,
|
29
29
|
)
|
30
|
+
|
31
|
+
|
32
|
+
__all__ = ["argument"]
|
strawberry/federation/enum.py
CHANGED
@@ -11,8 +11,8 @@ from typing import (
|
|
11
11
|
overload,
|
12
12
|
)
|
13
13
|
|
14
|
-
from strawberry.enum import _process_enum
|
15
|
-
from strawberry.enum import enum_value as base_enum_value
|
14
|
+
from strawberry.types.enum import _process_enum
|
15
|
+
from strawberry.types.enum import enum_value as base_enum_value
|
16
16
|
|
17
17
|
if TYPE_CHECKING:
|
18
18
|
from strawberry.enum import EnumType, EnumValueDefinition
|
@@ -85,7 +85,6 @@ def enum(
|
|
85
85
|
If name is passed, the name of the GraphQL type will be
|
86
86
|
the value passed of name instead of the Enum class name.
|
87
87
|
"""
|
88
|
-
|
89
88
|
from strawberry.federation.schema_directives import (
|
90
89
|
Authenticated,
|
91
90
|
Inaccessible,
|
@@ -118,3 +117,6 @@ def enum(
|
|
118
117
|
return wrap
|
119
118
|
|
120
119
|
return wrap(_cls) # pragma: no cover
|
120
|
+
|
121
|
+
|
122
|
+
__all__ = ["enum", "enum_value"]
|
strawberry/federation/field.py
CHANGED
@@ -15,15 +15,15 @@ from typing import (
|
|
15
15
|
overload,
|
16
16
|
)
|
17
17
|
|
18
|
-
from strawberry.field import field as base_field
|
19
|
-
from strawberry.unset import UNSET
|
18
|
+
from strawberry.types.field import field as base_field
|
19
|
+
from strawberry.types.unset import UNSET
|
20
20
|
|
21
21
|
if TYPE_CHECKING:
|
22
22
|
from typing_extensions import Literal
|
23
23
|
|
24
24
|
from strawberry.extensions.field_extension import FieldExtension
|
25
|
-
from strawberry.field import _RESOLVER_TYPE, StrawberryField
|
26
25
|
from strawberry.permission import BasePermission
|
26
|
+
from strawberry.types.field import _RESOLVER_TYPE, StrawberryField
|
27
27
|
|
28
28
|
from .schema_directives import Override
|
29
29
|
|
@@ -203,3 +203,6 @@ def field(
|
|
203
203
|
extensions=extensions,
|
204
204
|
graphql_type=graphql_type,
|
205
205
|
)
|
206
|
+
|
207
|
+
|
208
|
+
__all__ = ["field"]
|
@@ -12,10 +12,10 @@ from typing import (
|
|
12
12
|
)
|
13
13
|
from typing_extensions import dataclass_transform
|
14
14
|
|
15
|
-
from strawberry.field import StrawberryField
|
16
|
-
from strawberry.field import field as base_field
|
17
|
-
from strawberry.object_type import type as base_type
|
18
|
-
from strawberry.unset import UNSET
|
15
|
+
from strawberry.types.field import StrawberryField
|
16
|
+
from strawberry.types.field import field as base_field
|
17
|
+
from strawberry.types.object_type import type as base_type
|
18
|
+
from strawberry.types.unset import UNSET
|
19
19
|
|
20
20
|
from .field import field
|
21
21
|
|
@@ -369,3 +369,6 @@ def interface_object(
|
|
369
369
|
is_interface=False,
|
370
370
|
is_interface_object=True,
|
371
371
|
)
|
372
|
+
|
373
|
+
|
374
|
+
__all__ = ["type", "input", "interface", "interface_object"]
|
strawberry/federation/scalar.py
CHANGED
@@ -11,7 +11,7 @@ from typing import (
|
|
11
11
|
overload,
|
12
12
|
)
|
13
13
|
|
14
|
-
from strawberry.
|
14
|
+
from strawberry.types.scalar import ScalarWrapper, _process_scalar
|
15
15
|
|
16
16
|
# in python 3.10+ NewType is a class
|
17
17
|
if sys.version_info >= (3, 10):
|
@@ -79,28 +79,48 @@ def scalar(
|
|
79
79
|
) -> Any:
|
80
80
|
"""Annotates a class or type as a GraphQL custom scalar.
|
81
81
|
|
82
|
+
Args:
|
83
|
+
cls: The class or type to annotate
|
84
|
+
name: The GraphQL name of the scalar
|
85
|
+
description: The description of the scalar
|
86
|
+
specified_by_url: The URL of the specification
|
87
|
+
serialize: The function to serialize the scalar
|
88
|
+
parse_value: The function to parse the value
|
89
|
+
parse_literal: The function to parse the literal
|
90
|
+
directives: The directives to apply to the scalar
|
91
|
+
authenticated: Whether to add the @authenticated directive
|
92
|
+
inaccessible: Whether to add the @inaccessible directive
|
93
|
+
policy: The list of policy names to add to the @policy directive
|
94
|
+
requires_scopes: The list of scopes to add to the @requires directive
|
95
|
+
tags: The list of tags to add to the @tag directive
|
96
|
+
|
97
|
+
Returns:
|
98
|
+
The decorated class or type
|
99
|
+
|
82
100
|
Example usages:
|
83
101
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
>>> serialize=lambda value: ",".join(value.items),
|
98
|
-
>>> parse_value=lambda value: CustomList(value.split(","))
|
99
|
-
>>> )
|
100
|
-
>>> class CustomList:
|
101
|
-
>>> def __init__(self, items):
|
102
|
-
>>> self.items = items
|
102
|
+
```python
|
103
|
+
strawberry.federation.scalar(
|
104
|
+
datetime.date,
|
105
|
+
serialize=lambda value: value.isoformat(),
|
106
|
+
parse_value=datetime.parse_date,
|
107
|
+
)
|
108
|
+
|
109
|
+
Base64Encoded = strawberry.federation.scalar(
|
110
|
+
NewType("Base64Encoded", bytes),
|
111
|
+
serialize=base64.b64encode,
|
112
|
+
parse_value=base64.b64decode,
|
113
|
+
)
|
114
|
+
|
103
115
|
|
116
|
+
@strawberry.federation.scalar(
|
117
|
+
serialize=lambda value: ",".join(value.items),
|
118
|
+
parse_value=lambda value: CustomList(value.split(",")),
|
119
|
+
)
|
120
|
+
class CustomList:
|
121
|
+
def __init__(self, items):
|
122
|
+
self.items = items
|
123
|
+
```
|
104
124
|
"""
|
105
125
|
from strawberry.federation.schema_directives import (
|
106
126
|
Authenticated,
|
@@ -146,3 +166,6 @@ def scalar(
|
|
146
166
|
return wrap
|
147
167
|
|
148
168
|
return wrap(cls)
|
169
|
+
|
170
|
+
|
171
|
+
__all__ = ["scalar"]
|
strawberry/federation/schema.py
CHANGED
@@ -20,17 +20,17 @@ from typing import (
|
|
20
20
|
from graphql import GraphQLError
|
21
21
|
|
22
22
|
from strawberry.annotation import StrawberryAnnotation
|
23
|
-
from strawberry.custom_scalar import scalar
|
24
23
|
from strawberry.printer import print_schema
|
25
24
|
from strawberry.schema import Schema as BaseSchema
|
26
|
-
from strawberry.
|
25
|
+
from strawberry.types.base import (
|
27
26
|
StrawberryContainer,
|
27
|
+
StrawberryObjectDefinition,
|
28
28
|
WithStrawberryObjectDefinition,
|
29
29
|
get_object_definition,
|
30
30
|
)
|
31
31
|
from strawberry.types.info import Info
|
32
|
-
from strawberry.types.
|
33
|
-
from strawberry.union import StrawberryUnion
|
32
|
+
from strawberry.types.scalar import scalar
|
33
|
+
from strawberry.types.union import StrawberryUnion
|
34
34
|
from strawberry.utils.inspect import get_func_args
|
35
35
|
|
36
36
|
from .schema_directive import StrawberryFederationSchemaDirective
|
@@ -38,12 +38,12 @@ from .schema_directive import StrawberryFederationSchemaDirective
|
|
38
38
|
if TYPE_CHECKING:
|
39
39
|
from graphql import ExecutionContext as GraphQLExecutionContext
|
40
40
|
|
41
|
-
from strawberry.custom_scalar import ScalarDefinition, ScalarWrapper
|
42
|
-
from strawberry.enum import EnumDefinition
|
43
41
|
from strawberry.extensions import SchemaExtension
|
44
42
|
from strawberry.federation.schema_directives import ComposeDirective
|
45
43
|
from strawberry.schema.config import StrawberryConfig
|
46
44
|
from strawberry.schema_directive import StrawberrySchemaDirective
|
45
|
+
from strawberry.types.enum import EnumDefinition
|
46
|
+
from strawberry.types.scalar import ScalarDefinition, ScalarWrapper
|
47
47
|
|
48
48
|
|
49
49
|
FederationAny = scalar(NewType("_Any", object), name="_Any") # type: ignore
|
@@ -112,7 +112,6 @@ class Schema(BaseSchema):
|
|
112
112
|
The _service field is added by default, but the _entities field is only
|
113
113
|
added if the schema contains an entity type.
|
114
114
|
"""
|
115
|
-
|
116
115
|
import strawberry
|
117
116
|
from strawberry.tools.create_type import create_type
|
118
117
|
from strawberry.tools.merge_types import merge_types
|
@@ -181,7 +180,7 @@ class Schema(BaseSchema):
|
|
181
180
|
|
182
181
|
get_result = partial(resolve_reference, **kwargs)
|
183
182
|
else:
|
184
|
-
from strawberry.arguments import convert_argument
|
183
|
+
from strawberry.types.arguments import convert_argument
|
185
184
|
|
186
185
|
config = info.schema.config
|
187
186
|
scalar_registry = info.schema.schema_converter.scalar_registry
|
@@ -209,7 +208,8 @@ class Schema(BaseSchema):
|
|
209
208
|
def _remove_resolvable_field(self) -> None:
|
210
209
|
# this might be removed when we remove support for federation 1
|
211
210
|
# or when we improve how we print the directives
|
212
|
-
from
|
211
|
+
from strawberry.types.unset import UNSET
|
212
|
+
|
213
213
|
from .schema_directives import Key
|
214
214
|
|
215
215
|
for directive in self.schema_directives_in_use:
|
@@ -392,3 +392,6 @@ def _has_federation_keys(
|
|
392
392
|
return any(_is_key(directive) for directive in definition.directives or [])
|
393
393
|
|
394
394
|
return False
|
395
|
+
|
396
|
+
|
397
|
+
__all__ = ["Schema"]
|
@@ -3,9 +3,9 @@ from typing import Callable, List, Optional, Type, TypeVar
|
|
3
3
|
from typing_extensions import dataclass_transform
|
4
4
|
|
5
5
|
from strawberry.directive import directive_field
|
6
|
-
from strawberry.field import StrawberryField, field
|
7
|
-
from strawberry.object_type import _wrap_dataclass
|
8
6
|
from strawberry.schema_directive import Location, StrawberrySchemaDirective
|
7
|
+
from strawberry.types.field import StrawberryField, field
|
8
|
+
from strawberry.types.object_type import _wrap_dataclass
|
9
9
|
from strawberry.types.type_resolver import _get_fields
|
10
10
|
|
11
11
|
|
@@ -3,7 +3,7 @@ from typing import ClassVar, List, Optional
|
|
3
3
|
|
4
4
|
from strawberry import directive_field
|
5
5
|
from strawberry.schema_directive import Location, schema_directive
|
6
|
-
from strawberry.unset import UNSET
|
6
|
+
from strawberry.types.unset import UNSET
|
7
7
|
|
8
8
|
from .types import (
|
9
9
|
FieldSet,
|
@@ -226,3 +226,21 @@ class Policy(FederationDirective):
|
|
226
226
|
imported_from: ClassVar[ImportedFrom] = ImportedFrom(
|
227
227
|
name="policy", url="https://specs.apollo.dev/federation/v2.7"
|
228
228
|
)
|
229
|
+
|
230
|
+
|
231
|
+
__all__ = [
|
232
|
+
"External",
|
233
|
+
"Requires",
|
234
|
+
"Provides",
|
235
|
+
"Key",
|
236
|
+
"Shareable",
|
237
|
+
"Link",
|
238
|
+
"Tag",
|
239
|
+
"Override",
|
240
|
+
"Inaccessible",
|
241
|
+
"ComposeDirective",
|
242
|
+
"InterfaceObject",
|
243
|
+
"Authenticated",
|
244
|
+
"RequiresScopes",
|
245
|
+
"Policy",
|
246
|
+
]
|
strawberry/federation/types.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
from enum import Enum
|
2
2
|
|
3
|
-
from strawberry.
|
4
|
-
from strawberry.
|
3
|
+
from strawberry.types.enum import enum
|
4
|
+
from strawberry.types.scalar import scalar
|
5
5
|
|
6
6
|
FieldSet = scalar(str, name="_FieldSet")
|
7
7
|
|
@@ -12,3 +12,6 @@ LinkImport = scalar(object, name="link__Import")
|
|
12
12
|
class LinkPurpose(Enum):
|
13
13
|
SECURITY = "SECURITY"
|
14
14
|
EXECUTION = "EXECUTION"
|
15
|
+
|
16
|
+
|
17
|
+
__all__ = ["FieldSet", "LinkImport", "LinkPurpose"]
|
strawberry/federation/union.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
from typing import Any, Collection, Iterable, Optional, Type
|
2
2
|
|
3
|
-
from strawberry.union import StrawberryUnion
|
4
|
-
from strawberry.union import union as base_union
|
3
|
+
from strawberry.types.union import StrawberryUnion
|
4
|
+
from strawberry.types.union import union as base_union
|
5
5
|
|
6
6
|
|
7
7
|
def union(
|
@@ -15,15 +15,31 @@ def union(
|
|
15
15
|
) -> StrawberryUnion:
|
16
16
|
"""Creates a new named Union type.
|
17
17
|
|
18
|
+
Args:
|
19
|
+
name: The GraphQL name of the Union type.
|
20
|
+
types: The types that the Union can be.
|
21
|
+
(Deprecated, use `Annotated[U, strawberry.federation.union("Name")]` instead)
|
22
|
+
description: The GraphQL description of the Union type.
|
23
|
+
directives: The directives to attach to the Union type.
|
24
|
+
inaccessible: Whether the Union type is inaccessible.
|
25
|
+
tags: The federation tags to attach to the Union type.
|
26
|
+
|
18
27
|
Example usages:
|
19
28
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
29
|
+
```python
|
30
|
+
import strawberry
|
31
|
+
from typing import Annotated
|
32
|
+
|
33
|
+
@strawberry.federation.type(keys=["id"])
|
34
|
+
class A:
|
35
|
+
id: strawberry.ID
|
36
|
+
|
37
|
+
@strawberry.federation.type(keys=["id"])
|
38
|
+
class B:
|
39
|
+
id: strawberry.ID
|
26
40
|
|
41
|
+
MyUnion = Annotated[A | B, strawberry.federation.union("Name", tags=["tag"])]
|
42
|
+
"""
|
27
43
|
from strawberry.federation.schema_directives import Inaccessible, Tag
|
28
44
|
|
29
45
|
directives = list(directives)
|
@@ -40,3 +56,6 @@ def union(
|
|
40
56
|
description=description,
|
41
57
|
directives=directives,
|
42
58
|
)
|
59
|
+
|
60
|
+
|
61
|
+
__all__ = ["union"]
|
@@ -8,13 +8,13 @@ from typing import (
|
|
8
8
|
|
9
9
|
import strawberry
|
10
10
|
from strawberry.annotation import StrawberryAnnotation
|
11
|
-
from strawberry.arguments import StrawberryArgument
|
12
11
|
from strawberry.extensions.field_extension import (
|
13
12
|
AsyncExtensionResolver,
|
14
13
|
FieldExtension,
|
15
14
|
SyncExtensionResolver,
|
16
15
|
)
|
17
|
-
from strawberry.
|
16
|
+
from strawberry.types.arguments import StrawberryArgument
|
17
|
+
from strawberry.types.field import StrawberryField
|
18
18
|
from strawberry.utils.str_converters import capitalize_first, to_camel_case
|
19
19
|
|
20
20
|
if TYPE_CHECKING:
|
@@ -90,3 +90,6 @@ class InputMutationExtension(FieldExtension):
|
|
90
90
|
**kwargs,
|
91
91
|
**vars(input_args),
|
92
92
|
)
|
93
|
+
|
94
|
+
|
95
|
+
__all__ = ["InputMutationExtension"]
|
strawberry/file_uploads/utils.py
CHANGED
strawberry/flask/views.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
3
|
import warnings
|
4
|
-
from typing import TYPE_CHECKING, Any,
|
4
|
+
from typing import TYPE_CHECKING, Any, Mapping, Optional, Union, cast
|
5
5
|
|
6
6
|
from flask import Request, Response, render_template_string, request
|
7
7
|
from flask.views import View
|
@@ -26,7 +26,7 @@ class FlaskHTTPRequestAdapter(SyncHTTPRequestAdapter):
|
|
26
26
|
self.request = request
|
27
27
|
|
28
28
|
@property
|
29
|
-
def query_params(self) ->
|
29
|
+
def query_params(self) -> QueryParams:
|
30
30
|
return self.request.args.to_dict()
|
31
31
|
|
32
32
|
@property
|
@@ -177,3 +177,9 @@ class AsyncGraphQLView(
|
|
177
177
|
|
178
178
|
async def render_graphql_ide(self, request: Request) -> Response:
|
179
179
|
return render_template_string(self.graphql_ide_html) # type: ignore
|
180
|
+
|
181
|
+
|
182
|
+
__all__ = [
|
183
|
+
"GraphQLView",
|
184
|
+
"AsyncGraphQLView",
|
185
|
+
]
|
strawberry/http/__init__.py
CHANGED
@@ -48,3 +48,12 @@ def parse_request_data(data: Mapping[str, Any]) -> GraphQLRequestData:
|
|
48
48
|
variables=data.get("variables"),
|
49
49
|
operation_name=data.get("operationName"),
|
50
50
|
)
|
51
|
+
|
52
|
+
|
53
|
+
__all__ = [
|
54
|
+
"GraphQLHTTPResponse",
|
55
|
+
"process_result",
|
56
|
+
"GraphQLRequestData",
|
57
|
+
"parse_query_params",
|
58
|
+
"parse_request_data",
|
59
|
+
]
|
@@ -136,9 +136,7 @@ class AsyncBaseHTTPView(
|
|
136
136
|
def _handle_errors(
|
137
137
|
self, errors: List[GraphQLError], response_data: GraphQLHTTPResponse
|
138
138
|
) -> None:
|
139
|
-
"""
|
140
|
-
Hook to allow custom handling of errors, used by the Sentry Integration
|
141
|
-
"""
|
139
|
+
"""Hook to allow custom handling of errors, used by the Sentry Integration."""
|
142
140
|
|
143
141
|
async def run(
|
144
142
|
self,
|
@@ -213,3 +211,6 @@ class AsyncBaseHTTPView(
|
|
213
211
|
self, request: Request, result: ExecutionResult
|
214
212
|
) -> GraphQLHTTPResponse:
|
215
213
|
return process_result(result)
|
214
|
+
|
215
|
+
|
216
|
+
__all__ = ["AsyncBaseHTTPView"]
|
strawberry/http/base.py
CHANGED
@@ -4,7 +4,7 @@ from typing_extensions import Protocol
|
|
4
4
|
|
5
5
|
from strawberry.http import GraphQLHTTPResponse
|
6
6
|
from strawberry.http.ides import GraphQL_IDE, get_graphql_ide_html
|
7
|
-
from strawberry.http.types import HTTPMethod
|
7
|
+
from strawberry.http.types import HTTPMethod, QueryParams
|
8
8
|
|
9
9
|
from .exceptions import HTTPException
|
10
10
|
from .typevars import Request
|
@@ -50,17 +50,12 @@ class BaseView(Generic[Request]):
|
|
50
50
|
def encode_json(self, response_data: GraphQLHTTPResponse) -> str:
|
51
51
|
return json.dumps(response_data)
|
52
52
|
|
53
|
-
def parse_query_params(
|
54
|
-
self, params: Mapping[str, Optional[Union[str, List[str]]]]
|
55
|
-
) -> Dict[str, Any]:
|
53
|
+
def parse_query_params(self, params: QueryParams) -> Dict[str, Any]:
|
56
54
|
params = dict(params)
|
57
55
|
|
58
56
|
if "variables" in params:
|
59
57
|
variables = params["variables"]
|
60
58
|
|
61
|
-
if isinstance(variables, list):
|
62
|
-
variables = variables[0]
|
63
|
-
|
64
59
|
if variables:
|
65
60
|
params["variables"] = self.parse_json(variables)
|
66
61
|
|
@@ -73,3 +68,6 @@ class BaseView(Generic[Request]):
|
|
73
68
|
replace_variables=self._ide_replace_variables,
|
74
69
|
graphql_ide=self.graphql_ide,
|
75
70
|
)
|
71
|
+
|
72
|
+
|
73
|
+
__all__ = ["BaseView"]
|
strawberry/http/exceptions.py
CHANGED
strawberry/http/ides.py
CHANGED
@@ -151,9 +151,7 @@ class SyncBaseHTTPView(
|
|
151
151
|
def _handle_errors(
|
152
152
|
self, errors: List[GraphQLError], response_data: GraphQLHTTPResponse
|
153
153
|
) -> None:
|
154
|
-
"""
|
155
|
-
Hook to allow custom handling of errors, used by the Sentry Integration
|
156
|
-
"""
|
154
|
+
"""Hook to allow custom handling of errors, used by the Sentry Integration."""
|
157
155
|
|
158
156
|
def run(
|
159
157
|
self,
|
@@ -208,3 +206,6 @@ class SyncBaseHTTPView(
|
|
208
206
|
self, request: Request, result: ExecutionResult
|
209
207
|
) -> GraphQLHTTPResponse:
|
210
208
|
return process_result(result)
|
209
|
+
|
210
|
+
|
211
|
+
__all__ = ["SyncBaseHTTPView"]
|
strawberry/http/types.py
CHANGED
@@ -1,13 +1,16 @@
|
|
1
|
-
from typing import Any,
|
1
|
+
from typing import Any, Mapping, Optional
|
2
2
|
from typing_extensions import Literal, TypedDict
|
3
3
|
|
4
4
|
HTTPMethod = Literal[
|
5
5
|
"GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS", "TRACE"
|
6
6
|
]
|
7
7
|
|
8
|
-
QueryParams = Mapping[str, Optional[
|
8
|
+
QueryParams = Mapping[str, Optional[str]]
|
9
9
|
|
10
10
|
|
11
11
|
class FormData(TypedDict):
|
12
12
|
files: Mapping[str, Any]
|
13
13
|
form: Mapping[str, Any]
|
14
|
+
|
15
|
+
|
16
|
+
__all__ = ["HTTPMethod", "QueryParams", "FormData"]
|
strawberry/http/typevars.py
CHANGED
File without changes
|