strawberry-graphql 0.235.2__py3-none-any.whl → 0.236.0__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.
Files changed (182) hide show
  1. strawberry/__init__.py +17 -11
  2. strawberry/aiohttp/handlers/graphql_transport_ws_handler.py +3 -0
  3. strawberry/aiohttp/handlers/graphql_ws_handler.py +3 -0
  4. strawberry/aiohttp/test/client.py +3 -0
  5. strawberry/aiohttp/views.py +3 -0
  6. strawberry/annotation.py +19 -19
  7. strawberry/asgi/__init__.py +3 -3
  8. strawberry/asgi/handlers/graphql_transport_ws_handler.py +3 -0
  9. strawberry/asgi/handlers/graphql_ws_handler.py +3 -0
  10. strawberry/asgi/test/client.py +3 -0
  11. strawberry/chalice/views.py +12 -3
  12. strawberry/channels/handlers/__init__.py +0 -0
  13. strawberry/channels/handlers/base.py +5 -5
  14. strawberry/channels/handlers/graphql_transport_ws_handler.py +3 -0
  15. strawberry/channels/handlers/graphql_ws_handler.py +3 -0
  16. strawberry/channels/handlers/http_handler.py +5 -2
  17. strawberry/channels/handlers/ws_handler.py +4 -1
  18. strawberry/channels/router.py +9 -5
  19. strawberry/channels/testing.py +11 -4
  20. strawberry/cli/commands/upgrade/__init__.py +13 -5
  21. strawberry/cli/commands/upgrade/_fake_progress.py +2 -1
  22. strawberry/cli/commands/upgrade/_run_codemod.py +18 -1
  23. strawberry/codegen/exceptions.py +8 -0
  24. strawberry/codegen/query_codegen.py +16 -7
  25. strawberry/codegen/types.py +32 -1
  26. strawberry/codemods/update_imports.py +136 -0
  27. strawberry/dataloader.py +13 -0
  28. strawberry/directive.py +52 -4
  29. strawberry/django/context.py +4 -1
  30. strawberry/django/test/client.py +3 -0
  31. strawberry/django/views.py +3 -0
  32. strawberry/exceptions/__init__.py +5 -5
  33. strawberry/exceptions/duplicated_type_name.py +1 -1
  34. strawberry/exceptions/invalid_argument_type.py +3 -3
  35. strawberry/exceptions/invalid_union_type.py +5 -6
  36. strawberry/exceptions/missing_arguments_annotations.py +1 -1
  37. strawberry/exceptions/missing_dependencies.py +10 -2
  38. strawberry/exceptions/missing_return_annotation.py +1 -1
  39. strawberry/exceptions/permission_fail_silently_requires_optional.py +3 -3
  40. strawberry/exceptions/scalar_already_registered.py +1 -1
  41. strawberry/exceptions/unresolved_field_type.py +2 -2
  42. strawberry/exceptions/utils/source_finder.py +5 -2
  43. strawberry/experimental/pydantic/conversion.py +5 -5
  44. strawberry/experimental/pydantic/conversion_types.py +4 -2
  45. strawberry/experimental/pydantic/error_type.py +2 -2
  46. strawberry/experimental/pydantic/fields.py +2 -2
  47. strawberry/experimental/pydantic/object_type.py +11 -7
  48. strawberry/experimental/pydantic/utils.py +4 -5
  49. strawberry/ext/dataclasses/dataclasses.py +2 -1
  50. strawberry/ext/mypy_plugin.py +10 -8
  51. strawberry/extensions/add_validation_rules.py +27 -23
  52. strawberry/extensions/base_extension.py +6 -4
  53. strawberry/extensions/directives.py +4 -1
  54. strawberry/extensions/disable_validation.py +15 -12
  55. strawberry/extensions/field_extension.py +11 -5
  56. strawberry/extensions/mask_errors.py +3 -0
  57. strawberry/extensions/max_aliases.py +21 -19
  58. strawberry/extensions/max_tokens.py +14 -16
  59. strawberry/extensions/parser_cache.py +22 -19
  60. strawberry/extensions/pyinstrument.py +4 -8
  61. strawberry/extensions/query_depth_limiter.py +22 -23
  62. strawberry/extensions/runner.py +3 -0
  63. strawberry/extensions/tracing/apollo.py +3 -0
  64. strawberry/extensions/tracing/datadog.py +7 -2
  65. strawberry/extensions/tracing/opentelemetry.py +3 -0
  66. strawberry/extensions/tracing/sentry.py +3 -0
  67. strawberry/extensions/tracing/utils.py +3 -0
  68. strawberry/extensions/utils.py +3 -0
  69. strawberry/extensions/validation_cache.py +23 -20
  70. strawberry/fastapi/context.py +3 -0
  71. strawberry/fastapi/handlers/graphql_transport_ws_handler.py +3 -0
  72. strawberry/fastapi/handlers/graphql_ws_handler.py +3 -0
  73. strawberry/fastapi/router.py +3 -0
  74. strawberry/federation/argument.py +4 -1
  75. strawberry/federation/enum.py +5 -3
  76. strawberry/federation/field.py +6 -3
  77. strawberry/federation/mutation.py +2 -0
  78. strawberry/federation/object_type.py +7 -4
  79. strawberry/federation/scalar.py +43 -20
  80. strawberry/federation/schema.py +12 -9
  81. strawberry/federation/schema_directive.py +2 -2
  82. strawberry/federation/schema_directives.py +19 -1
  83. strawberry/federation/types.py +5 -2
  84. strawberry/federation/union.py +27 -8
  85. strawberry/field_extensions/input_mutation.py +5 -2
  86. strawberry/file_uploads/scalars.py +3 -1
  87. strawberry/file_uploads/utils.py +3 -0
  88. strawberry/flask/views.py +6 -0
  89. strawberry/http/__init__.py +9 -0
  90. strawberry/http/async_base_view.py +4 -3
  91. strawberry/http/base.py +3 -0
  92. strawberry/http/exceptions.py +3 -0
  93. strawberry/http/ides.py +3 -0
  94. strawberry/http/sync_base_view.py +4 -3
  95. strawberry/http/temporal_response.py +3 -0
  96. strawberry/http/types.py +3 -0
  97. strawberry/http/typevars.py +3 -0
  98. strawberry/litestar/controller.py +6 -0
  99. strawberry/litestar/handlers/__init__.py +0 -0
  100. strawberry/litestar/handlers/graphql_transport_ws_handler.py +3 -0
  101. strawberry/litestar/handlers/graphql_ws_handler.py +3 -0
  102. strawberry/parent.py +27 -21
  103. strawberry/permission.py +70 -27
  104. strawberry/printer/ast_from_value.py +4 -1
  105. strawberry/printer/printer.py +8 -5
  106. strawberry/quart/views.py +3 -0
  107. strawberry/relay/exceptions.py +7 -0
  108. strawberry/relay/fields.py +70 -45
  109. strawberry/relay/types.py +78 -78
  110. strawberry/relay/utils.py +10 -1
  111. strawberry/resolvers.py +3 -0
  112. strawberry/sanic/context.py +3 -0
  113. strawberry/sanic/utils.py +10 -8
  114. strawberry/sanic/views.py +4 -2
  115. strawberry/scalars.py +6 -2
  116. strawberry/schema/base.py +7 -4
  117. strawberry/schema/compat.py +12 -2
  118. strawberry/schema/config.py +3 -0
  119. strawberry/schema/exceptions.py +3 -0
  120. strawberry/schema/execute.py +3 -0
  121. strawberry/schema/name_converter.py +12 -9
  122. strawberry/schema/schema.py +46 -9
  123. strawberry/schema/schema_converter.py +16 -14
  124. strawberry/schema/types/base_scalars.py +3 -1
  125. strawberry/schema/types/concrete_type.py +4 -4
  126. strawberry/schema/types/scalar.py +8 -1
  127. strawberry/schema/validation_rules/one_of.py +3 -0
  128. strawberry/schema_codegen/__init__.py +3 -0
  129. strawberry/schema_directive.py +2 -2
  130. strawberry/starlite/controller.py +3 -0
  131. strawberry/starlite/handlers/__init__.py +0 -0
  132. strawberry/starlite/handlers/graphql_transport_ws_handler.py +3 -0
  133. strawberry/starlite/handlers/graphql_ws_handler.py +3 -0
  134. strawberry/subscriptions/__init__.py +6 -0
  135. strawberry/subscriptions/protocols/graphql_transport_ws/__init__.py +5 -0
  136. strawberry/subscriptions/protocols/graphql_transport_ws/handlers.py +12 -17
  137. strawberry/subscriptions/protocols/graphql_transport_ws/types.py +21 -25
  138. strawberry/subscriptions/protocols/graphql_ws/__init__.py +14 -0
  139. strawberry/subscriptions/protocols/graphql_ws/handlers.py +8 -5
  140. strawberry/subscriptions/protocols/graphql_ws/types.py +11 -0
  141. strawberry/test/client.py +44 -29
  142. strawberry/tools/create_type.py +27 -8
  143. strawberry/tools/merge_types.py +5 -3
  144. strawberry/types/__init__.py +8 -1
  145. strawberry/{arguments.py → types/arguments.py} +44 -13
  146. strawberry/{auto.py → types/auto.py} +21 -3
  147. strawberry/types/{types.py → base.py} +234 -10
  148. strawberry/{enum.py → types/enum.py} +69 -9
  149. strawberry/types/execution.py +3 -0
  150. strawberry/{field.py → types/field.py} +46 -23
  151. strawberry/types/fields/resolver.py +2 -2
  152. strawberry/types/graphql.py +3 -0
  153. strawberry/types/info.py +50 -7
  154. strawberry/{lazy_type.py → types/lazy_type.py} +50 -0
  155. strawberry/types/mutation.py +351 -0
  156. strawberry/types/nodes.py +4 -2
  157. strawberry/{object_type.py → types/object_type.py} +108 -29
  158. strawberry/{private.py → types/private.py} +13 -6
  159. strawberry/{custom_scalar.py → types/scalar.py} +39 -23
  160. strawberry/types/type_resolver.py +21 -16
  161. strawberry/{union.py → types/union.py} +24 -9
  162. strawberry/{unset.py → types/unset.py} +20 -0
  163. strawberry/utils/aio.py +8 -0
  164. strawberry/utils/await_maybe.py +3 -0
  165. strawberry/utils/dataclasses.py +3 -0
  166. strawberry/utils/debug.py +5 -2
  167. strawberry/utils/deprecations.py +3 -0
  168. strawberry/utils/graphql_lexer.py +3 -0
  169. strawberry/utils/importer.py +3 -0
  170. strawberry/utils/inspect.py +39 -30
  171. strawberry/utils/logging.py +3 -0
  172. strawberry/utils/operation.py +3 -0
  173. strawberry/utils/str_converters.py +3 -0
  174. strawberry/utils/typing.py +33 -16
  175. {strawberry_graphql-0.235.2.dist-info → strawberry_graphql-0.236.0.dist-info}/METADATA +1 -1
  176. strawberry_graphql-0.236.0.dist-info/RECORD +255 -0
  177. strawberry/mutation.py +0 -8
  178. strawberry/type.py +0 -232
  179. strawberry_graphql-0.235.2.dist-info/RECORD +0 -252
  180. {strawberry_graphql-0.235.2.dist-info → strawberry_graphql-0.236.0.dist-info}/LICENSE +0 -0
  181. {strawberry_graphql-0.235.2.dist-info → strawberry_graphql-0.236.0.dist-info}/WHEEL +0 -0
  182. {strawberry_graphql-0.235.2.dist-info → strawberry_graphql-0.236.0.dist-info}/entry_points.txt +0 -0
