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.

Files changed (161) hide show
  1. strawberry/__init__.py +2 -0
  2. strawberry/aiohttp/test/client.py +8 -15
  3. strawberry/aiohttp/views.py +15 -64
  4. strawberry/annotation.py +70 -25
  5. strawberry/asgi/__init__.py +22 -56
  6. strawberry/asgi/test/client.py +6 -6
  7. strawberry/chalice/views.py +13 -79
  8. strawberry/channels/handlers/base.py +7 -8
  9. strawberry/channels/handlers/http_handler.py +50 -32
  10. strawberry/channels/handlers/ws_handler.py +12 -14
  11. strawberry/channels/router.py +3 -4
  12. strawberry/channels/testing.py +7 -9
  13. strawberry/cli/__init__.py +7 -6
  14. strawberry/cli/commands/codegen.py +7 -7
  15. strawberry/cli/commands/dev.py +72 -0
  16. strawberry/cli/commands/schema_codegen.py +1 -2
  17. strawberry/cli/commands/server.py +3 -44
  18. strawberry/cli/commands/upgrade/__init__.py +3 -3
  19. strawberry/cli/commands/upgrade/_run_codemod.py +2 -2
  20. strawberry/cli/constants.py +1 -2
  21. strawberry/cli/{debug_server.py → dev_server.py} +3 -7
  22. strawberry/codegen/plugins/print_operation.py +2 -2
  23. strawberry/codegen/plugins/python.py +2 -2
  24. strawberry/codegen/query_codegen.py +20 -30
  25. strawberry/codegen/types.py +32 -32
  26. strawberry/codemods/__init__.py +9 -0
  27. strawberry/codemods/annotated_unions.py +2 -2
  28. strawberry/codemods/maybe_optional.py +118 -0
  29. strawberry/dataloader.py +28 -24
  30. strawberry/directive.py +6 -7
  31. strawberry/django/test/client.py +3 -3
  32. strawberry/django/views.py +21 -91
  33. strawberry/exceptions/__init__.py +4 -4
  34. strawberry/exceptions/conflicting_arguments.py +2 -2
  35. strawberry/exceptions/duplicated_type_name.py +4 -4
  36. strawberry/exceptions/exception.py +3 -3
  37. strawberry/exceptions/handler.py +8 -7
  38. strawberry/exceptions/invalid_argument_type.py +2 -2
  39. strawberry/exceptions/invalid_superclass_interface.py +2 -2
  40. strawberry/exceptions/invalid_union_type.py +4 -4
  41. strawberry/exceptions/missing_arguments_annotations.py +2 -2
  42. strawberry/exceptions/missing_dependencies.py +2 -4
  43. strawberry/exceptions/missing_field_annotation.py +2 -2
  44. strawberry/exceptions/missing_return_annotation.py +2 -2
  45. strawberry/exceptions/object_is_not_a_class.py +2 -2
  46. strawberry/exceptions/object_is_not_an_enum.py +2 -2
  47. strawberry/exceptions/permission_fail_silently_requires_optional.py +2 -2
  48. strawberry/exceptions/private_strawberry_field.py +2 -2
  49. strawberry/exceptions/scalar_already_registered.py +2 -2
  50. strawberry/exceptions/syntax.py +3 -3
  51. strawberry/exceptions/unresolved_field_type.py +2 -2
  52. strawberry/exceptions/utils/source_finder.py +25 -25
  53. strawberry/experimental/pydantic/_compat.py +8 -7
  54. strawberry/experimental/pydantic/conversion.py +2 -2
  55. strawberry/experimental/pydantic/conversion_types.py +2 -2
  56. strawberry/experimental/pydantic/error_type.py +10 -12
  57. strawberry/experimental/pydantic/fields.py +9 -15
  58. strawberry/experimental/pydantic/object_type.py +17 -25
  59. strawberry/experimental/pydantic/utils.py +1 -2
  60. strawberry/ext/mypy_plugin.py +12 -14
  61. strawberry/extensions/base_extension.py +2 -1
  62. strawberry/extensions/context.py +13 -18
  63. strawberry/extensions/directives.py +9 -3
  64. strawberry/extensions/field_extension.py +4 -4
  65. strawberry/extensions/mask_errors.py +24 -13
  66. strawberry/extensions/max_aliases.py +1 -3
  67. strawberry/extensions/parser_cache.py +1 -2
  68. strawberry/extensions/query_depth_limiter.py +18 -14
  69. strawberry/extensions/runner.py +2 -2
  70. strawberry/extensions/tracing/apollo.py +3 -3
  71. strawberry/extensions/tracing/datadog.py +3 -3
  72. strawberry/extensions/tracing/opentelemetry.py +6 -8
  73. strawberry/extensions/tracing/utils.py +3 -1
  74. strawberry/extensions/utils.py +2 -2
  75. strawberry/extensions/validation_cache.py +2 -3
  76. strawberry/fastapi/context.py +6 -6
  77. strawberry/fastapi/router.py +43 -42
  78. strawberry/federation/argument.py +4 -5
  79. strawberry/federation/enum.py +18 -21
  80. strawberry/federation/field.py +94 -97
  81. strawberry/federation/object_type.py +56 -58
  82. strawberry/federation/scalar.py +27 -35
  83. strawberry/federation/schema.py +15 -16
  84. strawberry/federation/schema_directive.py +7 -6
  85. strawberry/federation/schema_directives.py +11 -11
  86. strawberry/federation/union.py +4 -4
  87. strawberry/flask/views.py +16 -85
  88. strawberry/http/__init__.py +30 -20
  89. strawberry/http/async_base_view.py +208 -89
  90. strawberry/http/base.py +28 -11
  91. strawberry/http/exceptions.py +5 -7
  92. strawberry/http/ides.py +2 -3
  93. strawberry/http/sync_base_view.py +115 -69
  94. strawberry/http/types.py +3 -3
  95. strawberry/litestar/controller.py +43 -77
  96. strawberry/permission.py +4 -6
  97. strawberry/printer/ast_from_value.py +3 -5
  98. strawberry/printer/printer.py +18 -15
  99. strawberry/quart/views.py +16 -48
  100. strawberry/relay/exceptions.py +4 -4
  101. strawberry/relay/fields.py +33 -32
  102. strawberry/relay/types.py +32 -35
  103. strawberry/relay/utils.py +11 -23
  104. strawberry/resolvers.py +2 -1
  105. strawberry/sanic/context.py +1 -0
  106. strawberry/sanic/utils.py +3 -3
  107. strawberry/sanic/views.py +15 -54
  108. strawberry/scalars.py +2 -2
  109. strawberry/schema/_graphql_core.py +55 -0
  110. strawberry/schema/base.py +32 -33
  111. strawberry/schema/compat.py +9 -9
  112. strawberry/schema/config.py +10 -1
  113. strawberry/schema/exceptions.py +1 -3
  114. strawberry/schema/name_converter.py +9 -8
  115. strawberry/schema/schema.py +133 -100
  116. strawberry/schema/schema_converter.py +96 -58
  117. strawberry/schema/types/base_scalars.py +1 -1
  118. strawberry/schema/types/concrete_type.py +5 -5
  119. strawberry/schema/validation_rules/maybe_null.py +136 -0
  120. strawberry/schema_codegen/__init__.py +3 -3
  121. strawberry/schema_directive.py +7 -6
  122. strawberry/static/graphiql.html +5 -5
  123. strawberry/streamable.py +35 -0
  124. strawberry/subscriptions/protocols/graphql_transport_ws/handlers.py +5 -16
  125. strawberry/subscriptions/protocols/graphql_transport_ws/types.py +20 -20
  126. strawberry/subscriptions/protocols/graphql_ws/handlers.py +5 -12
  127. strawberry/subscriptions/protocols/graphql_ws/types.py +14 -14
  128. strawberry/test/client.py +18 -18
  129. strawberry/tools/create_type.py +2 -3
  130. strawberry/types/arguments.py +41 -28
  131. strawberry/types/auto.py +3 -4
  132. strawberry/types/base.py +25 -27
  133. strawberry/types/enum.py +22 -25
  134. strawberry/types/execution.py +21 -16
  135. strawberry/types/field.py +109 -130
  136. strawberry/types/fields/resolver.py +19 -21
  137. strawberry/types/info.py +5 -11
  138. strawberry/types/lazy_type.py +2 -3
  139. strawberry/types/maybe.py +12 -3
  140. strawberry/types/mutation.py +115 -118
  141. strawberry/types/nodes.py +2 -2
  142. strawberry/types/object_type.py +43 -63
  143. strawberry/types/scalar.py +37 -43
  144. strawberry/types/union.py +12 -14
  145. strawberry/utils/aio.py +12 -9
  146. strawberry/utils/await_maybe.py +3 -3
  147. strawberry/utils/deprecations.py +2 -2
  148. strawberry/utils/importer.py +1 -2
  149. strawberry/utils/inspect.py +4 -6
  150. strawberry/utils/logging.py +2 -2
  151. strawberry/utils/operation.py +4 -4
  152. strawberry/utils/typing.py +18 -83
  153. {strawberry_graphql-0.275.7.dist-info → strawberry_graphql-0.284.3.dist-info}/METADATA +14 -8
  154. strawberry_graphql-0.284.3.dist-info/RECORD +243 -0
  155. {strawberry_graphql-0.275.7.dist-info → strawberry_graphql-0.284.3.dist-info}/WHEEL +1 -1
  156. strawberry/utils/dataclasses.py +0 -37
  157. strawberry/utils/debug.py +0 -46
  158. strawberry/utils/graphql_lexer.py +0 -35
  159. strawberry_graphql-0.275.7.dist-info/RECORD +0 -241
  160. {strawberry_graphql-0.275.7.dist-info → strawberry_graphql-0.284.3.dist-info}/entry_points.txt +0 -0
  161. {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, Callable
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
 
@@ -1,12 +1,12 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import TYPE_CHECKING, Union
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: Union[str, int]) -> bool:
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: Optional[int] = None) -> None:
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.errors = errors
45
+ execution_context.pre_execution_errors = errors
47
46
  yield
