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
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from typing import TYPE_CHECKING, Any
|
|
3
|
+
from typing import TYPE_CHECKING, Any
|
|
4
4
|
|
|
5
5
|
from strawberry.extensions.utils import is_introspection_field
|
|
6
6
|
from strawberry.resolvers import is_default_resolver
|
|
7
7
|
|
|
8
8
|
if TYPE_CHECKING:
|
|
9
|
+
from collections.abc import Callable
|
|
10
|
+
|
|
9
11
|
from graphql import GraphQLResolveInfo
|
|
10
12
|
|
|
11
13
|
|
strawberry/extensions/utils.py
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from typing import TYPE_CHECKING
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
4
|
|
|
5
5
|
if TYPE_CHECKING:
|
|
6
6
|
from graphql import GraphQLResolveInfo
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
def is_introspection_key(key:
|
|
9
|
+
def is_introspection_key(key: str | int) -> bool:
|
|
10
10
|
# from: https://spec.graphql.org/June2018/#sec-Schema
|
|
11
11
|
# > All types and directives defined within a schema must not have a name which
|
|
12
12
|
# > begins with "__" (two underscores), as this is used exclusively
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
from collections.abc import Iterator
|
|
2
2
|
from functools import lru_cache
|
|
3
|
-
from typing import Optional
|
|
4
3
|
|
|
5
4
|
from strawberry.extensions.base_extension import SchemaExtension
|
|
6
5
|
|
|
@@ -22,7 +21,7 @@ class ValidationCache(SchemaExtension):
|
|
|
22
21
|
```
|
|
23
22
|
"""
|
|
24
23
|
|
|
25
|
-
def __init__(self, maxsize:
|
|
24
|
+
def __init__(self, maxsize: int | None = None) -> None:
|
|
26
25
|
"""Initialize the ValidationCache.
|
|
27
26
|
|
|
28
27
|
Args:
|
|
@@ -43,7 +42,7 @@ class ValidationCache(SchemaExtension):
|
|
|
43
42
|
execution_context.graphql_document,
|
|
44
43
|
execution_context.validation_rules,
|
|
45
44
|
)
|
|
46
|
-
execution_context.
|
|
45
|
+
execution_context.pre_execution_errors = errors
|
|
47
46
|
yield
|
|
48
47
|
|
|
49
48
|
|
strawberry/fastapi/context.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Any,
|
|
1
|
+
from typing import Any, Union
|
|
2
2
|
|
|
3
3
|
from starlette.background import BackgroundTasks
|
|
4
4
|
from starlette.requests import Request
|
|
@@ -7,17 +7,17 @@ from starlette.websockets import WebSocket
|
|
|
7
7
|
|
|
8
8
|
CustomContext = Union["BaseContext", dict[str, Any]]
|
|
9
9
|
MergedContext = Union[
|
|
10
|
-
"BaseContext", dict[str,
|
|
10
|
+
"BaseContext", dict[str, Any | BackgroundTasks | Request | Response | WebSocket]
|
|
11
11
|
]
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
class BaseContext:
|
|
15
|
-
connection_params:
|
|
15
|
+
connection_params: Any | None = None
|
|
16
16
|
|
|
17
17
|
def __init__(self) -> None:
|
|
18
|
-
self.request:
|
|
19
|
-
self.background_tasks:
|
|
20
|
-
self.response:
|
|
18
|
+
self.request: Request | WebSocket | None = None
|
|
19
|
+
self.background_tasks: BackgroundTasks | None = None
|
|
20
|
+
self.response: Response | None = None
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
__all__ = ["BaseContext"]
|
strawberry/fastapi/router.py
CHANGED
|
@@ -6,13 +6,15 @@ from inspect import signature
|
|
|
6
6
|
from typing import (
|
|
7
7
|
TYPE_CHECKING,
|
|
8
8
|
Any,
|
|
9
|
-
|
|
10
|
-
Optional,
|
|
11
|
-
Union,
|
|
9
|
+
TypeGuard,
|
|
12
10
|
cast,
|
|
13
11
|
)
|
|
14
|
-
from typing_extensions import TypeGuard
|
|
15
12
|
|
|
13
|
+
from fastapi import APIRouter, Depends, params
|
|
14
|
+
from fastapi.datastructures import Default
|
|
15
|
+
from fastapi.routing import APIRoute
|
|
16
|
+
from fastapi.utils import generate_unique_id
|
|
17
|
+
from lia import HTTPException, StarletteRequestAdapter
|
|
16
18
|
from starlette import status
|
|
17
19
|
from starlette.background import BackgroundTasks # noqa: TC002
|
|
18
20
|
from starlette.requests import HTTPConnection, Request
|
|
@@ -25,20 +27,20 @@ from starlette.responses import (
|
|
|
25
27
|
)
|
|
26
28
|
from starlette.websockets import WebSocket
|
|
27
29
|
|
|
28
|
-
from
|
|
29
|
-
from fastapi.datastructures import Default
|
|
30
|
-
from fastapi.routing import APIRoute
|
|
31
|
-
from fastapi.utils import generate_unique_id
|
|
32
|
-
from strawberry.asgi import ASGIRequestAdapter, ASGIWebSocketAdapter
|
|
30
|
+
from strawberry.asgi import ASGIWebSocketAdapter
|
|
33
31
|
from strawberry.exceptions import InvalidCustomContext
|
|
34
32
|
from strawberry.fastapi.context import BaseContext, CustomContext
|
|
35
33
|
from strawberry.http.async_base_view import AsyncBaseHTTPView
|
|
36
|
-
from strawberry.http.exceptions import HTTPException
|
|
37
34
|
from strawberry.http.typevars import Context, RootValue
|
|
38
35
|
from strawberry.subscriptions import GRAPHQL_TRANSPORT_WS_PROTOCOL, GRAPHQL_WS_PROTOCOL
|
|
39
36
|
|
|
40
37
|
if TYPE_CHECKING:
|
|
41
|
-
from collections.abc import
|
|
38
|
+
from collections.abc import (
|
|
39
|
+
AsyncIterator,
|
|
40
|
+
Awaitable,
|
|
41
|
+
Callable,
|
|
42
|
+
Sequence,
|
|
43
|
+
)
|
|
42
44
|
from enum import Enum
|
|
43
45
|
|
|
44
46
|
from starlette.routing import BaseRoute
|
|
@@ -57,8 +59,8 @@ class GraphQLRouter(
|
|
|
57
59
|
APIRouter,
|
|
58
60
|
):
|
|
59
61
|
allow_queries_via_get = True
|
|
60
|
-
request_adapter_class =
|
|
61
|
-
websocket_adapter_class = ASGIWebSocketAdapter
|
|
62
|
+
request_adapter_class = StarletteRequestAdapter
|
|
63
|
+
websocket_adapter_class = ASGIWebSocketAdapter # type: ignore
|
|
62
64
|
|
|
63
65
|
@staticmethod
|
|
64
66
|
async def __get_root_value() -> None:
|
|
@@ -67,16 +69,16 @@ class GraphQLRouter(
|
|
|
67
69
|
@staticmethod
|
|
68
70
|
def __get_context_getter(
|
|
69
71
|
custom_getter: Callable[
|
|
70
|
-
...,
|
|
72
|
+
..., CustomContext | None | Awaitable[CustomContext | None]
|
|
71
73
|
],
|
|
72
74
|
) -> Callable[..., Awaitable[CustomContext]]:
|
|
73
75
|
async def dependency(
|
|
74
|
-
custom_context:
|
|
76
|
+
custom_context: CustomContext | None,
|
|
75
77
|
background_tasks: BackgroundTasks,
|
|
76
78
|
connection: HTTPConnection,
|
|
77
79
|
response: Response = None, # type: ignore
|
|
78
80
|
) -> MergedContext:
|
|
79
|
-
request = cast("
|
|
81
|
+
request = cast("Request | WebSocket", connection)
|
|
80
82
|
if isinstance(custom_context, BaseContext):
|
|
81
83
|
custom_context.request = request
|
|
82
84
|
custom_context.background_tasks = background_tasks
|
|
@@ -118,36 +120,34 @@ class GraphQLRouter(
|
|
|
118
120
|
self,
|
|
119
121
|
schema: BaseSchema,
|
|
120
122
|
path: str = "",
|
|
121
|
-
graphiql:
|
|
122
|
-
graphql_ide:
|
|
123
|
+
graphiql: bool | None = None,
|
|
124
|
+
graphql_ide: GraphQL_IDE | None = "graphiql",
|
|
123
125
|
allow_queries_via_get: bool = True,
|
|
124
126
|
keep_alive: bool = False,
|
|
125
127
|
keep_alive_interval: float = 1,
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
Callable[..., Union[Optional[Context], Awaitable[Optional[Context]]]]
|
|
130
|
-
] = None,
|
|
128
|
+
root_value_getter: Callable[[], RootValue] | None = None,
|
|
129
|
+
context_getter: Callable[..., Context | None | Awaitable[Context | None]]
|
|
130
|
+
| None = None,
|
|
131
131
|
subscription_protocols: Sequence[str] = (
|
|
132
132
|
GRAPHQL_TRANSPORT_WS_PROTOCOL,
|
|
133
133
|
GRAPHQL_WS_PROTOCOL,
|
|
134
134
|
),
|
|
135
135
|
connection_init_wait_timeout: timedelta = timedelta(minutes=1),
|
|
136
136
|
prefix: str = "",
|
|
137
|
-
tags:
|
|
138
|
-
dependencies:
|
|
137
|
+
tags: list[str | Enum] | None = None,
|
|
138
|
+
dependencies: Sequence[params.Depends] | None = None,
|
|
139
139
|
default_response_class: type[Response] = Default(JSONResponse),
|
|
140
|
-
responses:
|
|
141
|
-
callbacks:
|
|
142
|
-
routes:
|
|
140
|
+
responses: dict[int | str, dict[str, Any]] | None = None,
|
|
141
|
+
callbacks: list[BaseRoute] | None = None,
|
|
142
|
+
routes: list[BaseRoute] | None = None,
|
|
143
143
|
redirect_slashes: bool = True,
|
|
144
|
-
default:
|
|
145
|
-
dependency_overrides_provider:
|
|
144
|
+
default: ASGIApp | None = None,
|
|
145
|
+
dependency_overrides_provider: Any | None = None,
|
|
146
146
|
route_class: type[APIRoute] = APIRoute,
|
|
147
|
-
on_startup:
|
|
148
|
-
on_shutdown:
|
|
149
|
-
lifespan:
|
|
150
|
-
deprecated:
|
|
147
|
+
on_startup: Sequence[Callable[[], Any]] | None = None,
|
|
148
|
+
on_shutdown: Sequence[Callable[[], Any]] | None = None,
|
|
149
|
+
lifespan: Lifespan[Any] | None = None,
|
|
150
|
+
deprecated: bool | None = None,
|
|
151
151
|
include_in_schema: bool = True,
|
|
152
152
|
generate_unique_id_function: Callable[[APIRoute], str] = Default(
|
|
153
153
|
generate_unique_id
|
|
@@ -179,7 +179,6 @@ class GraphQLRouter(
|
|
|
179
179
|
self.allow_queries_via_get = allow_queries_via_get
|
|
180
180
|
self.keep_alive = keep_alive
|
|
181
181
|
self.keep_alive_interval = keep_alive_interval
|
|
182
|
-
self.debug = debug
|
|
183
182
|
self.root_value_getter = root_value_getter or self.__get_root_value
|
|
184
183
|
# TODO: clean this type up
|
|
185
184
|
self.context_getter = self.__get_context_getter(
|
|
@@ -263,20 +262,22 @@ class GraphQLRouter(
|
|
|
263
262
|
return HTMLResponse(self.graphql_ide_html)
|
|
264
263
|
|
|
265
264
|
async def get_context(
|
|
266
|
-
self, request:
|
|
265
|
+
self, request: Request | WebSocket, response: Response | WebSocket
|
|
267
266
|
) -> Context: # pragma: no cover
|
|
268
267
|
raise ValueError("`get_context` is not used by FastAPI GraphQL Router")
|
|
269
268
|
|
|
270
269
|
async def get_root_value(
|
|
271
|
-
self, request:
|
|
272
|
-
) ->
|
|
270
|
+
self, request: Request | WebSocket
|
|
271
|
+
) -> RootValue | None: # pragma: no cover
|
|
273
272
|
raise ValueError("`get_root_value` is not used by FastAPI GraphQL Router")
|
|
274
273
|
|
|
275
274
|
async def get_sub_response(self, request: Request) -> Response:
|
|
276
275
|
return self.temporal_response
|
|
277
276
|
|
|
278
277
|
def create_response(
|
|
279
|
-
self,
|
|
278
|
+
self,
|
|
279
|
+
response_data: GraphQLHTTPResponse | list[GraphQLHTTPResponse],
|
|
280
|
+
sub_response: Response,
|
|
280
281
|
) -> Response:
|
|
281
282
|
response = Response(
|
|
282
283
|
self.encode_json(response_data),
|
|
@@ -305,18 +306,18 @@ class GraphQLRouter(
|
|
|
305
306
|
)
|
|
306
307
|
|
|
307
308
|
def is_websocket_request(
|
|
308
|
-
self, request:
|
|
309
|
+
self, request: Request | WebSocket
|
|
309
310
|
) -> TypeGuard[WebSocket]:
|
|
310
311
|
return request.scope["type"] == "websocket"
|
|
311
312
|
|
|
312
|
-
async def pick_websocket_subprotocol(self, request: WebSocket) ->
|
|
313
|
+
async def pick_websocket_subprotocol(self, request: WebSocket) -> str | None:
|
|
313
314
|
protocols = request["subprotocols"]
|
|
314
315
|
intersection = set(protocols) & set(self.protocols)
|
|
315
316
|
sorted_intersection = sorted(intersection, key=protocols.index)
|
|
316
317
|
return next(iter(sorted_intersection), None)
|
|
317
318
|
|
|
318
319
|
async def create_websocket_response(
|
|
319
|
-
self, request: WebSocket, subprotocol:
|
|
320
|
+
self, request: WebSocket, subprotocol: str | None
|
|
320
321
|
) -> WebSocket:
|
|
321
322
|
await request.accept(subprotocol=subprotocol)
|
|
322
323
|
return request
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
from collections.abc import Iterable
|
|
2
|
-
from typing import Optional
|
|
3
2
|
|
|
4
3
|
from strawberry.types.arguments import StrawberryArgumentAnnotation
|
|
5
4
|
|
|
6
5
|
|
|
7
6
|
def argument(
|
|
8
|
-
description:
|
|
9
|
-
name:
|
|
10
|
-
deprecation_reason:
|
|
7
|
+
description: str | None = None,
|
|
8
|
+
name: str | None = None,
|
|
9
|
+
deprecation_reason: str | None = None,
|
|
11
10
|
directives: Iterable[object] = (),
|
|
12
11
|
inaccessible: bool = False,
|
|
13
|
-
tags:
|
|
12
|
+
tags: Iterable[str] | None = (),
|
|
14
13
|
) -> StrawberryArgumentAnnotation:
|
|
15
14
|
from strawberry.federation.schema_directives import Inaccessible, Tag
|
|
16
15
|
|
strawberry/federation/enum.py
CHANGED
|
@@ -3,9 +3,6 @@ from __future__ import annotations
|
|
|
3
3
|
from typing import (
|
|
4
4
|
TYPE_CHECKING,
|
|
5
5
|
Any,
|
|
6
|
-
Callable,
|
|
7
|
-
Optional,
|
|
8
|
-
Union,
|
|
9
6
|
overload,
|
|
10
7
|
)
|
|
11
8
|
|
|
@@ -13,15 +10,15 @@ from strawberry.types.enum import _process_enum
|
|
|
13
10
|
from strawberry.types.enum import enum_value as base_enum_value
|
|
14
11
|
|
|
15
12
|
if TYPE_CHECKING:
|
|
16
|
-
from collections.abc import Iterable
|
|
13
|
+
from collections.abc import Callable, Iterable
|
|
17
14
|
|
|
18
15
|
from strawberry.enum import EnumType, EnumValueDefinition
|
|
19
16
|
|
|
20
17
|
|
|
21
18
|
def enum_value(
|
|
22
19
|
value: Any,
|
|
23
|
-
name:
|
|
24
|
-
deprecation_reason:
|
|
20
|
+
name: str | None = None,
|
|
21
|
+
deprecation_reason: str | None = None,
|
|
25
22
|
directives: Iterable[object] = (),
|
|
26
23
|
inaccessible: bool = False,
|
|
27
24
|
tags: Iterable[str] = (),
|
|
@@ -48,14 +45,14 @@ def enum_value(
|
|
|
48
45
|
def enum(
|
|
49
46
|
_cls: EnumType,
|
|
50
47
|
*,
|
|
51
|
-
name:
|
|
52
|
-
description:
|
|
48
|
+
name: str | None = None,
|
|
49
|
+
description: str | None = None,
|
|
53
50
|
directives: Iterable[object] = (),
|
|
54
51
|
authenticated: bool = False,
|
|
55
52
|
inaccessible: bool = False,
|
|
56
|
-
policy:
|
|
57
|
-
requires_scopes:
|
|
58
|
-
tags:
|
|
53
|
+
policy: list[list[str]] | None = None,
|
|
54
|
+
requires_scopes: list[list[str]] | None = None,
|
|
55
|
+
tags: Iterable[str] | None = (),
|
|
59
56
|
) -> EnumType: ...
|
|
60
57
|
|
|
61
58
|
|
|
@@ -63,29 +60,29 @@ def enum(
|
|
|
63
60
|
def enum(
|
|
64
61
|
_cls: None = None,
|
|
65
62
|
*,
|
|
66
|
-
name:
|
|
67
|
-
description:
|
|
63
|
+
name: str | None = None,
|
|
64
|
+
description: str | None = None,
|
|
68
65
|
directives: Iterable[object] = (),
|
|
69
66
|
authenticated: bool = False,
|
|
70
67
|
inaccessible: bool = False,
|
|
71
|
-
policy:
|
|
72
|
-
requires_scopes:
|
|
73
|
-
tags:
|
|
68
|
+
policy: list[list[str]] | None = None,
|
|
69
|
+
requires_scopes: list[list[str]] | None = None,
|
|
70
|
+
tags: Iterable[str] | None = (),
|
|
74
71
|
) -> Callable[[EnumType], EnumType]: ...
|
|
75
72
|
|
|
76
73
|
|
|
77
74
|
def enum(
|
|
78
|
-
_cls:
|
|
75
|
+
_cls: EnumType | None = None,
|
|
79
76
|
*,
|
|
80
77
|
name=None,
|
|
81
78
|
description=None,
|
|
82
79
|
directives=(),
|
|
83
80
|
authenticated: bool = False,
|
|
84
81
|
inaccessible: bool = False,
|
|
85
|
-
policy:
|
|
86
|
-
requires_scopes:
|
|
87
|
-
tags:
|
|
88
|
-
) ->
|
|
82
|
+
policy: list[list[str]] | None = None,
|
|
83
|
+
requires_scopes: list[list[str]] | None = None,
|
|
84
|
+
tags: Iterable[str] | None = (),
|
|
85
|
+
) -> EnumType | Callable[[EnumType], EnumType]:
|
|
89
86
|
"""Registers the enum in the GraphQL type system.
|
|
90
87
|
|
|
91
88
|
If name is passed, the name of the GraphQL type will be
|