strawberry/relay/utils.py CHANGED
@@ -6,8 +6,8 @@ import sys
6
6
  from typing import TYPE_CHECKING, Any, Tuple, Union
7
7
  from typing_extensions import Self, assert_never
8
8
 
9
+ from strawberry.types.base import StrawberryObjectDefinition
9
10
  from strawberry.types.nodes import InlineFragment, Selection
10
- from strawberry.types.types import StrawberryObjectDefinition
11
11
 
12
12
  if TYPE_CHECKING:
13
13
  from strawberry.types.info import Info
@@ -86,6 +86,7 @@ def should_resolve_list_connection_edges(info: Info) -> bool:
86
86
 
87
87
  def _check_selection(selection: Selection) -> bool:
88
88
  """Recursively inspect the selection to check if the user requested to resolve the `edges` field.
89
+
89
90
  Args:
90
91
  selection (Selection): The selection to check.
91
92
 
@@ -187,3 +188,11 @@ class SliceMetadata:
187
188
  end=end,
188
189
  expected=expected,
189
190
  )
191
+
192
+
193
+ __all__ = [
194
+ "from_base64",
195
+ "to_base64",
196
+ "should_resolve_list_connection_edges",
197
+ "SliceMetadata",
198
+ ]
strawberry/resolvers.py CHANGED
@@ -4,3 +4,6 @@ from typing import Any, Callable
4
4
  def is_default_resolver(func: Callable[..., Any]) -> bool:
5
5
  """Check whether the function is a default resolver or a user provided one."""
6
6
  return getattr(func, "_is_default", False)
7
+
8
+
9
+ __all__ = ["is_default_resolver"]
@@ -22,3 +22,6 @@ class StrawberrySanicContext(TypedDict):
22
22
  )
23
23
 
24
24
  return super().__getitem__(key)
25
+
26
+
27
+ __all__ = ["StrawberrySanicContext"]
strawberry/sanic/utils.py CHANGED
@@ -10,18 +10,17 @@ if TYPE_CHECKING:
10
10
 
11
11
 
12
12
  def convert_request_to_files_dict(request: Request) -> Dict[str, Any]:
13
- """
14
- request.files has the following format, even if only a single file is uploaded:
13
+ """Converts the request.files dictionary to a dictionary of BytesIO objects.
14
+
15
+ `request.files` has the following format, even if only a single file is uploaded:
15
16
 
17
+ ```python
16
18
  {
17
- 'textFile': [
18
- sanic.request.File(
19
- type='text/plain',
20
- body=b'strawberry',
21
- name='textFile.txt'
22
- )
19
+ "textFile": [
20
+ sanic.request.File(type="text/plain", body=b"strawberry", name="textFile.txt")
23
21
  ]
24
22
  }
23
+ ```
25
24
 
26
25
  Note that the dictionary entries are lists.
27
26
  """
