strawberry-graphql 0.275.7__py3-none-any.whl → 0.284.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.
Potentially problematic release.
This version of strawberry-graphql might be problematic. Click here for more details.
- strawberry/__init__.py +2 -0
- strawberry/aiohttp/test/client.py +8 -15
- strawberry/aiohttp/views.py +15 -64
- strawberry/annotation.py +70 -25
- strawberry/asgi/__init__.py +22 -56
- strawberry/asgi/test/client.py +6 -6
- strawberry/chalice/views.py +13 -79
- strawberry/channels/handlers/base.py +7 -8
- strawberry/channels/handlers/http_handler.py +50 -32
- strawberry/channels/handlers/ws_handler.py +12 -14
- strawberry/channels/router.py +3 -4
- strawberry/channels/testing.py +7 -9
- strawberry/cli/__init__.py +7 -6
- strawberry/cli/commands/codegen.py +7 -7
- strawberry/cli/commands/dev.py +72 -0
- strawberry/cli/commands/schema_codegen.py +1 -2
- strawberry/cli/commands/server.py +3 -44
- strawberry/cli/commands/upgrade/__init__.py +3 -3
- strawberry/cli/commands/upgrade/_run_codemod.py +2 -2
- strawberry/cli/constants.py +1 -2
- strawberry/cli/{debug_server.py → dev_server.py} +3 -7
- strawberry/codegen/plugins/print_operation.py +2 -2
- strawberry/codegen/plugins/python.py +2 -2
- strawberry/codegen/query_codegen.py +20 -30
- strawberry/codegen/types.py +32 -32
- strawberry/codemods/__init__.py +9 -0
- strawberry/codemods/annotated_unions.py +2 -2
- strawberry/codemods/maybe_optional.py +118 -0
- strawberry/dataloader.py +28 -24
- strawberry/directive.py +6 -7
- strawberry/django/test/client.py +3 -3
- strawberry/django/views.py +21 -91
- strawberry/exceptions/__init__.py +4 -4
- strawberry/exceptions/conflicting_arguments.py +2 -2
- strawberry/exceptions/duplicated_type_name.py +4 -4
- strawberry/exceptions/exception.py +3 -3
- strawberry/exceptions/handler.py +8 -7
- strawberry/exceptions/invalid_argument_type.py +2 -2
- strawberry/exceptions/invalid_superclass_interface.py +2 -2
- strawberry/exceptions/invalid_union_type.py +4 -4
- strawberry/exceptions/missing_arguments_annotations.py +2 -2
- strawberry/exceptions/missing_dependencies.py +2 -4
- strawberry/exceptions/missing_field_annotation.py +2 -2
- strawberry/exceptions/missing_return_annotation.py +2 -2
- strawberry/exceptions/object_is_not_a_class.py +2 -2
- strawberry/exceptions/object_is_not_an_enum.py +2 -2
- strawberry/exceptions/permission_fail_silently_requires_optional.py +2 -2
- strawberry/exceptions/private_strawberry_field.py +2 -2
- strawberry/exceptions/scalar_already_registered.py +2 -2
- strawberry/exceptions/syntax.py +3 -3
- strawberry/exceptions/unresolved_field_type.py +2 -2
- strawberry/exceptions/utils/source_finder.py +25 -25
- strawberry/experimental/pydantic/_compat.py +8 -7
- strawberry/experimental/pydantic/conversion.py +2 -2
- strawberry/experimental/pydantic/conversion_types.py +2 -2
- strawberry/experimental/pydantic/error_type.py +10 -12
- strawberry/experimental/pydantic/fields.py +9 -15
- strawberry/experimental/pydantic/object_type.py +17 -25
- strawberry/experimental/pydantic/utils.py +1 -2
- strawberry/ext/mypy_plugin.py +12 -14
- strawberry/extensions/base_extension.py +2 -1
- strawberry/extensions/context.py +13 -18
- strawberry/extensions/directives.py +9 -3
- strawberry/extensions/field_extension.py +4 -4
- strawberry/extensions/mask_errors.py +24 -13
- strawberry/extensions/max_aliases.py +1 -3
- strawberry/extensions/parser_cache.py +1 -2
- strawberry/extensions/query_depth_limiter.py +18 -14
- strawberry/extensions/runner.py +2 -2
- strawberry/extensions/tracing/apollo.py +3 -3
- strawberry/extensions/tracing/datadog.py +3 -3
- strawberry/extensions/tracing/opentelemetry.py +6 -8
- strawberry/extensions/tracing/utils.py +3 -1
- strawberry/extensions/utils.py +2 -2
- strawberry/extensions/validation_cache.py +2 -3
- strawberry/fastapi/context.py +6 -6
- strawberry/fastapi/router.py +43 -42
- strawberry/federation/argument.py +4 -5
- strawberry/federation/enum.py +18 -21
- strawberry/federation/field.py +94 -97
- strawberry/federation/object_type.py +56 -58
- strawberry/federation/scalar.py +27 -35
- strawberry/federation/schema.py +15 -16
- strawberry/federation/schema_directive.py +7 -6
- strawberry/federation/schema_directives.py +11 -11
- strawberry/federation/union.py +4 -4
- strawberry/flask/views.py +16 -85
- strawberry/http/__init__.py +30 -20
- strawberry/http/async_base_view.py +208 -89
- strawberry/http/base.py +28 -11
- strawberry/http/exceptions.py +5 -7
- strawberry/http/ides.py +2 -3
- strawberry/http/sync_base_view.py +115 -69
- strawberry/http/types.py +3 -3
- strawberry/litestar/controller.py +43 -77
- strawberry/permission.py +4 -6
- strawberry/printer/ast_from_value.py +3 -5
- strawberry/printer/printer.py +18 -15
- strawberry/quart/views.py +16 -48
- strawberry/relay/exceptions.py +4 -4
- strawberry/relay/fields.py +33 -32
- strawberry/relay/types.py +32 -35
- strawberry/relay/utils.py +11 -23
- strawberry/resolvers.py +2 -1
- strawberry/sanic/context.py +1 -0
- strawberry/sanic/utils.py +3 -3
- strawberry/sanic/views.py +15 -54
- strawberry/scalars.py +2 -2
- strawberry/schema/_graphql_core.py +55 -0
- strawberry/schema/base.py +32 -33
- strawberry/schema/compat.py +9 -9
- strawberry/schema/config.py +10 -1
- strawberry/schema/exceptions.py +1 -3
- strawberry/schema/name_converter.py +9 -8
- strawberry/schema/schema.py +133 -100
- strawberry/schema/schema_converter.py +96 -58
- strawberry/schema/types/base_scalars.py +1 -1
- strawberry/schema/types/concrete_type.py +5 -5
- strawberry/schema/validation_rules/maybe_null.py +136 -0
- strawberry/schema_codegen/__init__.py +3 -3
- strawberry/schema_directive.py +7 -6
- strawberry/static/graphiql.html +5 -5
- strawberry/streamable.py +35 -0
- strawberry/subscriptions/protocols/graphql_transport_ws/handlers.py +5 -16
- strawberry/subscriptions/protocols/graphql_transport_ws/types.py +20 -20
- strawberry/subscriptions/protocols/graphql_ws/handlers.py +5 -12
- strawberry/subscriptions/protocols/graphql_ws/types.py +14 -14
- strawberry/test/client.py +18 -18
- strawberry/tools/create_type.py +2 -3
- strawberry/types/arguments.py +41 -28
- strawberry/types/auto.py +3 -4
- strawberry/types/base.py +25 -27
- strawberry/types/enum.py +22 -25
- strawberry/types/execution.py +21 -16
- strawberry/types/field.py +109 -130
- strawberry/types/fields/resolver.py +19 -21
- strawberry/types/info.py +5 -11
- strawberry/types/lazy_type.py +2 -3
- strawberry/types/maybe.py +12 -3
- strawberry/types/mutation.py +115 -118
- strawberry/types/nodes.py +2 -2
- strawberry/types/object_type.py +43 -63
- strawberry/types/scalar.py +37 -43
- strawberry/types/union.py +12 -14
- strawberry/utils/aio.py +12 -9
- strawberry/utils/await_maybe.py +3 -3
- strawberry/utils/deprecations.py +2 -2
- strawberry/utils/importer.py +1 -2
- strawberry/utils/inspect.py +4 -6
- strawberry/utils/logging.py +2 -2
- strawberry/utils/operation.py +4 -4
- strawberry/utils/typing.py +18 -83
- {strawberry_graphql-0.275.7.dist-info → strawberry_graphql-0.284.3.dist-info}/METADATA +14 -8
- strawberry_graphql-0.284.3.dist-info/RECORD +243 -0
- {strawberry_graphql-0.275.7.dist-info → strawberry_graphql-0.284.3.dist-info}/WHEEL +1 -1
- strawberry/utils/dataclasses.py +0 -37
- strawberry/utils/debug.py +0 -46
- strawberry/utils/graphql_lexer.py +0 -35
- strawberry_graphql-0.275.7.dist-info/RECORD +0 -241
- {strawberry_graphql-0.275.7.dist-info → strawberry_graphql-0.284.3.dist-info}/entry_points.txt +0 -0
- {strawberry_graphql-0.275.7.dist-info → strawberry_graphql-0.284.3.dist-info/licenses}/LICENSE +0 -0
|
@@ -10,15 +10,13 @@ from typing import (
|
|
|
10
10
|
TYPE_CHECKING,
|
|
11
11
|
Annotated,
|
|
12
12
|
Any,
|
|
13
|
-
Callable,
|
|
14
13
|
Generic,
|
|
15
14
|
NamedTuple,
|
|
16
|
-
Optional,
|
|
17
15
|
TypeVar,
|
|
18
|
-
Union,
|
|
19
16
|
cast,
|
|
17
|
+
get_origin,
|
|
20
18
|
)
|
|
21
|
-
from typing_extensions import Protocol
|
|
19
|
+
from typing_extensions import Protocol
|
|
22
20
|
|
|
23
21
|
from strawberry.annotation import StrawberryAnnotation
|
|
24
22
|
from strawberry.exceptions import (
|
|
@@ -33,7 +31,7 @@ from strawberry.utils.typing import type_has_annotation
|
|
|
33
31
|
|
|
34
32
|
if TYPE_CHECKING:
|
|
35
33
|
import builtins
|
|
36
|
-
from collections.abc import Mapping
|
|
34
|
+
from collections.abc import Callable, Mapping
|
|
37
35
|
|
|
38
36
|
|
|
39
37
|
class Parameter(inspect.Parameter):
|
|
@@ -63,7 +61,7 @@ class ReservedParameterSpecification(Protocol):
|
|
|
63
61
|
self,
|
|
64
62
|
parameters: tuple[inspect.Parameter, ...],
|
|
65
63
|
resolver: StrawberryResolver[Any],
|
|
66
|
-
) ->
|
|
64
|
+
) -> inspect.Parameter | None:
|
|
67
65
|
"""Finds the reserved parameter from ``parameters``."""
|
|
68
66
|
|
|
69
67
|
|
|
@@ -74,7 +72,7 @@ class ReservedName(NamedTuple):
|
|
|
74
72
|
self,
|
|
75
73
|
parameters: tuple[inspect.Parameter, ...],
|
|
76
74
|
resolver: StrawberryResolver[Any],
|
|
77
|
-
) ->
|
|
75
|
+
) -> inspect.Parameter | None:
|
|
78
76
|
del resolver
|
|
79
77
|
return next((p for p in parameters if p.name == self.name), None)
|
|
80
78
|
|
|
@@ -86,7 +84,7 @@ class ReservedNameBoundParameter(NamedTuple):
|
|
|
86
84
|
self,
|
|
87
85
|
parameters: tuple[inspect.Parameter, ...],
|
|
88
86
|
resolver: StrawberryResolver[Any],
|
|
89
|
-
) ->
|
|
87
|
+
) -> inspect.Parameter | None:
|
|
90
88
|
del resolver
|
|
91
89
|
if parameters: # Add compatibility for resolvers with no arguments
|
|
92
90
|
first_parameter = parameters[0]
|
|
@@ -108,7 +106,7 @@ class ReservedType(NamedTuple):
|
|
|
108
106
|
self,
|
|
109
107
|
parameters: tuple[inspect.Parameter, ...],
|
|
110
108
|
resolver: StrawberryResolver[Any],
|
|
111
|
-
) ->
|
|
109
|
+
) -> inspect.Parameter | None:
|
|
112
110
|
# Go through all the types even after we've found one so we can
|
|
113
111
|
# give a helpful error message if someone uses the type more than once.
|
|
114
112
|
type_parameters = []
|
|
@@ -193,10 +191,10 @@ class StrawberryResolver(Generic[T]):
|
|
|
193
191
|
|
|
194
192
|
def __init__(
|
|
195
193
|
self,
|
|
196
|
-
func:
|
|
194
|
+
func: Callable[..., T] | staticmethod | classmethod,
|
|
197
195
|
*,
|
|
198
|
-
description:
|
|
199
|
-
type_override:
|
|
196
|
+
description: str | None = None,
|
|
197
|
+
type_override: StrawberryType | type | None = None,
|
|
200
198
|
) -> None:
|
|
201
199
|
self.wrapped_func = func
|
|
202
200
|
self._description = description
|
|
@@ -220,7 +218,7 @@ class StrawberryResolver(Generic[T]):
|
|
|
220
218
|
@cached_property
|
|
221
219
|
def strawberry_annotations(
|
|
222
220
|
self,
|
|
223
|
-
) -> dict[inspect.Parameter,
|
|
221
|
+
) -> dict[inspect.Parameter, StrawberryAnnotation | None]:
|
|
224
222
|
return {
|
|
225
223
|
p: (
|
|
226
224
|
StrawberryAnnotation(p.annotation, namespace=self._namespace)
|
|
@@ -233,7 +231,7 @@ class StrawberryResolver(Generic[T]):
|
|
|
233
231
|
@cached_property
|
|
234
232
|
def reserved_parameters(
|
|
235
233
|
self,
|
|
236
|
-
) -> dict[ReservedParameterSpecification,
|
|
234
|
+
) -> dict[ReservedParameterSpecification, inspect.Parameter | None]:
|
|
237
235
|
"""Mapping of reserved parameter specification to parameter."""
|
|
238
236
|
parameters = tuple(self.signature.parameters.values())
|
|
239
237
|
return {spec: spec.find(parameters, self) for spec in self.RESERVED_PARAMSPEC}
|
|
@@ -281,19 +279,19 @@ class StrawberryResolver(Generic[T]):
|
|
|
281
279
|
return arguments
|
|
282
280
|
|
|
283
281
|
@cached_property
|
|
284
|
-
def info_parameter(self) ->
|
|
282
|
+
def info_parameter(self) -> inspect.Parameter | None:
|
|
285
283
|
return self.reserved_parameters.get(INFO_PARAMSPEC)
|
|
286
284
|
|
|
287
285
|
@cached_property
|
|
288
|
-
def root_parameter(self) ->
|
|
286
|
+
def root_parameter(self) -> inspect.Parameter | None:
|
|
289
287
|
return self.reserved_parameters.get(ROOT_PARAMSPEC)
|
|
290
288
|
|
|
291
289
|
@cached_property
|
|
292
|
-
def self_parameter(self) ->
|
|
290
|
+
def self_parameter(self) -> inspect.Parameter | None:
|
|
293
291
|
return self.reserved_parameters.get(SELF_PARAMSPEC)
|
|
294
292
|
|
|
295
293
|
@cached_property
|
|
296
|
-
def parent_parameter(self) ->
|
|
294
|
+
def parent_parameter(self) -> inspect.Parameter | None:
|
|
297
295
|
return self.reserved_parameters.get(PARENT_PARAMSPEC)
|
|
298
296
|
|
|
299
297
|
@cached_property
|
|
@@ -320,7 +318,7 @@ class StrawberryResolver(Generic[T]):
|
|
|
320
318
|
}
|
|
321
319
|
|
|
322
320
|
@cached_property
|
|
323
|
-
def type_annotation(self) ->
|
|
321
|
+
def type_annotation(self) -> StrawberryAnnotation | None:
|
|
324
322
|
return_annotation = self.signature.return_annotation
|
|
325
323
|
if return_annotation is inspect.Signature.empty:
|
|
326
324
|
return None
|
|
@@ -329,7 +327,7 @@ class StrawberryResolver(Generic[T]):
|
|
|
329
327
|
)
|
|
330
328
|
|
|
331
329
|
@property
|
|
332
|
-
def type(self) ->
|
|
330
|
+
def type(self) -> StrawberryType | type | None:
|
|
333
331
|
if self._type_override:
|
|
334
332
|
return self._type_override
|
|
335
333
|
if self.type_annotation is None:
|
|
@@ -355,7 +353,7 @@ class StrawberryResolver(Generic[T]):
|
|
|
355
353
|
)
|
|
356
354
|
|
|
357
355
|
def copy_with(
|
|
358
|
-
self, type_var_map: Mapping[str,
|
|
356
|
+
self, type_var_map: Mapping[str, StrawberryType | builtins.type]
|
|
359
357
|
) -> StrawberryResolver:
|
|
360
358
|
type_override = None
|
|
361
359
|
|
strawberry/types/info.py
CHANGED
|
@@ -7,8 +7,6 @@ from typing import (
|
|
|
7
7
|
TYPE_CHECKING,
|
|
8
8
|
Any,
|
|
9
9
|
Generic,
|
|
10
|
-
Optional,
|
|
11
|
-
Union,
|
|
12
10
|
)
|
|
13
11
|
from typing_extensions import TypeVar
|
|
14
12
|
|
|
@@ -21,11 +19,7 @@ if TYPE_CHECKING:
|
|
|
21
19
|
|
|
22
20
|
from strawberry.schema import Schema
|
|
23
21
|
from strawberry.types.arguments import StrawberryArgument
|
|
24
|
-
from strawberry.types.
|
|
25
|
-
StrawberryType,
|
|
26
|
-
WithStrawberryObjectDefinition,
|
|
27
|
-
)
|
|
28
|
-
from strawberry.types.field import StrawberryField
|
|
22
|
+
from strawberry.types.field import FieldType, StrawberryField
|
|
29
23
|
|
|
30
24
|
from .nodes import Selection
|
|
31
25
|
|
|
@@ -68,7 +62,7 @@ class Info(Generic[ContextType, RootValueType]):
|
|
|
68
62
|
_raw_info: GraphQLResolveInfo
|
|
69
63
|
_field: StrawberryField
|
|
70
64
|
|
|
71
|
-
def __class_getitem__(cls, types:
|
|
65
|
+
def __class_getitem__(cls, types: type | tuple[type, ...]) -> type[Info]:
|
|
72
66
|
"""Workaround for when passing only one type.
|
|
73
67
|
|
|
74
68
|
Python doesn't yet support directly passing only one type to a generic class
|
|
@@ -78,7 +72,7 @@ class Info(Generic[ContextType, RootValueType]):
|
|
|
78
72
|
https://discuss.python.org/t/passing-only-one-typevar-of-two-when-using-defaults/49134
|
|
79
73
|
"""
|
|
80
74
|
if not isinstance(types, tuple):
|
|
81
|
-
types = (types, Any)
|
|
75
|
+
types = (types, Any)
|
|
82
76
|
|
|
83
77
|
return super().__class_getitem__(types) # type: ignore
|
|
84
78
|
|
|
@@ -131,7 +125,7 @@ class Info(Generic[ContextType, RootValueType]):
|
|
|
131
125
|
@property
|
|
132
126
|
def return_type(
|
|
133
127
|
self,
|
|
134
|
-
) ->
|
|
128
|
+
) -> FieldType:
|
|
135
129
|
"""The return type of the current field being resolved."""
|
|
136
130
|
return self._field.type
|
|
137
131
|
|
|
@@ -154,7 +148,7 @@ class Info(Generic[ContextType, RootValueType]):
|
|
|
154
148
|
# TODO: parent_type as strawberry types
|
|
155
149
|
|
|
156
150
|
# Helper functions
|
|
157
|
-
def get_argument_definition(self, name: str) ->
|
|
151
|
+
def get_argument_definition(self, name: str) -> StrawberryArgument | None:
|
|
158
152
|
"""Get the StrawberryArgument definition for the current field by name."""
|
|
159
153
|
try:
|
|
160
154
|
return next(arg for arg in self._field.arguments if arg.python_name == name)
|
strawberry/types/lazy_type.py
CHANGED
|
@@ -8,7 +8,6 @@ from typing import (
|
|
|
8
8
|
Any,
|
|
9
9
|
ForwardRef,
|
|
10
10
|
Generic,
|
|
11
|
-
Optional,
|
|
12
11
|
TypeVar,
|
|
13
12
|
Union,
|
|
14
13
|
cast,
|
|
@@ -32,7 +31,7 @@ class LazyType(Generic[TypeName, Module]):
|
|
|
32
31
|
|
|
33
32
|
type_name: str
|
|
34
33
|
module: str
|
|
35
|
-
package:
|
|
34
|
+
package: str | None = None
|
|
36
35
|
|
|
37
36
|
def __class_getitem__(cls, params: tuple[str, str]) -> "Self":
|
|
38
37
|
warnings.warn(
|
|
@@ -57,7 +56,7 @@ class LazyType(Generic[TypeName, Module]):
|
|
|
57
56
|
return cls(type_name, module, package)
|
|
58
57
|
|
|
59
58
|
def __or__(self, other: Other) -> object:
|
|
60
|
-
return Union[self, other]
|
|
59
|
+
return Union[self, other] # noqa: UP007
|
|
61
60
|
|
|
62
61
|
def resolve_type(self) -> type[Any]:
|
|
63
62
|
module = importlib.import_module(self.module, self.package)
|
strawberry/types/maybe.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import re
|
|
1
2
|
import typing
|
|
2
|
-
from typing import TYPE_CHECKING, Any, Generic,
|
|
3
|
-
from typing_extensions import TypeAlias
|
|
3
|
+
from typing import TYPE_CHECKING, Any, Generic, TypeAlias, TypeVar
|
|
4
4
|
|
|
5
5
|
T = TypeVar("T")
|
|
6
6
|
|
|
@@ -31,13 +31,22 @@ class Some(Generic[T]):
|
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
if TYPE_CHECKING:
|
|
34
|
-
Maybe: TypeAlias =
|
|
34
|
+
Maybe: TypeAlias = Some[T] | None
|
|
35
35
|
else:
|
|
36
36
|
# we do this trick so we can inspect that at runtime
|
|
37
37
|
class Maybe(Generic[T]): ...
|
|
38
38
|
|
|
39
39
|
|
|
40
|
+
_maybe_re = re.compile(r"^(?:strawberry\.)?Maybe\[(.+)\]$")
|
|
41
|
+
|
|
42
|
+
|
|
40
43
|
def _annotation_is_maybe(annotation: Any) -> bool:
|
|
44
|
+
if isinstance(annotation, str):
|
|
45
|
+
# Ideally we would try to evaluate the annotation, but the args inside
|
|
46
|
+
# may still not be available, as the module is still being constructed.
|
|
47
|
+
# Checking for the pattern should be good enough for now.
|
|
48
|
+
return _maybe_re.match(annotation) is not None
|
|
49
|
+
|
|
41
50
|
return (orig := typing.get_origin(annotation)) and orig is Maybe
|
|
42
51
|
|
|
43
52
|
|
strawberry/types/mutation.py
CHANGED
|
@@ -4,12 +4,9 @@ import dataclasses
|
|
|
4
4
|
from typing import (
|
|
5
5
|
TYPE_CHECKING,
|
|
6
6
|
Any,
|
|
7
|
-
|
|
8
|
-
Optional,
|
|
9
|
-
Union,
|
|
7
|
+
Literal,
|
|
10
8
|
overload,
|
|
11
9
|
)
|
|
12
|
-
from typing_extensions import Literal
|
|
13
10
|
|
|
14
11
|
from strawberry.types.field import (
|
|
15
12
|
_RESOLVER_TYPE,
|
|
@@ -21,8 +18,8 @@ from strawberry.types.field import (
|
|
|
21
18
|
)
|
|
22
19
|
|
|
23
20
|
if TYPE_CHECKING:
|
|
24
|
-
from collections.abc import Mapping, Sequence
|
|
25
|
-
from
|
|
21
|
+
from collections.abc import Callable, Mapping, Sequence
|
|
22
|
+
from typing import Literal
|
|
26
23
|
|
|
27
24
|
from strawberry.extensions.field_extension import FieldExtension
|
|
28
25
|
from strawberry.permission import BasePermission
|
|
@@ -35,17 +32,17 @@ if TYPE_CHECKING:
|
|
|
35
32
|
def mutation(
|
|
36
33
|
*,
|
|
37
34
|
resolver: _RESOLVER_TYPE_ASYNC[T],
|
|
38
|
-
name:
|
|
39
|
-
description:
|
|
35
|
+
name: str | None = None,
|
|
36
|
+
description: str | None = None,
|
|
40
37
|
init: Literal[False] = False,
|
|
41
|
-
permission_classes:
|
|
42
|
-
deprecation_reason:
|
|
38
|
+
permission_classes: list[type[BasePermission]] | None = None,
|
|
39
|
+
deprecation_reason: str | None = None,
|
|
43
40
|
default: Any = dataclasses.MISSING,
|
|
44
|
-
default_factory:
|
|
45
|
-
metadata:
|
|
46
|
-
directives:
|
|
47
|
-
extensions:
|
|
48
|
-
graphql_type:
|
|
41
|
+
default_factory: Callable[..., object] | object = dataclasses.MISSING,
|
|
42
|
+
metadata: Mapping[Any, Any] | None = None,
|
|
43
|
+
directives: Sequence[object] | None = (),
|
|
44
|
+
extensions: list[FieldExtension] | None = None,
|
|
45
|
+
graphql_type: Any | None = None,
|
|
49
46
|
) -> T: ...
|
|
50
47
|
|
|
51
48
|
|
|
@@ -53,34 +50,34 @@ def mutation(
|
|
|
53
50
|
def mutation(
|
|
54
51
|
*,
|
|
55
52
|
resolver: _RESOLVER_TYPE_SYNC[T],
|
|
56
|
-
name:
|
|
57
|
-
description:
|
|
53
|
+
name: str | None = None,
|
|
54
|
+
description: str | None = None,
|
|
58
55
|
init: Literal[False] = False,
|
|
59
|
-
permission_classes:
|
|
60
|
-
deprecation_reason:
|
|
56
|
+
permission_classes: list[type[BasePermission]] | None = None,
|
|
57
|
+
deprecation_reason: str | None = None,
|
|
61
58
|
default: Any = dataclasses.MISSING,
|
|
62
|
-
default_factory:
|
|
63
|
-
metadata:
|
|
64
|
-
directives:
|
|
65
|
-
extensions:
|
|
66
|
-
graphql_type:
|
|
59
|
+
default_factory: Callable[..., object] | object = dataclasses.MISSING,
|
|
60
|
+
metadata: Mapping[Any, Any] | None = None,
|
|
61
|
+
directives: Sequence[object] | None = (),
|
|
62
|
+
extensions: list[FieldExtension] | None = None,
|
|
63
|
+
graphql_type: Any | None = None,
|
|
67
64
|
) -> T: ...
|
|
68
65
|
|
|
69
66
|
|
|
70
67
|
@overload
|
|
71
68
|
def mutation(
|
|
72
69
|
*,
|
|
73
|
-
name:
|
|
74
|
-
description:
|
|
70
|
+
name: str | None = None,
|
|
71
|
+
description: str | None = None,
|
|
75
72
|
init: Literal[True] = True,
|
|
76
|
-
permission_classes:
|
|
77
|
-
deprecation_reason:
|
|
73
|
+
permission_classes: list[type[BasePermission]] | None = None,
|
|
74
|
+
deprecation_reason: str | None = None,
|
|
78
75
|
default: Any = dataclasses.MISSING,
|
|
79
|
-
default_factory:
|
|
80
|
-
metadata:
|
|
81
|
-
directives:
|
|
82
|
-
extensions:
|
|
83
|
-
graphql_type:
|
|
76
|
+
default_factory: Callable[..., object] | object = dataclasses.MISSING,
|
|
77
|
+
metadata: Mapping[Any, Any] | None = None,
|
|
78
|
+
directives: Sequence[object] | None = (),
|
|
79
|
+
extensions: list[FieldExtension] | None = None,
|
|
80
|
+
graphql_type: Any | None = None,
|
|
84
81
|
) -> Any: ...
|
|
85
82
|
|
|
86
83
|
|
|
@@ -88,16 +85,16 @@ def mutation(
|
|
|
88
85
|
def mutation(
|
|
89
86
|
resolver: _RESOLVER_TYPE_ASYNC[T],
|
|
90
87
|
*,
|
|
91
|
-
name:
|
|
92
|
-
description:
|
|
93
|
-
permission_classes:
|
|
94
|
-
deprecation_reason:
|
|
88
|
+
name: str | None = None,
|
|
89
|
+
description: str | None = None,
|
|
90
|
+
permission_classes: list[type[BasePermission]] | None = None,
|
|
91
|
+
deprecation_reason: str | None = None,
|
|
95
92
|
default: Any = dataclasses.MISSING,
|
|
96
|
-
default_factory:
|
|
97
|
-
metadata:
|
|
98
|
-
directives:
|
|
99
|
-
extensions:
|
|
100
|
-
graphql_type:
|
|
93
|
+
default_factory: Callable[..., object] | object = dataclasses.MISSING,
|
|
94
|
+
metadata: Mapping[Any, Any] | None = None,
|
|
95
|
+
directives: Sequence[object] | None = (),
|
|
96
|
+
extensions: list[FieldExtension] | None = None,
|
|
97
|
+
graphql_type: Any | None = None,
|
|
101
98
|
) -> StrawberryField: ...
|
|
102
99
|
|
|
103
100
|
|
|
@@ -105,36 +102,36 @@ def mutation(
|
|
|
105
102
|
def mutation(
|
|
106
103
|
resolver: _RESOLVER_TYPE_SYNC[T],
|
|
107
104
|
*,
|
|
108
|
-
name:
|
|
109
|
-
description:
|
|
110
|
-
permission_classes:
|
|
111
|
-
deprecation_reason:
|
|
105
|
+
name: str | None = None,
|
|
106
|
+
description: str | None = None,
|
|
107
|
+
permission_classes: list[type[BasePermission]] | None = None,
|
|
108
|
+
deprecation_reason: str | None = None,
|
|
112
109
|
default: Any = dataclasses.MISSING,
|
|
113
|
-
default_factory:
|
|
114
|
-
metadata:
|
|
115
|
-
directives:
|
|
116
|
-
extensions:
|
|
117
|
-
graphql_type:
|
|
110
|
+
default_factory: Callable[..., object] | object = dataclasses.MISSING,
|
|
111
|
+
metadata: Mapping[Any, Any] | None = None,
|
|
112
|
+
directives: Sequence[object] | None = (),
|
|
113
|
+
extensions: list[FieldExtension] | None = None,
|
|
114
|
+
graphql_type: Any | None = None,
|
|
118
115
|
) -> StrawberryField: ...
|
|
119
116
|
|
|
120
117
|
|
|
121
118
|
def mutation(
|
|
122
|
-
resolver:
|
|
119
|
+
resolver: _RESOLVER_TYPE[Any] | None = None,
|
|
123
120
|
*,
|
|
124
|
-
name:
|
|
125
|
-
description:
|
|
126
|
-
permission_classes:
|
|
127
|
-
deprecation_reason:
|
|
121
|
+
name: str | None = None,
|
|
122
|
+
description: str | None = None,
|
|
123
|
+
permission_classes: list[type[BasePermission]] | None = None,
|
|
124
|
+
deprecation_reason: str | None = None,
|
|
128
125
|
default: Any = dataclasses.MISSING,
|
|
129
|
-
default_factory:
|
|
130
|
-
metadata:
|
|
131
|
-
directives:
|
|
132
|
-
extensions:
|
|
133
|
-
graphql_type:
|
|
126
|
+
default_factory: Callable[..., object] | object = dataclasses.MISSING,
|
|
127
|
+
metadata: Mapping[Any, Any] | None = None,
|
|
128
|
+
directives: Sequence[object] | None = (),
|
|
129
|
+
extensions: list[FieldExtension] | None = None,
|
|
130
|
+
graphql_type: Any | None = None,
|
|
134
131
|
# This init parameter is used by PyRight to determine whether this field
|
|
135
132
|
# is added in the constructor or not. It is not used to change
|
|
136
133
|
# any behavior at the moment.
|
|
137
|
-
init: Literal[True, False
|
|
134
|
+
init: Literal[True, False] | None = None,
|
|
138
135
|
) -> Any:
|
|
139
136
|
"""Annotates a method or property as a GraphQL mutation.
|
|
140
137
|
|
|
@@ -195,17 +192,17 @@ def mutation(
|
|
|
195
192
|
def subscription(
|
|
196
193
|
*,
|
|
197
194
|
resolver: _RESOLVER_TYPE_ASYNC[T],
|
|
198
|
-
name:
|
|
199
|
-
description:
|
|
195
|
+
name: str | None = None,
|
|
196
|
+
description: str | None = None,
|
|
200
197
|
init: Literal[False] = False,
|
|
201
|
-
permission_classes:
|
|
202
|
-
deprecation_reason:
|
|
198
|
+
permission_classes: list[type[BasePermission]] | None = None,
|
|
199
|
+
deprecation_reason: str | None = None,
|
|
203
200
|
default: Any = dataclasses.MISSING,
|
|
204
|
-
default_factory:
|
|
205
|
-
metadata:
|
|
206
|
-
directives:
|
|
207
|
-
extensions:
|
|
208
|
-
graphql_type:
|
|
201
|
+
default_factory: Callable[..., object] | object = dataclasses.MISSING,
|
|
202
|
+
metadata: Mapping[Any, Any] | None = None,
|
|
203
|
+
directives: Sequence[object] | None = (),
|
|
204
|
+
extensions: list[FieldExtension] | None = None,
|
|
205
|
+
graphql_type: Any | None = None,
|
|
209
206
|
) -> T: ...
|
|
210
207
|
|
|
211
208
|
|
|
@@ -213,34 +210,34 @@ def subscription(
|
|
|
213
210
|
def subscription(
|
|
214
211
|
*,
|
|
215
212
|
resolver: _RESOLVER_TYPE_SYNC[T],
|
|
216
|
-
name:
|
|
217
|
-
description:
|
|
213
|
+
name: str | None = None,
|
|
214
|
+
description: str | None = None,
|
|
218
215
|
init: Literal[False] = False,
|
|
219
|
-
permission_classes:
|
|
220
|
-
deprecation_reason:
|
|
216
|
+
permission_classes: list[type[BasePermission]] | None = None,
|
|
217
|
+
deprecation_reason: str | None = None,
|
|
221
218
|
default: Any = dataclasses.MISSING,
|
|
222
|
-
default_factory:
|
|
223
|
-
metadata:
|
|
224
|
-
directives:
|
|
225
|
-
extensions:
|
|
226
|
-
graphql_type:
|
|
219
|
+
default_factory: Callable[..., object] | object = dataclasses.MISSING,
|
|
220
|
+
metadata: Mapping[Any, Any] | None = None,
|
|
221
|
+
directives: Sequence[object] | None = (),
|
|
222
|
+
extensions: list[FieldExtension] | None = None,
|
|
223
|
+
graphql_type: Any | None = None,
|
|
227
224
|
) -> T: ...
|
|
228
225
|
|
|
229
226
|
|
|
230
227
|
@overload
|
|
231
228
|
def subscription(
|
|
232
229
|
*,
|
|
233
|
-
name:
|
|
234
|
-
description:
|
|
230
|
+
name: str | None = None,
|
|
231
|
+
description: str | None = None,
|
|
235
232
|
init: Literal[True] = True,
|
|
236
|
-
permission_classes:
|
|
237
|
-
deprecation_reason:
|
|
233
|
+
permission_classes: list[type[BasePermission]] | None = None,
|
|
234
|
+
deprecation_reason: str | None = None,
|
|
238
235
|
default: Any = dataclasses.MISSING,
|
|
239
|
-
default_factory:
|
|
240
|
-
metadata:
|
|
241
|
-
directives:
|
|
242
|
-
extensions:
|
|
243
|
-
graphql_type:
|
|
236
|
+
default_factory: Callable[..., object] | object = dataclasses.MISSING,
|
|
237
|
+
metadata: Mapping[Any, Any] | None = None,
|
|
238
|
+
directives: Sequence[object] | None = (),
|
|
239
|
+
extensions: list[FieldExtension] | None = None,
|
|
240
|
+
graphql_type: Any | None = None,
|
|
244
241
|
) -> Any: ...
|
|
245
242
|
|
|
246
243
|
|
|
@@ -248,16 +245,16 @@ def subscription(
|
|
|
248
245
|
def subscription(
|
|
249
246
|
resolver: _RESOLVER_TYPE_ASYNC[T],
|
|
250
247
|
*,
|
|
251
|
-
name:
|
|
252
|
-
description:
|
|
253
|
-
permission_classes:
|
|
254
|
-
deprecation_reason:
|
|
248
|
+
name: str | None = None,
|
|
249
|
+
description: str | None = None,
|
|
250
|
+
permission_classes: list[type[BasePermission]] | None = None,
|
|
251
|
+
deprecation_reason: str | None = None,
|
|
255
252
|
default: Any = dataclasses.MISSING,
|
|
256
|
-
default_factory:
|
|
257
|
-
metadata:
|
|
258
|
-
directives:
|
|
259
|
-
extensions:
|
|
260
|
-
graphql_type:
|
|
253
|
+
default_factory: Callable[..., object] | object = dataclasses.MISSING,
|
|
254
|
+
metadata: Mapping[Any, Any] | None = None,
|
|
255
|
+
directives: Sequence[object] | None = (),
|
|
256
|
+
extensions: list[FieldExtension] | None = None,
|
|
257
|
+
graphql_type: Any | None = None,
|
|
261
258
|
) -> StrawberryField: ...
|
|
262
259
|
|
|
263
260
|
|
|
@@ -265,33 +262,33 @@ def subscription(
|
|
|
265
262
|
def subscription(
|
|
266
263
|
resolver: _RESOLVER_TYPE_SYNC[T],
|
|
267
264
|
*,
|
|
268
|
-
name:
|
|
269
|
-
description:
|
|
270
|
-
permission_classes:
|
|
271
|
-
deprecation_reason:
|
|
265
|
+
name: str | None = None,
|
|
266
|
+
description: str | None = None,
|
|
267
|
+
permission_classes: list[type[BasePermission]] | None = None,
|
|
268
|
+
deprecation_reason: str | None = None,
|
|
272
269
|
default: Any = dataclasses.MISSING,
|
|
273
|
-
default_factory:
|
|
274
|
-
metadata:
|
|
275
|
-
directives:
|
|
276
|
-
extensions:
|
|
277
|
-
graphql_type:
|
|
270
|
+
default_factory: Callable[..., object] | object = dataclasses.MISSING,
|
|
271
|
+
metadata: Mapping[Any, Any] | None = None,
|
|
272
|
+
directives: Sequence[object] | None = (),
|
|
273
|
+
extensions: list[FieldExtension] | None = None,
|
|
274
|
+
graphql_type: Any | None = None,
|
|
278
275
|
) -> StrawberryField: ...
|
|
279
276
|
|
|
280
277
|
|
|
281
278
|
def subscription(
|
|
282
|
-
resolver:
|
|
279
|
+
resolver: _RESOLVER_TYPE[Any] | None = None,
|
|
283
280
|
*,
|
|
284
|
-
name:
|
|
285
|
-
description:
|
|
286
|
-
permission_classes:
|
|
287
|
-
deprecation_reason:
|
|
281
|
+
name: str | None = None,
|
|
282
|
+
description: str | None = None,
|
|
283
|
+
permission_classes: list[type[BasePermission]] | None = None,
|
|
284
|
+
deprecation_reason: str | None = None,
|
|
288
285
|
default: Any = dataclasses.MISSING,
|
|
289
|
-
default_factory:
|
|
290
|
-
metadata:
|
|
291
|
-
directives:
|
|
292
|
-
extensions:
|
|
293
|
-
graphql_type:
|
|
294
|
-
init: Literal[True, False
|
|
286
|
+
default_factory: Callable[..., object] | object = dataclasses.MISSING,
|
|
287
|
+
metadata: Mapping[Any, Any] | None = None,
|
|
288
|
+
directives: Sequence[object] | None = (),
|
|
289
|
+
extensions: list[FieldExtension] | None = None,
|
|
290
|
+
graphql_type: Any | None = None,
|
|
291
|
+
init: Literal[True, False] | None = None,
|
|
295
292
|
) -> Any:
|
|
296
293
|
"""Annotates a method or property as a GraphQL subscription.
|
|
297
294
|
|
strawberry/types/nodes.py
CHANGED
|
@@ -12,7 +12,7 @@ Note Python dicts maintain ordering (for all supported versions).
|
|
|
12
12
|
from __future__ import annotations
|
|
13
13
|
|
|
14
14
|
import dataclasses
|
|
15
|
-
from typing import TYPE_CHECKING, Any,
|
|
15
|
+
from typing import TYPE_CHECKING, Any, Union
|
|
16
16
|
|
|
17
17
|
from graphql.language import FieldNode as GQLFieldNode
|
|
18
18
|
from graphql.language import FragmentSpreadNode as GQLFragmentSpreadNode
|
|
@@ -139,7 +139,7 @@ class SelectedField:
|
|
|
139
139
|
directives: Directives
|
|
140
140
|
arguments: Arguments
|
|
141
141
|
selections: list[Selection]
|
|
142
|
-
alias:
|
|
142
|
+
alias: str | None = None
|
|
143
143
|
|
|
144
144
|
@classmethod
|
|
145
145
|
def from_node(cls, info: GraphQLResolveInfo, node: GQLFieldNode) -> SelectedField:
|