strawberry-graphql 0.255.0__py3-none-any.whl → 0.256.1__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 +9 -9
- strawberry/aiohttp/test/client.py +10 -8
- strawberry/aiohttp/views.py +5 -7
- strawberry/annotation.py +12 -15
- strawberry/asgi/__init__.py +3 -6
- strawberry/asgi/test/client.py +9 -8
- strawberry/chalice/views.py +4 -2
- strawberry/channels/__init__.py +1 -1
- strawberry/channels/handlers/base.py +3 -7
- strawberry/channels/handlers/http_handler.py +5 -6
- strawberry/channels/handlers/ws_handler.py +3 -4
- strawberry/channels/testing.py +5 -9
- strawberry/cli/commands/codegen.py +9 -9
- strawberry/cli/commands/upgrade/__init__.py +2 -3
- strawberry/cli/commands/upgrade/_run_codemod.py +7 -5
- strawberry/codegen/exceptions.py +2 -2
- strawberry/codegen/plugins/print_operation.py +6 -6
- strawberry/codegen/plugins/python.py +6 -6
- strawberry/codegen/plugins/typescript.py +3 -3
- strawberry/codegen/query_codegen.py +29 -34
- strawberry/codegen/types.py +35 -34
- strawberry/codemods/annotated_unions.py +5 -2
- strawberry/dataloader.py +13 -20
- strawberry/directive.py +12 -5
- strawberry/django/test/client.py +4 -4
- strawberry/django/views.py +4 -5
- strawberry/exceptions/__init__.py +24 -24
- strawberry/exceptions/conflicting_arguments.py +2 -2
- strawberry/exceptions/duplicated_type_name.py +3 -3
- strawberry/exceptions/handler.py +7 -7
- strawberry/exceptions/invalid_union_type.py +2 -2
- strawberry/exceptions/missing_arguments_annotations.py +2 -2
- strawberry/exceptions/missing_field_annotation.py +2 -2
- strawberry/exceptions/object_is_not_an_enum.py +2 -2
- strawberry/exceptions/private_strawberry_field.py +2 -2
- strawberry/exceptions/syntax.py +4 -4
- strawberry/exceptions/utils/source_finder.py +7 -6
- strawberry/experimental/pydantic/__init__.py +3 -3
- strawberry/experimental/pydantic/_compat.py +14 -14
- strawberry/experimental/pydantic/conversion.py +2 -2
- strawberry/experimental/pydantic/conversion_types.py +3 -3
- strawberry/experimental/pydantic/error_type.py +18 -16
- strawberry/experimental/pydantic/exceptions.py +5 -5
- strawberry/experimental/pydantic/fields.py +2 -13
- strawberry/experimental/pydantic/object_type.py +20 -22
- strawberry/experimental/pydantic/utils.py +6 -10
- strawberry/ext/dataclasses/dataclasses.py +3 -3
- strawberry/ext/mypy_plugin.py +6 -9
- strawberry/extensions/__init__.py +7 -8
- strawberry/extensions/add_validation_rules.py +5 -3
- strawberry/extensions/base_extension.py +4 -4
- strawberry/extensions/context.py +15 -14
- strawberry/extensions/directives.py +2 -2
- strawberry/extensions/disable_validation.py +1 -1
- strawberry/extensions/field_extension.py +2 -1
- strawberry/extensions/mask_errors.py +3 -2
- strawberry/extensions/max_aliases.py +2 -2
- strawberry/extensions/max_tokens.py +1 -1
- strawberry/extensions/parser_cache.py +2 -1
- strawberry/extensions/pyinstrument.py +5 -2
- strawberry/extensions/query_depth_limiter.py +13 -13
- strawberry/extensions/runner.py +7 -7
- strawberry/extensions/tracing/apollo.py +11 -9
- strawberry/extensions/tracing/datadog.py +3 -1
- strawberry/extensions/tracing/opentelemetry.py +7 -10
- strawberry/extensions/utils.py +3 -3
- strawberry/extensions/validation_cache.py +2 -1
- strawberry/fastapi/context.py +3 -3
- strawberry/fastapi/router.py +9 -14
- strawberry/federation/__init__.py +4 -4
- strawberry/federation/argument.py +2 -1
- strawberry/federation/enum.py +8 -8
- strawberry/federation/field.py +25 -28
- strawberry/federation/object_type.py +24 -26
- strawberry/federation/scalar.py +7 -8
- strawberry/federation/schema.py +30 -36
- strawberry/federation/schema_directive.py +5 -5
- strawberry/federation/schema_directives.py +14 -14
- strawberry/federation/union.py +3 -2
- strawberry/field_extensions/input_mutation.py +1 -2
- strawberry/file_uploads/utils.py +4 -3
- strawberry/flask/views.py +3 -2
- strawberry/http/__init__.py +6 -6
- strawberry/http/async_base_view.py +9 -14
- strawberry/http/base.py +5 -4
- strawberry/http/ides.py +1 -1
- strawberry/http/parse_content_type.py +1 -2
- strawberry/http/sync_base_view.py +3 -5
- strawberry/http/temporal_response.py +1 -2
- strawberry/http/types.py +3 -2
- strawberry/litestar/controller.py +8 -14
- strawberry/parent.py +1 -2
- strawberry/permission.py +6 -8
- strawberry/printer/ast_from_value.py +2 -1
- strawberry/printer/printer.py +50 -30
- strawberry/quart/views.py +3 -3
- strawberry/relay/exceptions.py +4 -4
- strawberry/relay/fields.py +22 -24
- strawberry/relay/types.py +29 -27
- strawberry/relay/utils.py +4 -4
- strawberry/sanic/utils.py +4 -4
- strawberry/sanic/views.py +5 -7
- strawberry/scalars.py +2 -2
- strawberry/schema/base.py +16 -11
- strawberry/schema/compat.py +4 -4
- strawberry/schema/execute.py +6 -10
- strawberry/schema/name_converter.py +3 -3
- strawberry/schema/schema.py +37 -25
- strawberry/schema/schema_converter.py +22 -24
- strawberry/schema/subscribe.py +4 -3
- strawberry/schema/types/base_scalars.py +1 -1
- strawberry/schema/types/concrete_type.py +2 -2
- strawberry/schema/types/scalar.py +3 -4
- strawberry/schema_codegen/__init__.py +4 -4
- strawberry/schema_directive.py +8 -8
- strawberry/subscriptions/protocols/graphql_transport_ws/handlers.py +8 -9
- strawberry/subscriptions/protocols/graphql_transport_ws/types.py +16 -16
- strawberry/subscriptions/protocols/graphql_ws/handlers.py +6 -5
- strawberry/subscriptions/protocols/graphql_ws/types.py +13 -13
- strawberry/test/__init__.py +1 -1
- strawberry/test/client.py +21 -19
- strawberry/tools/create_type.py +4 -3
- strawberry/tools/merge_types.py +1 -2
- strawberry/types/__init__.py +1 -1
- strawberry/types/arguments.py +10 -12
- strawberry/types/auto.py +2 -2
- strawberry/types/base.py +17 -21
- strawberry/types/enum.py +3 -5
- strawberry/types/execution.py +8 -12
- strawberry/types/field.py +26 -31
- strawberry/types/fields/resolver.py +15 -17
- strawberry/types/graphql.py +2 -2
- strawberry/types/info.py +5 -9
- strawberry/types/lazy_type.py +3 -5
- strawberry/types/mutation.py +25 -28
- strawberry/types/nodes.py +11 -9
- strawberry/types/object_type.py +14 -16
- strawberry/types/private.py +1 -2
- strawberry/types/scalar.py +2 -2
- strawberry/types/type_resolver.py +5 -5
- strawberry/types/union.py +8 -11
- strawberry/types/unset.py +3 -3
- strawberry/utils/aio.py +3 -8
- strawberry/utils/await_maybe.py +3 -2
- strawberry/utils/debug.py +2 -2
- strawberry/utils/deprecations.py +2 -2
- strawberry/utils/inspect.py +3 -5
- strawberry/utils/str_converters.py +1 -1
- strawberry/utils/typing.py +38 -67
- {strawberry_graphql-0.255.0.dist-info → strawberry_graphql-0.256.1.dist-info}/METADATA +3 -6
- strawberry_graphql-0.256.1.dist-info/RECORD +236 -0
- strawberry_graphql-0.255.0.dist-info/RECORD +0 -236
- {strawberry_graphql-0.255.0.dist-info → strawberry_graphql-0.256.1.dist-info}/LICENSE +0 -0
- {strawberry_graphql-0.255.0.dist-info → strawberry_graphql-0.256.1.dist-info}/WHEEL +0 -0
- {strawberry_graphql-0.255.0.dist-info → strawberry_graphql-0.256.1.dist-info}/entry_points.txt +0 -0
@@ -30,12 +30,9 @@ from __future__ import annotations
|
|
30
30
|
import re
|
31
31
|
from dataclasses import dataclass
|
32
32
|
from typing import (
|
33
|
+
TYPE_CHECKING,
|
33
34
|
Callable,
|
34
|
-
Dict,
|
35
|
-
Iterable,
|
36
|
-
List,
|
37
35
|
Optional,
|
38
|
-
Type,
|
39
36
|
Union,
|
40
37
|
)
|
41
38
|
|
@@ -61,12 +58,15 @@ from graphql.validation import ValidationContext, ValidationRule
|
|
61
58
|
from strawberry.extensions import AddValidationRules
|
62
59
|
from strawberry.extensions.utils import is_introspection_key
|
63
60
|
|
61
|
+
if TYPE_CHECKING:
|
62
|
+
from collections.abc import Iterable
|
63
|
+
|
64
64
|
IgnoreType = Union[Callable[[str], bool], re.Pattern, str]
|
65
65
|
|
66
66
|
FieldArgumentType = Union[
|
67
|
-
bool, int, float, str,
|
67
|
+
bool, int, float, str, list["FieldArgumentType"], dict[str, "FieldArgumentType"]
|
68
68
|
]
|
69
|
-
FieldArgumentsType =
|
69
|
+
FieldArgumentsType = dict[str, FieldArgumentType]
|
70
70
|
|
71
71
|
|
72
72
|
@dataclass
|
@@ -99,7 +99,7 @@ class QueryDepthLimiter(AddValidationRules):
|
|
99
99
|
def __init__(
|
100
100
|
self,
|
101
101
|
max_depth: int,
|
102
|
-
callback: Optional[Callable[[
|
102
|
+
callback: Optional[Callable[[dict[str, int]], None]] = None,
|
103
103
|
should_ignore: Optional[ShouldIgnoreType] = None,
|
104
104
|
) -> None:
|
105
105
|
"""Initialize the QueryDepthLimiter.
|
@@ -123,8 +123,8 @@ class QueryDepthLimiter(AddValidationRules):
|
|
123
123
|
def create_validator(
|
124
124
|
max_depth: int,
|
125
125
|
should_ignore: Optional[ShouldIgnoreType],
|
126
|
-
callback: Optional[Callable[[
|
127
|
-
) ->
|
126
|
+
callback: Optional[Callable[[dict[str, int]], None]] = None,
|
127
|
+
) -> type[ValidationRule]:
|
128
128
|
class DepthLimitValidator(ValidationRule):
|
129
129
|
def __init__(self, validation_context: ValidationContext) -> None:
|
130
130
|
document = validation_context.document
|
@@ -154,7 +154,7 @@ def create_validator(
|
|
154
154
|
|
155
155
|
def get_fragments(
|
156
156
|
definitions: Iterable[DefinitionNode],
|
157
|
-
) ->
|
157
|
+
) -> dict[str, FragmentDefinitionNode]:
|
158
158
|
fragments = {}
|
159
159
|
for definition in definitions:
|
160
160
|
if isinstance(definition, FragmentDefinitionNode):
|
@@ -167,7 +167,7 @@ def get_fragments(
|
|
167
167
|
# We can basically treat those the same
|
168
168
|
def get_queries_and_mutations(
|
169
169
|
definitions: Iterable[DefinitionNode],
|
170
|
-
) ->
|
170
|
+
) -> dict[str, OperationDefinitionNode]:
|
171
171
|
operations = {}
|
172
172
|
|
173
173
|
for definition in definitions:
|
@@ -214,7 +214,7 @@ def get_field_arguments(
|
|
214
214
|
|
215
215
|
def determine_depth(
|
216
216
|
node: Node,
|
217
|
-
fragments:
|
217
|
+
fragments: dict[str, FragmentDefinitionNode],
|
218
218
|
depth_so_far: int,
|
219
219
|
max_depth: int,
|
220
220
|
context: ValidationContext,
|
@@ -294,7 +294,7 @@ def determine_depth(
|
|
294
294
|
raise TypeError(f"Depth crawler cannot handle: {node.kind}") # pragma: no cover
|
295
295
|
|
296
296
|
|
297
|
-
def is_ignored(node: FieldNode, ignore: Optional[
|
297
|
+
def is_ignored(node: FieldNode, ignore: Optional[list[IgnoreType]] = None) -> bool:
|
298
298
|
if ignore is None:
|
299
299
|
return False
|
300
300
|
|
strawberry/extensions/runner.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
3
|
import inspect
|
4
|
-
from typing import TYPE_CHECKING, Any,
|
4
|
+
from typing import TYPE_CHECKING, Any, Optional
|
5
5
|
|
6
6
|
from strawberry.extensions.context import (
|
7
7
|
ExecutingContextManager,
|
@@ -18,12 +18,12 @@ if TYPE_CHECKING:
|
|
18
18
|
|
19
19
|
|
20
20
|
class SchemaExtensionsRunner:
|
21
|
-
extensions:
|
21
|
+
extensions: list[SchemaExtension]
|
22
22
|
|
23
23
|
def __init__(
|
24
24
|
self,
|
25
25
|
execution_context: ExecutionContext,
|
26
|
-
extensions: Optional[
|
26
|
+
extensions: Optional[list[SchemaExtension]] = None,
|
27
27
|
) -> None:
|
28
28
|
self.execution_context = execution_context
|
29
29
|
self.extensions = extensions or []
|
@@ -40,8 +40,8 @@ class SchemaExtensionsRunner:
|
|
40
40
|
def executing(self) -> ExecutingContextManager:
|
41
41
|
return ExecutingContextManager(self.extensions)
|
42
42
|
|
43
|
-
def get_extensions_results_sync(self) ->
|
44
|
-
data:
|
43
|
+
def get_extensions_results_sync(self) -> dict[str, Any]:
|
44
|
+
data: dict[str, Any] = {}
|
45
45
|
for extension in self.extensions:
|
46
46
|
if inspect.iscoroutinefunction(extension.get_results):
|
47
47
|
msg = "Cannot use async extension hook during sync execution"
|
@@ -50,8 +50,8 @@ class SchemaExtensionsRunner:
|
|
50
50
|
|
51
51
|
return data
|
52
52
|
|
53
|
-
async def get_extensions_results(self, ctx: ExecutionContext) ->
|
54
|
-
data:
|
53
|
+
async def get_extensions_results(self, ctx: ExecutionContext) -> dict[str, Any]:
|
54
|
+
data: dict[str, Any] = {}
|
55
55
|
|
56
56
|
for extension in self.extensions:
|
57
57
|
data.update(await await_maybe(extension.get_results()))
|
@@ -4,7 +4,7 @@ import dataclasses
|
|
4
4
|
import time
|
5
5
|
from datetime import datetime, timezone
|
6
6
|
from inspect import isawaitable
|
7
|
-
from typing import TYPE_CHECKING, Any, Callable,
|
7
|
+
from typing import TYPE_CHECKING, Any, Callable, Optional
|
8
8
|
|
9
9
|
from strawberry.extensions import SchemaExtension
|
10
10
|
from strawberry.extensions.utils import get_path_from_info
|
@@ -12,6 +12,8 @@ from strawberry.extensions.utils import get_path_from_info
|
|
12
12
|
from .utils import should_skip_tracing
|
13
13
|
|
14
14
|
if TYPE_CHECKING:
|
15
|
+
from collections.abc import Generator
|
16
|
+
|
15
17
|
from graphql import GraphQLResolveInfo
|
16
18
|
|
17
19
|
DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%fZ"
|
@@ -25,20 +27,20 @@ class ApolloStepStats:
|
|
25
27
|
start_offset: int
|
26
28
|
duration: int
|
27
29
|
|
28
|
-
def to_json(self) ->
|
30
|
+
def to_json(self) -> dict[str, Any]:
|
29
31
|
return {"startOffset": self.start_offset, "duration": self.duration}
|
30
32
|
|
31
33
|
|
32
34
|
@dataclasses.dataclass
|
33
35
|
class ApolloResolverStats:
|
34
|
-
path:
|
36
|
+
path: list[str]
|
35
37
|
parent_type: Any
|
36
38
|
field_name: str
|
37
39
|
return_type: Any
|
38
40
|
start_offset: int
|
39
41
|
duration: Optional[int] = None
|
40
42
|
|
41
|
-
def to_json(self) ->
|
43
|
+
def to_json(self) -> dict[str, Any]:
|
42
44
|
return {
|
43
45
|
"path": self.path,
|
44
46
|
"field_name": self.field_name,
|
@@ -51,9 +53,9 @@ class ApolloResolverStats:
|
|
51
53
|
|
52
54
|
@dataclasses.dataclass
|
53
55
|
class ApolloExecutionStats:
|
54
|
-
resolvers:
|
56
|
+
resolvers: list[ApolloResolverStats]
|
55
57
|
|
56
|
-
def to_json(self) ->
|
58
|
+
def to_json(self) -> dict[str, Any]:
|
57
59
|
return {"resolvers": [resolver.to_json() for resolver in self.resolvers]}
|
58
60
|
|
59
61
|
|
@@ -67,7 +69,7 @@ class ApolloTracingStats:
|
|
67
69
|
parsing: ApolloStepStats
|
68
70
|
version: int = 1
|
69
71
|
|
70
|
-
def to_json(self) ->
|
72
|
+
def to_json(self) -> dict[str, Any]:
|
71
73
|
return {
|
72
74
|
"version": self.version,
|
73
75
|
"startTime": self.start_time.strftime(DATETIME_FORMAT),
|
@@ -81,7 +83,7 @@ class ApolloTracingStats:
|
|
81
83
|
|
82
84
|
class ApolloTracingExtension(SchemaExtension):
|
83
85
|
def __init__(self, execution_context: ExecutionContext) -> None:
|
84
|
-
self._resolver_stats:
|
86
|
+
self._resolver_stats: list[ApolloResolverStats] = []
|
85
87
|
self.execution_context = execution_context
|
86
88
|
|
87
89
|
def on_operation(self) -> Generator[None, None, None]:
|
@@ -121,7 +123,7 @@ class ApolloTracingExtension(SchemaExtension):
|
|
121
123
|
),
|
122
124
|
)
|
123
125
|
|
124
|
-
def get_results(self) ->
|
126
|
+
def get_results(self) -> dict[str, dict[str, Any]]:
|
125
127
|
return {"tracing": self.stats.to_json()}
|
126
128
|
|
127
129
|
async def resolve(
|
@@ -3,7 +3,7 @@ from __future__ import annotations
|
|
3
3
|
import hashlib
|
4
4
|
from functools import cached_property
|
5
5
|
from inspect import isawaitable
|
6
|
-
from typing import TYPE_CHECKING, Any, Callable,
|
6
|
+
from typing import TYPE_CHECKING, Any, Callable, Optional
|
7
7
|
|
8
8
|
from ddtrace import Span, tracer
|
9
9
|
|
@@ -11,6 +11,8 @@ from strawberry.extensions import LifecycleStep, SchemaExtension
|
|
11
11
|
from strawberry.extensions.tracing.utils import should_skip_tracing
|
12
12
|
|
13
13
|
if TYPE_CHECKING:
|
14
|
+
from collections.abc import Generator, Iterator
|
15
|
+
|
14
16
|
from graphql import GraphQLResolveInfo
|
15
17
|
|
16
18
|
from strawberry.types.execution import ExecutionContext
|
@@ -6,12 +6,7 @@ from typing import (
|
|
6
6
|
TYPE_CHECKING,
|
7
7
|
Any,
|
8
8
|
Callable,
|
9
|
-
Dict,
|
10
|
-
FrozenSet,
|
11
|
-
Generator,
|
12
|
-
Iterable,
|
13
9
|
Optional,
|
14
|
-
Set,
|
15
10
|
Union,
|
16
11
|
)
|
17
12
|
|
@@ -24,6 +19,8 @@ from strawberry.extensions.utils import get_path_from_info
|
|
24
19
|
from .utils import should_skip_tracing
|
25
20
|
|
26
21
|
if TYPE_CHECKING:
|
22
|
+
from collections.abc import Generator, Iterable
|
23
|
+
|
27
24
|
from graphql import GraphQLResolveInfo
|
28
25
|
from opentelemetry.trace import Span, Tracer
|
29
26
|
|
@@ -32,12 +29,12 @@ if TYPE_CHECKING:
|
|
32
29
|
|
33
30
|
DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%fZ"
|
34
31
|
|
35
|
-
ArgFilter = Callable[[
|
32
|
+
ArgFilter = Callable[[dict[str, Any], "GraphQLResolveInfo"], dict[str, Any]]
|
36
33
|
|
37
34
|
|
38
35
|
class OpenTelemetryExtension(SchemaExtension):
|
39
36
|
_arg_filter: Optional[ArgFilter]
|
40
|
-
_span_holder:
|
37
|
+
_span_holder: dict[LifecycleStep, Span]
|
41
38
|
_tracer: Tracer
|
42
39
|
|
43
40
|
def __init__(
|
@@ -100,8 +97,8 @@ class OpenTelemetryExtension(SchemaExtension):
|
|
100
97
|
self._span_holder[LifecycleStep.PARSE].end()
|
101
98
|
|
102
99
|
def filter_resolver_args(
|
103
|
-
self, args:
|
104
|
-
) ->
|
100
|
+
self, args: dict[str, Any], info: GraphQLResolveInfo
|
101
|
+
) -> dict[str, Any]:
|
105
102
|
if not self._arg_filter:
|
106
103
|
return args
|
107
104
|
return self._arg_filter(deepcopy(args), info)
|
@@ -132,7 +129,7 @@ class OpenTelemetryExtension(SchemaExtension):
|
|
132
129
|
else:
|
133
130
|
return str(value)
|
134
131
|
|
135
|
-
def convert_set_to_allowed_types(self, value: Union[
|
132
|
+
def convert_set_to_allowed_types(self, value: Union[set, frozenset]) -> str:
|
136
133
|
return (
|
137
134
|
"{" + ", ".join(str(self.convert_to_allowed_types(x)) for x in value) + "}"
|
138
135
|
)
|
strawberry/extensions/utils.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
|
-
from typing import TYPE_CHECKING,
|
3
|
+
from typing import TYPE_CHECKING, Union
|
4
4
|
|
5
5
|
if TYPE_CHECKING:
|
6
6
|
from graphql import GraphQLResolveInfo
|
@@ -26,7 +26,7 @@ def is_introspection_field(info: GraphQLResolveInfo) -> bool:
|
|
26
26
|
return False
|
27
27
|
|
28
28
|
|
29
|
-
def get_path_from_info(info: GraphQLResolveInfo) ->
|
29
|
+
def get_path_from_info(info: GraphQLResolveInfo) -> list[str]:
|
30
30
|
path = info.path
|
31
31
|
elements = []
|
32
32
|
|
@@ -37,4 +37,4 @@ def get_path_from_info(info: GraphQLResolveInfo) -> List[str]:
|
|
37
37
|
return elements[::-1]
|
38
38
|
|
39
39
|
|
40
|
-
__all__ = ["
|
40
|
+
__all__ = ["get_path_from_info", "is_introspection_field", "is_introspection_key"]
|
strawberry/fastapi/context.py
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
from typing import Any,
|
1
|
+
from typing import Any, Optional, Union
|
2
2
|
|
3
3
|
from starlette.background import BackgroundTasks
|
4
4
|
from starlette.requests import Request
|
5
5
|
from starlette.responses import Response
|
6
6
|
from starlette.websockets import WebSocket
|
7
7
|
|
8
|
-
CustomContext = Union["BaseContext",
|
8
|
+
CustomContext = Union["BaseContext", dict[str, Any]]
|
9
9
|
MergedContext = Union[
|
10
|
-
"BaseContext",
|
10
|
+
"BaseContext", dict[str, Union[Any, BackgroundTasks, Request, Response, WebSocket]]
|
11
11
|
]
|
12
12
|
|
13
13
|
|
strawberry/fastapi/router.py
CHANGED
@@ -6,21 +6,15 @@ from inspect import signature
|
|
6
6
|
from typing import (
|
7
7
|
TYPE_CHECKING,
|
8
8
|
Any,
|
9
|
-
AsyncIterator,
|
10
|
-
Awaitable,
|
11
9
|
Callable,
|
12
|
-
Dict,
|
13
|
-
List,
|
14
10
|
Optional,
|
15
|
-
Sequence,
|
16
|
-
Type,
|
17
11
|
Union,
|
18
12
|
cast,
|
19
13
|
)
|
20
14
|
from typing_extensions import TypeGuard
|
21
15
|
|
22
16
|
from starlette import status
|
23
|
-
from starlette.background import BackgroundTasks # noqa:
|
17
|
+
from starlette.background import BackgroundTasks # noqa: TC002
|
24
18
|
from starlette.requests import HTTPConnection, Request
|
25
19
|
from starlette.responses import (
|
26
20
|
HTMLResponse,
|
@@ -44,6 +38,7 @@ from strawberry.http.typevars import Context, RootValue
|
|
44
38
|
from strawberry.subscriptions import GRAPHQL_TRANSPORT_WS_PROTOCOL, GRAPHQL_WS_PROTOCOL
|
45
39
|
|
46
40
|
if TYPE_CHECKING:
|
41
|
+
from collections.abc import AsyncIterator, Awaitable, Sequence
|
47
42
|
from enum import Enum
|
48
43
|
|
49
44
|
from starlette.routing import BaseRoute
|
@@ -138,16 +133,16 @@ class GraphQLRouter(
|
|
138
133
|
),
|
139
134
|
connection_init_wait_timeout: timedelta = timedelta(minutes=1),
|
140
135
|
prefix: str = "",
|
141
|
-
tags: Optional[
|
136
|
+
tags: Optional[list[Union[str, Enum]]] = None,
|
142
137
|
dependencies: Optional[Sequence[params.Depends]] = None,
|
143
|
-
default_response_class:
|
144
|
-
responses: Optional[
|
145
|
-
callbacks: Optional[
|
146
|
-
routes: Optional[
|
138
|
+
default_response_class: type[Response] = Default(JSONResponse),
|
139
|
+
responses: Optional[dict[Union[int, str], dict[str, Any]]] = None,
|
140
|
+
callbacks: Optional[list[BaseRoute]] = None,
|
141
|
+
routes: Optional[list[BaseRoute]] = None,
|
147
142
|
redirect_slashes: bool = True,
|
148
143
|
default: Optional[ASGIApp] = None,
|
149
144
|
dependency_overrides_provider: Optional[Any] = None,
|
150
|
-
route_class:
|
145
|
+
route_class: type[APIRoute] = APIRoute,
|
151
146
|
on_startup: Optional[Sequence[Callable[[], Any]]] = None,
|
152
147
|
on_shutdown: Optional[Sequence[Callable[[], Any]]] = None,
|
153
148
|
lifespan: Optional[Lifespan[Any]] = None,
|
@@ -297,7 +292,7 @@ class GraphQLRouter(
|
|
297
292
|
request: Request,
|
298
293
|
stream: Callable[[], AsyncIterator[str]],
|
299
294
|
sub_response: Response,
|
300
|
-
headers:
|
295
|
+
headers: dict[str, str],
|
301
296
|
) -> Response:
|
302
297
|
return StreamingResponse(
|
303
298
|
stream(),
|
@@ -2,24 +2,24 @@ from .argument import argument
|
|
2
2
|
from .enum import enum, enum_value
|
3
3
|
from .field import field
|
4
4
|
from .mutation import mutation
|
5
|
-
from .object_type import input, interface, interface_object, type
|
5
|
+
from .object_type import input, interface, interface_object, type # noqa: A004
|
6
6
|
from .scalar import scalar
|
7
7
|
from .schema import Schema
|
8
8
|
from .schema_directive import schema_directive
|
9
9
|
from .union import union
|
10
10
|
|
11
11
|
__all__ = [
|
12
|
+
"Schema",
|
12
13
|
"argument",
|
13
14
|
"enum",
|
14
15
|
"enum_value",
|
15
16
|
"field",
|
16
|
-
"mutation",
|
17
17
|
"input",
|
18
18
|
"interface",
|
19
19
|
"interface_object",
|
20
|
-
"
|
20
|
+
"mutation",
|
21
21
|
"scalar",
|
22
|
-
"Schema",
|
23
22
|
"schema_directive",
|
23
|
+
"type",
|
24
24
|
"union",
|
25
25
|
]
|
strawberry/federation/enum.py
CHANGED
@@ -4,8 +4,6 @@ from typing import (
|
|
4
4
|
TYPE_CHECKING,
|
5
5
|
Any,
|
6
6
|
Callable,
|
7
|
-
Iterable,
|
8
|
-
List,
|
9
7
|
Optional,
|
10
8
|
Union,
|
11
9
|
overload,
|
@@ -15,6 +13,8 @@ from strawberry.types.enum import _process_enum
|
|
15
13
|
from strawberry.types.enum import enum_value as base_enum_value
|
16
14
|
|
17
15
|
if TYPE_CHECKING:
|
16
|
+
from collections.abc import Iterable
|
17
|
+
|
18
18
|
from strawberry.enum import EnumType, EnumValueDefinition
|
19
19
|
|
20
20
|
|
@@ -47,8 +47,8 @@ def enum(
|
|
47
47
|
directives: Iterable[object] = (),
|
48
48
|
authenticated: bool = False,
|
49
49
|
inaccessible: bool = False,
|
50
|
-
policy: Optional[
|
51
|
-
requires_scopes: Optional[
|
50
|
+
policy: Optional[list[list[str]]] = None,
|
51
|
+
requires_scopes: Optional[list[list[str]]] = None,
|
52
52
|
tags: Optional[Iterable[str]] = (),
|
53
53
|
) -> EnumType: ...
|
54
54
|
|
@@ -62,8 +62,8 @@ def enum(
|
|
62
62
|
directives: Iterable[object] = (),
|
63
63
|
authenticated: bool = False,
|
64
64
|
inaccessible: bool = False,
|
65
|
-
policy: Optional[
|
66
|
-
requires_scopes: Optional[
|
65
|
+
policy: Optional[list[list[str]]] = None,
|
66
|
+
requires_scopes: Optional[list[list[str]]] = None,
|
67
67
|
tags: Optional[Iterable[str]] = (),
|
68
68
|
) -> Callable[[EnumType], EnumType]: ...
|
69
69
|
|
@@ -76,8 +76,8 @@ def enum(
|
|
76
76
|
directives=(),
|
77
77
|
authenticated: bool = False,
|
78
78
|
inaccessible: bool = False,
|
79
|
-
policy: Optional[
|
80
|
-
requires_scopes: Optional[
|
79
|
+
policy: Optional[list[list[str]]] = None,
|
80
|
+
requires_scopes: Optional[list[list[str]]] = None,
|
81
81
|
tags: Optional[Iterable[str]] = (),
|
82
82
|
) -> Union[EnumType, Callable[[EnumType], EnumType]]:
|
83
83
|
"""Registers the enum in the GraphQL type system.
|
strawberry/federation/field.py
CHANGED
@@ -5,11 +5,7 @@ from typing import (
|
|
5
5
|
TYPE_CHECKING,
|
6
6
|
Any,
|
7
7
|
Callable,
|
8
|
-
Iterable,
|
9
|
-
List,
|
10
8
|
Optional,
|
11
|
-
Sequence,
|
12
|
-
Type,
|
13
9
|
TypeVar,
|
14
10
|
Union,
|
15
11
|
overload,
|
@@ -19,6 +15,7 @@ from strawberry.types.field import field as base_field
|
|
19
15
|
from strawberry.types.unset import UNSET
|
20
16
|
|
21
17
|
if TYPE_CHECKING:
|
18
|
+
from collections.abc import Iterable, Sequence
|
22
19
|
from typing_extensions import Literal
|
23
20
|
|
24
21
|
from strawberry.extensions.field_extension import FieldExtension
|
@@ -40,20 +37,20 @@ def field(
|
|
40
37
|
authenticated: bool = False,
|
41
38
|
external: bool = False,
|
42
39
|
inaccessible: bool = False,
|
43
|
-
policy: Optional[
|
44
|
-
provides: Optional[
|
40
|
+
policy: Optional[list[list[str]]] = None,
|
41
|
+
provides: Optional[list[str]] = None,
|
45
42
|
override: Optional[Union[Override, str]] = None,
|
46
|
-
requires: Optional[
|
47
|
-
requires_scopes: Optional[
|
43
|
+
requires: Optional[list[str]] = None,
|
44
|
+
requires_scopes: Optional[list[list[str]]] = None,
|
48
45
|
tags: Optional[Iterable[str]] = (),
|
49
46
|
shareable: bool = False,
|
50
47
|
init: Literal[False] = False,
|
51
|
-
permission_classes: Optional[
|
48
|
+
permission_classes: Optional[list[type[BasePermission]]] = None,
|
52
49
|
deprecation_reason: Optional[str] = None,
|
53
50
|
default: Any = UNSET,
|
54
51
|
default_factory: Union[Callable[..., object], object] = UNSET,
|
55
52
|
directives: Sequence[object] = (),
|
56
|
-
extensions: Optional[
|
53
|
+
extensions: Optional[list[FieldExtension]] = None,
|
57
54
|
graphql_type: Optional[Any] = None,
|
58
55
|
) -> T: ...
|
59
56
|
|
@@ -67,20 +64,20 @@ def field(
|
|
67
64
|
authenticated: bool = False,
|
68
65
|
external: bool = False,
|
69
66
|
inaccessible: bool = False,
|
70
|
-
policy: Optional[
|
71
|
-
provides: Optional[
|
67
|
+
policy: Optional[list[list[str]]] = None,
|
68
|
+
provides: Optional[list[str]] = None,
|
72
69
|
override: Optional[Union[Override, str]] = None,
|
73
|
-
requires: Optional[
|
74
|
-
requires_scopes: Optional[
|
70
|
+
requires: Optional[list[str]] = None,
|
71
|
+
requires_scopes: Optional[list[list[str]]] = None,
|
75
72
|
tags: Optional[Iterable[str]] = (),
|
76
73
|
shareable: bool = False,
|
77
74
|
init: Literal[True] = True,
|
78
|
-
permission_classes: Optional[
|
75
|
+
permission_classes: Optional[list[type[BasePermission]]] = None,
|
79
76
|
deprecation_reason: Optional[str] = None,
|
80
77
|
default: Any = UNSET,
|
81
78
|
default_factory: Union[Callable[..., object], object] = UNSET,
|
82
79
|
directives: Sequence[object] = (),
|
83
|
-
extensions: Optional[
|
80
|
+
extensions: Optional[list[FieldExtension]] = None,
|
84
81
|
graphql_type: Optional[Any] = None,
|
85
82
|
) -> Any: ...
|
86
83
|
|
@@ -95,19 +92,19 @@ def field(
|
|
95
92
|
authenticated: bool = False,
|
96
93
|
external: bool = False,
|
97
94
|
inaccessible: bool = False,
|
98
|
-
policy: Optional[
|
99
|
-
provides: Optional[
|
95
|
+
policy: Optional[list[list[str]]] = None,
|
96
|
+
provides: Optional[list[str]] = None,
|
100
97
|
override: Optional[Union[Override, str]] = None,
|
101
|
-
requires: Optional[
|
102
|
-
requires_scopes: Optional[
|
98
|
+
requires: Optional[list[str]] = None,
|
99
|
+
requires_scopes: Optional[list[list[str]]] = None,
|
103
100
|
tags: Optional[Iterable[str]] = (),
|
104
101
|
shareable: bool = False,
|
105
|
-
permission_classes: Optional[
|
102
|
+
permission_classes: Optional[list[type[BasePermission]]] = None,
|
106
103
|
deprecation_reason: Optional[str] = None,
|
107
104
|
default: Any = UNSET,
|
108
105
|
default_factory: Union[Callable[..., object], object] = UNSET,
|
109
106
|
directives: Sequence[object] = (),
|
110
|
-
extensions: Optional[
|
107
|
+
extensions: Optional[list[FieldExtension]] = None,
|
111
108
|
graphql_type: Optional[Any] = None,
|
112
109
|
) -> StrawberryField: ...
|
113
110
|
|
@@ -121,19 +118,19 @@ def field(
|
|
121
118
|
authenticated: bool = False,
|
122
119
|
external: bool = False,
|
123
120
|
inaccessible: bool = False,
|
124
|
-
policy: Optional[
|
125
|
-
provides: Optional[
|
121
|
+
policy: Optional[list[list[str]]] = None,
|
122
|
+
provides: Optional[list[str]] = None,
|
126
123
|
override: Optional[Union[Override, str]] = None,
|
127
|
-
requires: Optional[
|
128
|
-
requires_scopes: Optional[
|
124
|
+
requires: Optional[list[str]] = None,
|
125
|
+
requires_scopes: Optional[list[list[str]]] = None,
|
129
126
|
tags: Optional[Iterable[str]] = (),
|
130
127
|
shareable: bool = False,
|
131
|
-
permission_classes: Optional[
|
128
|
+
permission_classes: Optional[list[type[BasePermission]]] = None,
|
132
129
|
deprecation_reason: Optional[str] = None,
|
133
130
|
default: Any = dataclasses.MISSING,
|
134
131
|
default_factory: Union[Callable[..., object], object] = dataclasses.MISSING,
|
135
132
|
directives: Sequence[object] = (),
|
136
|
-
extensions: Optional[
|
133
|
+
extensions: Optional[list[FieldExtension]] = None,
|
137
134
|
graphql_type: Optional[Any] = None,
|
138
135
|
# This init parameter is used by PyRight to determine whether this field
|
139
136
|
# is added in the constructor or not. It is not used to change
|