@@ -38,3 +37,6 @@ def convert_request_to_files_dict(request: Request) -> Dict[str, Any]:
38
37
  files_dict[field_name] = BytesIO(file_list[0].body)
39
38
 
40
39
  return files_dict
40
+
41
+
42
+ __all__ = ["convert_request_to_files_dict"]
strawberry/sanic/views.py CHANGED
@@ -72,8 +72,7 @@ class GraphQLView(
72
72
  AsyncBaseHTTPView[Request, HTTPResponse, TemporalResponse, Context, RootValue],
73
73
  HTTPMethodView,
74
74
  ):
75
- """
76
- Class based view to handle GraphQL HTTP Requests
75
+ """Class based view to handle GraphQL HTTP Requests.
77
76
 
78
77
  Args:
79
78
  schema: strawberry.Schema
@@ -172,3 +171,6 @@ class GraphQLView(
172
171
  return await self.run(request)
173
172
  except HTTPException as e:
174
173
  return HTTPResponse(e.reason, status=e.status_code)
174
+
175
+
176
+ __all__ = ["GraphQLView"]
strawberry/scalars.py CHANGED
@@ -3,13 +3,14 @@ from __future__ import annotations
3
3
  import base64
4
4
  from typing import TYPE_CHECKING, Any, Dict, NewType, Union
5
5
 
6
- from .custom_scalar import scalar
6
+ from strawberry.types.scalar import scalar
7
7
 
8
8
  if TYPE_CHECKING:
9
- from .custom_scalar import ScalarDefinition, ScalarWrapper
9
+ from strawberry.types.scalar import ScalarDefinition, ScalarWrapper
10
10
 
11
11
 
12
12
  ID = NewType("ID", str)
13
+ """Represent the GraphQL `ID` scalar type."""
13
14
 
14
15
  JSON = scalar(
15
16
  NewType("JSON", object), # mypy doesn't like `NewType("name", Any)`
@@ -62,3 +63,6 @@ def is_scalar(
62
63
  return True
63
64
 
64
65
  return hasattr(annotation, "_scalar_definition")
66
+
67
+
68
+ __all__ = ["ID", "JSON", "Base16", "Base32", "Base64", "is_scalar"]
strawberry/schema/base.py CHANGED
@@ -10,14 +10,14 @@ from strawberry.utils.logging import StrawberryLogger
10
10
  if TYPE_CHECKING:
11
11
  from graphql import GraphQLError
12
12
 
13
- from strawberry.custom_scalar import ScalarDefinition
14
13
  from strawberry.directive import StrawberryDirective
15
- from strawberry.enum import EnumDefinition
16
14
  from strawberry.schema.schema_converter import GraphQLCoreConverter
17
15
  from strawberry.types import ExecutionContext, ExecutionResult
16
+ from strawberry.types.base import StrawberryObjectDefinition
17
+ from strawberry.types.enum import EnumDefinition
18
18
  from strawberry.types.graphql import OperationType
19
- from strawberry.types.types import StrawberryObjectDefinition
20
- from strawberry.union import StrawberryUnion
19
+ from strawberry.types.scalar import ScalarDefinition
20
+ from strawberry.types.union import StrawberryUnion
21
21
 
22
22
  from .config import StrawberryConfig
23
23
 
@@ -113,3 +113,6 @@ class BaseSchema(Protocol):
113
113
  ) -> None:
114
114
  for error in errors:
115
115
  StrawberryLogger.error(error, execution_context)
116
+
117
+
118
+ __all__ = ["BaseSchema"]
@@ -3,7 +3,7 @@ from __future__ import annotations
3
3
  from typing import TYPE_CHECKING, Dict, Union
4
4
 
5
5
  from strawberry.scalars import is_scalar as is_strawberry_scalar
6
- from strawberry.type import StrawberryType, has_object_definition
6
+ from strawberry.types.base import StrawberryType, has_object_definition
7
7
 
8
8
  # TypeGuard is only available in typing_extensions => 3.10, we don't want
9
9
  # to force updates to the typing_extensions package so we only use it when
@@ -12,7 +12,7 @@ from strawberry.type import StrawberryType, has_object_definition
12
12
  if TYPE_CHECKING:
13
13
  from typing_extensions import TypeGuard
14
14
 
15
- from strawberry.custom_scalar import ScalarDefinition, ScalarWrapper
15
+ from strawberry.types.scalar import ScalarDefinition, ScalarWrapper
16
16
 
17
17
 
18
18
  def is_input_type(type_: Union[StrawberryType, type]) -> TypeGuard[type]:
@@ -51,3 +51,13 @@ def is_graphql_generic(type_: Union[StrawberryType, type]) -> bool:
51
51
  return type_.is_graphql_generic
52
52
 
53
53
  return False
54
+
55
+
56
+ __all__ = [
57
+ "is_input_type",
58
+ "is_interface_type",
59
+ "is_scalar",
60
+ "is_enum",
61
+ "is_schema_directive",
62
+ "is_graphql_generic",
63
+ ]
@@ -20,3 +20,6 @@ class StrawberryConfig:
20
20
  ) -> None:
21
21
  if auto_camel_case is not None:
22
22
  self.name_converter.auto_camel_case = auto_camel_case
23
+
24
+
25
+ __all__ = ["StrawberryConfig"]
@@ -13,3 +13,6 @@ class InvalidOperationTypeError(Exception):
13
13
  }[self.operation_type]
14
14
 
15
15
  return f"{operation_type} are not allowed when using {method}"
16
+
17
+
18
+ __all__ = ["InvalidOperationTypeError"]
@@ -277,3 +277,6 @@ def execute_sync(
277
277
  errors=execution_context.result.errors,
278
278
  extensions=extensions_runner.get_extensions_results_sync(),
279
279
  )
280
+
281
+
282
+ __all__ = ["execute", "execute_sync"]
@@ -3,25 +3,25 @@ from __future__ import annotations
3
3
  from typing import TYPE_CHECKING, List, Optional, Union, cast
4
4
  from typing_extensions import Protocol
5
5
 
6
- from strawberry.custom_scalar import ScalarDefinition
7
6
  from strawberry.directive import StrawberryDirective
8
- from strawberry.enum import EnumDefinition, EnumValue
9
- from strawberry.lazy_type import LazyType
10
7
  from strawberry.schema_directive import StrawberrySchemaDirective
11
- from strawberry.type import (
8
+ from strawberry.types.base import (
12
9
  StrawberryList,
10
+ StrawberryObjectDefinition,
13
11
  StrawberryOptional,
14
12
  has_object_definition,
15
13
  )
16
- from strawberry.types.types import StrawberryObjectDefinition
17
- from strawberry.union import StrawberryUnion
14
+ from strawberry.types.enum import EnumDefinition, EnumValue
15
+ from strawberry.types.lazy_type import LazyType
16
+ from strawberry.types.scalar import ScalarDefinition
17
+ from strawberry.types.union import StrawberryUnion
18
18
  from strawberry.utils.str_converters import capitalize_first, to_camel_case
19
19
  from strawberry.utils.typing import eval_type
20
20
 
21
21
  if TYPE_CHECKING:
22
- from strawberry.arguments import StrawberryArgument
23
- from strawberry.field import StrawberryField
24
- from strawberry.type import StrawberryType
22
+ from strawberry.types.arguments import StrawberryArgument
23
+ from strawberry.types.base import StrawberryType
24
+ from strawberry.types.field import StrawberryField
25
25
 
26
26
 
27
27
  class HasGraphQLName(Protocol):
@@ -184,3 +184,6 @@ class NameConverter:
184
184
  assert obj.python_name
185
185
 
186
186
  return self.apply_naming_config(obj.python_name)
187
+
188
+
189
+ __all__ = ["NameConverter"]
@@ -36,10 +36,9 @@ from strawberry.extensions.directives import (
36
36
  )
37
37
  from strawberry.schema.schema_converter import GraphQLCoreConverter
38
38
  from strawberry.schema.types.scalar import DEFAULT_SCALAR_REGISTRY
39
- from strawberry.type import has_object_definition
40
39
  from strawberry.types import ExecutionContext
40
+ from strawberry.types.base import StrawberryObjectDefinition, has_object_definition
41
41
  from strawberry.types.graphql import OperationType
42
- from strawberry.types.types import StrawberryObjectDefinition
43
42
 
44
43
  from ..printer import print_schema
45
44
  from . import compat
@@ -51,14 +50,14 @@ if TYPE_CHECKING:
51
50
  from graphql import ExecutionContext as GraphQLExecutionContext
52
51
  from graphql import ExecutionResult as GraphQLExecutionResult
53
52
 
54
- from strawberry.custom_scalar import ScalarDefinition, ScalarWrapper
55
53
  from strawberry.directive import StrawberryDirective
56
- from strawberry.enum import EnumDefinition
57
54
  from strawberry.extensions import SchemaExtension
58
- from strawberry.field import StrawberryField
59
- from strawberry.type import StrawberryType
60
55
  from strawberry.types import ExecutionResult
61
- from strawberry.union import StrawberryUnion
56
+ from strawberry.types.base import StrawberryType
57
+ from strawberry.types.enum import EnumDefinition
58
+ from strawberry.types.field import StrawberryField
59
+ from strawberry.types.scalar import ScalarDefinition, ScalarWrapper
60
+ from strawberry.types.union import StrawberryUnion
62
61
 
63
62
  DEFAULT_ALLOWED_OPERATION_TYPES = {
64
63
  OperationType.QUERY,
@@ -81,10 +80,45 @@ class Schema(BaseSchema):
81
80
  execution_context_class: Optional[Type[GraphQLExecutionContext]] = None,
82
81
  config: Optional[StrawberryConfig] = None,
83
82
  scalar_overrides: Optional[
84
- Dict[object, Union[Type, ScalarWrapper, ScalarDefinition]]
83
+ Dict[object, Union[Type, ScalarWrapper, ScalarDefinition]],
85
84
  ] = None,
86
85
  schema_directives: Iterable[object] = (),
87
86
  ) -> None:
87
+ """Default Schema to be to be used in a Strawberry application.
88
+
89
+ A GraphQL Schema class used to define the structure and configuration
90
+ of GraphQL queries, mutations, and subscriptions.
91
+
92
+ This class allows the creation of a GraphQL schema by specifying the types
93
+ for queries, mutations, and subscriptions, along with various configuration
94
+ options such as directives, extensions, and scalar overrides.
95
+
96
+ Args:
97
+ query: The entry point for queries.
98
+ mutation: The entry point for mutations.
99
+ subscription: The entry point for subscriptions.
100
+ directives: A list of operation directives that clients can use.
101
+ The bult-in `@include` and `@skip` are included by default.
102
+ types: A list of additional types that will be included in the schema.
103
+ extensions: A list of Strawberry extensions.
104
+ execution_context_class: The execution context class.
105
+ config: The configuration for the schema.
106
+ scalar_overrides: A dictionary of overrides for scalars.
107
+ schema_directives: A list of schema directives for the schema.
108
+
109
+ Example:
110
+ ```python
111
+ import strawberry
112
+
113
+
114
+ @strawberry.type
115
+ class Query:
116
+ name: str = "Patrick"
117
+
118
+
119
+ schema = strawberry.Schema(query=Query)
120
+ ```
121
+ """
88
122
  self.query = query
89
123
  self.mutation = mutation
90
124
  self.subscription = subscription
@@ -395,7 +429,7 @@ class Schema(BaseSchema):
395
429
  __str__ = as_str
396
430
 
397
431
  def introspect(self) -> Dict[str, Any]:
398
- """Return the introspection query result for the current schema
432
+ """Return the introspection query result for the current schema.
399
433
 
400
434
  Raises:
401
435
  ValueError: If the introspection query fails due to an invalid schema
@@ -405,3 +439,6 @@ class Schema(BaseSchema):
405
439
  raise ValueError(f"Invalid Schema. Errors {introspection.errors!r}")
406
440
 
407
441
  return introspection.data
442
+
443
+
444
+ __all__ = ["Schema"]
@@ -44,9 +44,6 @@ from graphql import (
44
44
  from graphql.language.directive_locations import DirectiveLocation
45
45
 
46
46
  from strawberry.annotation import StrawberryAnnotation
47
- from strawberry.arguments import StrawberryArgument, convert_arguments
48
- from strawberry.custom_scalar import ScalarWrapper
49
- from strawberry.enum import EnumDefinition
50
47
  from strawberry.exceptions import (
51
48
  DuplicatedTypeName,
52
49
  InvalidTypeInputForUnion,
@@ -55,21 +52,24 @@ from strawberry.exceptions import (
55
52
  ScalarAlreadyRegisteredError,
56
53
  UnresolvedFieldTypeError,
57
54
  )
58
- from strawberry.field import UNRESOLVED
59
- from strawberry.lazy_type import LazyType
60
- from strawberry.private import is_private
61
55
  from strawberry.schema.types.scalar import _make_scalar_type
62
- from strawberry.type import (
56
+ from strawberry.types.arguments import StrawberryArgument, convert_arguments
57
+ from strawberry.types.base import (
63
58
  StrawberryList,
59
+ StrawberryObjectDefinition,
64
60
  StrawberryOptional,
65
61
  StrawberryType,
66
62
  get_object_definition,
67
63
  has_object_definition,
68
64
  )
65
+ from strawberry.types.enum import EnumDefinition
66
+ from strawberry.types.field import UNRESOLVED
69
67
  from strawberry.types.info import Info
70
- from strawberry.types.types import StrawberryObjectDefinition
71
- from strawberry.union import StrawberryUnion
72
- from strawberry.unset import UNSET
68
+ from strawberry.types.lazy_type import LazyType
69
+ from strawberry.types.private import is_private
70
+ from strawberry.types.scalar import ScalarWrapper
71
+ from strawberry.types.union import StrawberryUnion
72
+ from strawberry.types.unset import UNSET
73
73
  from strawberry.utils.await_maybe import await_maybe
74
74
 
75
75
  from ..extensions.field_extension import build_field_extension_resolvers
@@ -85,12 +85,12 @@ if TYPE_CHECKING:
85
85
  GraphQLScalarType,
86
86
  )
87
87
 
88
- from strawberry.custom_scalar import ScalarDefinition
89
88
  from strawberry.directive import StrawberryDirective
90
- from strawberry.enum import EnumValue
91
- from strawberry.field import StrawberryField
92
89
  from strawberry.schema.config import StrawberryConfig
93
90
  from strawberry.schema_directive import StrawberrySchemaDirective
91
+ from strawberry.types.enum import EnumValue
92
+ from strawberry.types.field import StrawberryField
93
+ from strawberry.types.scalar import ScalarDefinition
94
94
 
95
95
 
96
96
  FieldType = TypeVar(
@@ -681,7 +681,6 @@ class GraphQLCoreConverter:
681
681
 
682
682
  def wrap_field_extensions() -> Callable[..., Any]:
683
683
  """Wrap the provided field resolver with the middleware."""
684
-
685
684
  for extension in field.extensions:
686
685
  extension.apply(field)
687
686
 
@@ -999,3 +998,6 @@ class GraphQLCoreConverter:
999
998
  second_origin = None
1000
999
 
1001
1000
  raise DuplicatedTypeName(first_origin, second_origin, name)
1001
+
1002
+
1003
+ __all__ = ["GraphQLCoreConverter"]
@@ -7,7 +7,7 @@ from typing import Callable
7
7
  import dateutil.parser
8
8
  from graphql import GraphQLError
9
9
 
10
- from strawberry.custom_scalar import scalar
10
+ from strawberry.types.scalar import scalar
11
11
 
12
12
 
13
13
  def wrap_parser(parser: Callable, type_: str) -> Callable:
@@ -80,3 +80,5 @@ Void = scalar(
80
80
  parse_value=_verify_void,
81
81
  description="Represents NULL values",
82
82
  )
83
+
84
+ __all__ = ["Date", "DateTime", "Time", "Decimal", "UUID", "Void"]
@@ -6,10 +6,10 @@ from typing import TYPE_CHECKING, Dict, Union
6
6
  from graphql import GraphQLField, GraphQLInputField, GraphQLType
7
7
 
8
8
  if TYPE_CHECKING:
9
- from strawberry.custom_scalar import ScalarDefinition
10
- from strawberry.enum import EnumDefinition
11
- from strawberry.types.types import StrawberryObjectDefinition
12
- from strawberry.union import StrawberryUnion
9
+ from strawberry.types.base import StrawberryObjectDefinition
10
+ from strawberry.types.enum import EnumDefinition
11
+ from strawberry.types.scalar import ScalarDefinition
12
+ from strawberry.types.union import StrawberryUnion
13
13
 
14
14
  Field = Union[GraphQLInputField, GraphQLField]
15
15
 
@@ -12,11 +12,11 @@ from graphql import (
12
12
  GraphQLString,
13
13
  )
14
14
 
15
- from strawberry.custom_scalar import ScalarDefinition, scalar
16
15
  from strawberry.file_uploads.scalars import Upload
17
16
  from strawberry.relay.types import GlobalID
18
17
  from strawberry.scalars import ID
19
18
  from strawberry.schema.types import base_scalars
19
+ from strawberry.types.scalar import ScalarDefinition, scalar
20
20
 
21
21
 
22
22
  def _make_scalar_type(definition: ScalarDefinition) -> GraphQLScalarType:
@@ -78,3 +78,10 @@ DEFAULT_SCALAR_REGISTRY: Dict[object, ScalarDefinition] = {
78
78
  )
79
79
  ),
80
80
  }
81
+
82
+ __all__ = [
83
+ "DEFAULT_SCALAR_REGISTRY",
84
+ "_get_scalar_definition",
85
+ "_make_scalar_definition",
86
+ "_make_scalar_type",
87
+ ]
@@ -78,3 +78,6 @@ class OneOfInputValidationRule(ValidationRule):
78
78
  nodes=[node],
79
79
  )
80
80
  )
81
+
82
+
83
+ __all__ = ["OneOfInputValidationRule"]
@@ -802,3 +802,6 @@ def codegen(schema: str) -> str:
802
802
  module = cst.Module(body=body) # type: ignore
803
803
 
804
804
  return module.code
805
+
806
+
807
+ __all__ = ["codegen"]
@@ -3,11 +3,11 @@ from enum import Enum
3
3
  from typing import Callable, List, Optional, Type, TypeVar
4
4
  from typing_extensions import dataclass_transform
5
5
 
6
- from strawberry.object_type import _wrap_dataclass
6
+ from strawberry.types.field import StrawberryField, field
7
+ from strawberry.types.object_type import _wrap_dataclass
7
8
  from strawberry.types.type_resolver import _get_fields
8
9
 
9
10
  from .directive import directive_field
10
- from .field import StrawberryField, field
11
11
 
12
12
 
13
13
  class Location(Enum):
@@ -382,3 +382,6 @@ def make_graphql_controller(
382
382
  )
383
383
 
384
384
  return GraphQLController
385
+
386
+
387
+ __all__ = ["make_graphql_controller"]
File without changes
@@ -54,3 +54,6 @@ class GraphQLTransportWSHandler(BaseGraphQLTransportWSHandler):
54
54
  pass
55
55
  finally:
56
56
  await self.shutdown()
57
+
58
+
59
+ __all__ = ["GraphQLTransportWSHandler"]
@@ -59,3 +59,6 @@ class GraphQLWSHandler(BaseGraphQLWSHandler):
59
59
 
60
60
  for operation_id in list(self.subscriptions.keys()):
61
61
  await self.cleanup_operation(operation_id)
62
+
63
+
64
+ __all__ = ["GraphQLWSHandler"]
@@ -1,2 +1,8 @@
1
1
  GRAPHQL_TRANSPORT_WS_PROTOCOL = "graphql-transport-ws"
2
2
  GRAPHQL_WS_PROTOCOL = "graphql-ws"
3
+
4
+
5
+ __all__ = [
6
+ "GRAPHQL_TRANSPORT_WS_PROTOCOL",
7
+ "GRAPHQL_WS_PROTOCOL",
8
+ ]
@@ -1,2 +1,7 @@
1
1
  # Code 4406 is "Subprotocol not acceptable"
2
2
  WS_4406_PROTOCOL_NOT_ACCEPTABLE = 4406
3
+
4
+
5
+ __all__ = [
6
+ "WS_4406_PROTOCOL_NOT_ACCEPTABLE",
7
+ ]
@@ -30,7 +30,7 @@ from strawberry.subscriptions.protocols.graphql_transport_ws.types import (
30
30
  SubscribeMessagePayload,
31
31
  )
32
32
  from strawberry.types.graphql import OperationType
33
- from strawberry.unset import UNSET
33
+ from strawberry.types.unset import UNSET
34
34
  from strawberry.utils.debug import pretty_print_graphql_operation
35
35
  from strawberry.utils.operation import get_operation_type
36
36
 
@@ -66,23 +66,23 @@ class BaseGraphQLTransportWSHandler(ABC):
66
66
 
67
67
  @abstractmethod
68
68
  async def get_context(self) -> Any:
69
- """Return the operations context"""
69
+ """Return the operations context."""
70
70
 
71
71
  @abstractmethod
72
72
  async def get_root_value(self) -> Any:
73
- """Return the schemas root value"""
73
+ """Return the schemas root value."""
74
74
 
75
75
  @abstractmethod
76
76
  async def send_json(self, data: dict) -> None:
77
- """Send the data JSON encoded to the WebSocket client"""
77
+ """Send the data JSON encoded to the WebSocket client."""
78
78
 
79
79
  @abstractmethod
80
80
  async def close(self, code: int, reason: str) -> None:
81
- """Close the WebSocket with the passed code and reason"""
81
+ """Close the WebSocket with the passed code and reason."""
82
82
 
83
83
  @abstractmethod
84
84
  async def handle_request(self) -> Any:
