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
@@ -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, get_origin
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
- ) -> Optional[inspect.Parameter]:
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
- ) -> Optional[inspect.Parameter]:
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
- ) -> Optional[inspect.Parameter]:
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
- ) -> Optional[inspect.Parameter]:
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: Union[Callable[..., T], staticmethod, classmethod],
194
+ func: Callable[..., T] | staticmethod | classmethod,
197
195
  *,
198
- description: Optional[str] = None,
199
- type_override: Optional[Union[StrawberryType, type]] = None,
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, Union[StrawberryAnnotation, None]]:
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, Optional[inspect.Parameter]]:
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) -> Optional[inspect.Parameter]:
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) -> Optional[inspect.Parameter]:
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) -> Optional[inspect.Parameter]:
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) -> Optional[inspect.Parameter]:
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) -> Optional[StrawberryAnnotation]:
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) -> Optional[Union[StrawberryType, type]]:
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, Union[StrawberryType, builtins.type]]
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.base import (
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: Union[type, tuple[type, ...]]) -> type[Info]:
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) # type: ignore
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
- ) -> Optional[Union[type[WithStrawberryObjectDefinition], StrawberryType]]:
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) -> Optional[StrawberryArgument]:
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)
@@ -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: Optional[str] = None
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, TypeVar, Union
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 = Union[Some[Union[T, None]], None]
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
 
@@ -4,12 +4,9 @@ import dataclasses
4
4
  from typing import (
5
5
  TYPE_CHECKING,
6
6
  Any,
7
- Callable,
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 typing_extensions import Literal
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: Optional[str] = None,
39
- description: Optional[str] = None,
35
+ name: str | None = None,
36
+ description: str | None = None,
40
37
  init: Literal[False] = False,
41
- permission_classes: Optional[list[type[BasePermission]]] = None,
42
- deprecation_reason: Optional[str] = None,
38
+ permission_classes: list[type[BasePermission]] | None = None,
39
+ deprecation_reason: str | None = None,
43
40
  default: Any = dataclasses.MISSING,
44
- default_factory: Union[Callable[..., object], object] = dataclasses.MISSING,
45
- metadata: Optional[Mapping[Any, Any]] = None,
46
- directives: Optional[Sequence[object]] = (),
47
- extensions: Optional[list[FieldExtension]] = None,
48
- graphql_type: Optional[Any] = None,
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: Optional[str] = None,
57
- description: Optional[str] = None,
53
+ name: str | None = None,
54
+ description: str | None = None,
58
55
  init: Literal[False] = False,
59
- permission_classes: Optional[list[type[BasePermission]]] = None,
60
- deprecation_reason: Optional[str] = None,
56
+ permission_classes: list[type[BasePermission]] | None = None,
57
+ deprecation_reason: str | None = None,
61
58
  default: Any = dataclasses.MISSING,
62
- default_factory: Union[Callable[..., object], object] = dataclasses.MISSING,
63
- metadata: Optional[Mapping[Any, Any]] = None,
64
- directives: Optional[Sequence[object]] = (),
65
- extensions: Optional[list[FieldExtension]] = None,
66
- graphql_type: Optional[Any] = None,
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: Optional[str] = None,
74
- description: Optional[str] = None,
70
+ name: str | None = None,
71
+ description: str | None = None,
75
72
  init: Literal[True] = True,
76
- permission_classes: Optional[list[type[BasePermission]]] = None,
77
- deprecation_reason: Optional[str] = None,
73
+ permission_classes: list[type[BasePermission]] | None = None,
74
+ deprecation_reason: str | None = None,
78
75
  default: Any = dataclasses.MISSING,
79
- default_factory: Union[Callable[..., object], object] = dataclasses.MISSING,
80
- metadata: Optional[Mapping[Any, Any]] = None,
81
- directives: Optional[Sequence[object]] = (),
82
- extensions: Optional[list[FieldExtension]] = None,
83
- graphql_type: Optional[Any] = None,
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: Optional[str] = None,
92
- description: Optional[str] = None,
93
- permission_classes: Optional[list[type[BasePermission]]] = None,
94
- deprecation_reason: Optional[str] = None,
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: Union[Callable[..., object], object] = dataclasses.MISSING,
97
- metadata: Optional[Mapping[Any, Any]] = None,
98
- directives: Optional[Sequence[object]] = (),
99
- extensions: Optional[list[FieldExtension]] = None,
100
- graphql_type: Optional[Any] = None,
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: Optional[str] = None,
109
- description: Optional[str] = None,
110
- permission_classes: Optional[list[type[BasePermission]]] = None,
111
- deprecation_reason: Optional[str] = None,
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: Union[Callable[..., object], object] = dataclasses.MISSING,
114
- metadata: Optional[Mapping[Any, Any]] = None,
115
- directives: Optional[Sequence[object]] = (),
116
- extensions: Optional[list[FieldExtension]] = None,
117
- graphql_type: Optional[Any] = None,
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: Optional[_RESOLVER_TYPE[Any]] = None,
119
+ resolver: _RESOLVER_TYPE[Any] | None = None,
123
120
  *,
124
- name: Optional[str] = None,
125
- description: Optional[str] = None,
126
- permission_classes: Optional[list[type[BasePermission]]] = None,
127
- deprecation_reason: Optional[str] = None,
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: Union[Callable[..., object], object] = dataclasses.MISSING,
130
- metadata: Optional[Mapping[Any, Any]] = None,
131
- directives: Optional[Sequence[object]] = (),
132
- extensions: Optional[list[FieldExtension]] = None,
133
- graphql_type: Optional[Any] = None,
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, None] = None,
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: Optional[str] = None,
199
- description: Optional[str] = None,
195
+ name: str | None = None,
196
+ description: str | None = None,
200
197
  init: Literal[False] = False,