48
47
 
49
48
 
@@ -1,4 +1,4 @@
1
- from typing import Any, Optional, Union
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, Union[Any, BackgroundTasks, Request, Response, WebSocket]]
10
+ "BaseContext", dict[str, Any | BackgroundTasks | Request | Response | WebSocket]
11
11
  ]
12
12
 
13
13
 
14
14
  class BaseContext:
15
- connection_params: Optional[Any] = None
15
+ connection_params: Any | None = None
16
16
 
17
17
  def __init__(self) -> None:
18
- self.request: Optional[Union[Request, WebSocket]] = None
19
- self.background_tasks: Optional[BackgroundTasks] = None
20
- self.response: Optional[Response] = None
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"]
@@ -6,13 +6,15 @@ from inspect import signature
6
6
  from typing import (
7
7
  TYPE_CHECKING,
8
8
  Any,
9
- Callable,
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 fastapi import APIRouter, Depends, params
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 AsyncIterator, Awaitable, Sequence
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 = ASGIRequestAdapter
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
- ..., Union[Optional[CustomContext], Awaitable[Optional[CustomContext]]]
72
+ ..., CustomContext | None | Awaitable[CustomContext | None]
71
73
  ],
72
74
  ) -> Callable[..., Awaitable[CustomContext]]:
73
75
  async def dependency(
74
- custom_context: Optional[CustomContext],
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("Union[Request, WebSocket]", connection)
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: Optional[bool] = None,
122
- graphql_ide: Optional[GraphQL_IDE] = "graphiql",
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
- debug: bool = False,
127
- root_value_getter: Optional[Callable[[], RootValue]] = None,
128
- context_getter: Optional[
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: Optional[list[Union[str, Enum]]] = None,
138
- dependencies: Optional[Sequence[params.Depends]] = None,
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: Optional[dict[Union[int, str], dict[str, Any]]] = None,
141
- callbacks: Optional[list[BaseRoute]] = None,
142
- routes: Optional[list[BaseRoute]] = None,
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: Optional[ASGIApp] = None,
145
- dependency_overrides_provider: Optional[Any] = None,
144
+ default: ASGIApp | None = None,
145
+ dependency_overrides_provider: Any | None = None,
146
146
  route_class: type[APIRoute] = APIRoute,
147
- on_startup: Optional[Sequence[Callable[[], Any]]] = None,
148
- on_shutdown: Optional[Sequence[Callable[[], Any]]] = None,
149
- lifespan: Optional[Lifespan[Any]] = None,
150
- deprecated: Optional[bool] = None,
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: Union[Request, WebSocket], response: Union[Response, WebSocket]
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: Union[Request, WebSocket]
272
- ) -> Optional[RootValue]: # pragma: no cover
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, response_data: GraphQLHTTPResponse, sub_response: Response
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: Union[Request, WebSocket]
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) -> Optional[str]:
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: Optional[str]
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: Optional[str] = None,
9
- name: Optional[str] = None,
10
- deprecation_reason: Optional[str] = None,
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: Optional[Iterable[str]] = (),
12
+ tags: Iterable[str] | None = (),
14
13
  ) -> StrawberryArgumentAnnotation:
15
14
  from strawberry.federation.schema_directives import Inaccessible, Tag
16
15
 
@@ -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: Optional[str] = None,
24
- deprecation_reason: Optional[str] = None,
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: Optional[str] = None,
52
- description: Optional[str] = None,
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: Optional[list[list[str]]] = None,
57
- requires_scopes: Optional[list[list[str]]] = None,
58
- tags: Optional[Iterable[str]] = (),
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: Optional[str] = None,
67
- description: Optional[str] = None,
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: Optional[list[list[str]]] = None,
72
- requires_scopes: Optional[list[list[str]]] = None,
73
- tags: Optional[Iterable[str]] = (),
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: Optional[EnumType] = None,
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: Optional[list[list[str]]] = None,
86
- requires_scopes: Optional[list[list[str]]] = None,
87
- tags: Optional[Iterable[str]] = (),
88
- ) -> Union[EnumType, Callable[[EnumType], EnumType]]:
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