85
- """Handle the request this instance was created for"""
85
+ """Handle the request this instance was created for."""
86
86
 
87
87
  async def handle(self) -> Any:
88
88
  return await self.handle_request()
@@ -286,10 +286,7 @@ class BaseGraphQLTransportWSHandler(ABC):
286
286
  async def operation_task(
287
287
  self, result_source: AsyncGenerator, operation: Operation
288
288
  ) -> None:
289
- """
290
- Operation task top level method. Cleans up and de-registers the operation
291
- once it is done.
292
- """
289
+ """The operation task's top level method. Cleans-up and de-registers the operation once it is done."""
293
290
  # TODO: Handle errors in this method using self.handle_task_exception()
294
291
  try:
295
292
  await self.handle_async_results(result_source, operation)
@@ -371,9 +368,7 @@ class BaseGraphQLTransportWSHandler(ABC):
371
368
  # websocket handler Task.
372
369
 
373
370
  async def reap_completed_tasks(self) -> None:
374
- """
375
- Await tasks that have completed
376
- """
371
+ """Await tasks that have completed."""
377
372
  tasks, self.completed_tasks = self.completed_tasks, []
378
373
  for task in tasks:
379
374
  with suppress(BaseException):
@@ -381,10 +376,7 @@ class BaseGraphQLTransportWSHandler(ABC):
381
376
 
382
377
 
383
378
  class Operation:
384
- """
385
- A class encapsulating a single operation with its id.
386
- Helps enforce protocol state transition.
387
- """
379
+ """A class encapsulating a single operation with its id. Helps enforce protocol state transition."""
388
380
 
389
381
  __slots__ = ["handler", "id", "operation_type", "completed", "task"]
390
382
 
@@ -408,3 +400,6 @@ class Operation:
408
400
  # de-register the operation _before_ sending the final message
409
401
  self.handler.forget_id(self.id)
410
402
  await self.handler.send_message(message)
403
+
404
+
405
+ __all__ = ["BaseGraphQLTransportWSHandler", "Operation"]