201
- permission_classes: Optional[list[type[BasePermission]]] = None,
202
- deprecation_reason: Optional[str] = None,
198
+ permission_classes: list[type[BasePermission]] | None = None,
199
+ deprecation_reason: str | None = None,
203
200
  default: Any = dataclasses.MISSING,
204
- default_factory: Union[Callable[..., object], object] = dataclasses.MISSING,
205
- metadata: Optional[Mapping[Any, Any]] = None,
206
- directives: Optional[Sequence[object]] = (),
207
- extensions: Optional[list[FieldExtension]] = None,
208
- graphql_type: Optional[Any] = None,
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: Optional[str] = None,
217
- description: Optional[str] = None,
213
+ name: str | None = None,
214
+ description: str | None = None,
218
215
  init: Literal[False] = False,
219
- permission_classes: Optional[list[type[BasePermission]]] = None,
220
- deprecation_reason: Optional[str] = None,
216
+ permission_classes: list[type[BasePermission]] | None = None,
217
+ deprecation_reason: str | None = None,
221
218
  default: Any = dataclasses.MISSING,
222
- default_factory: Union[Callable[..., object], object] = dataclasses.MISSING,
223
- metadata: Optional[Mapping[Any, Any]] = None,
224
- directives: Optional[Sequence[object]] = (),
225
- extensions: Optional[list[FieldExtension]] = None,
226
- graphql_type: Optional[Any] = None,
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: Optional[str] = None,
234
- description: Optional[str] = None,
230
+ name: str | None = None,
231
+ description: str | None = None,
235
232
  init: Literal[True] = True,
236
- permission_classes: Optional[list[type[BasePermission]]] = None,
237
- deprecation_reason: Optional[str] = None,
233
+ permission_classes: list[type[BasePermission]] | None = None,
234
+ deprecation_reason: str | None = None,
238
235
  default: Any = dataclasses.MISSING,
239
- default_factory: Union[Callable[..., object], object] = dataclasses.MISSING,
240
- metadata: Optional[Mapping[Any, Any]] = None,
241
- directives: Optional[Sequence[object]] = (),
242
- extensions: Optional[list[FieldExtension]] = None,
243
- graphql_type: Optional[Any] = None,
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: Optional[str] = None,
252
- description: Optional[str] = None,
253
- permission_classes: Optional[list[type[BasePermission]]] = None,
254
- deprecation_reason: Optional[str] = None,
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: Union[Callable[..., object], object] = dataclasses.MISSING,
257
- metadata: Optional[Mapping[Any, Any]] = None,
258
- directives: Optional[Sequence[object]] = (),
259
- extensions: Optional[list[FieldExtension]] = None,
260
- graphql_type: Optional[Any] = None,
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: Optional[str] = None,
269
- description: Optional[str] = None,
270
- permission_classes: Optional[list[type[BasePermission]]] = None,
271
- deprecation_reason: Optional[str] = None,
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: Union[Callable[..., object], object] = dataclasses.MISSING,
274
- metadata: Optional[Mapping[Any, Any]] = None,
275
- directives: Optional[Sequence[object]] = (),
276
- extensions: Optional[list[FieldExtension]] = None,
277
- graphql_type: Optional[Any] = None,
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: Optional[_RESOLVER_TYPE[Any]] = None,
279
+ resolver: _RESOLVER_TYPE[Any] | None = None,
283
280
  *,
284
- name: Optional[str] = None,
285
- description: Optional[str] = None,
286
- permission_classes: Optional[list[type[BasePermission]]] = None,
287
- deprecation_reason: Optional[str] = None,
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: Union[Callable[..., object], object] = dataclasses.MISSING,
290
- metadata: Optional[Mapping[Any, Any]] = None,
291
- directives: Optional[Sequence[object]] = (),
292
- extensions: Optional[list[FieldExtension]] = None,
293
- graphql_type: Optional[Any] = None,
294
- init: Literal[True, False, None] = None,
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, Optional, Union
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: Optional[str] = None
142
+ alias: str | None = None
143
143
 
144
144
  @classmethod
145
145
  def from_node(cls, info: GraphQLResolveInfo, node: GQLFieldNode) -> SelectedField: