strawberry-graphql 0.263.0.dev1743582446__py3-none-any.whl → 0.263.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- strawberry/__init__.py +0 -2
- strawberry/aiohttp/views.py +1 -1
- strawberry/annotation.py +9 -13
- strawberry/asgi/__init__.py +1 -1
- strawberry/chalice/views.py +2 -2
- strawberry/channels/handlers/http_handler.py +4 -2
- strawberry/cli/commands/codegen.py +1 -1
- strawberry/codegen/query_codegen.py +6 -6
- strawberry/django/views.py +2 -2
- strawberry/exceptions/handler.py +1 -1
- strawberry/experimental/pydantic/_compat.py +34 -4
- strawberry/experimental/pydantic/conversion.py +1 -1
- strawberry/experimental/pydantic/error_type.py +1 -1
- strawberry/experimental/pydantic/object_type.py +7 -3
- strawberry/experimental/pydantic/utils.py +8 -2
- strawberry/ext/mypy_plugin.py +3 -3
- strawberry/extensions/tracing/opentelemetry.py +2 -1
- strawberry/fastapi/router.py +1 -1
- strawberry/federation/schema.py +1 -1
- strawberry/flask/views.py +2 -2
- strawberry/http/__init__.py +4 -9
- strawberry/http/async_base_view.py +6 -82
- strawberry/litestar/controller.py +1 -1
- strawberry/printer/printer.py +9 -9
- strawberry/quart/views.py +1 -1
- strawberry/relay/exceptions.py +3 -2
- strawberry/relay/fields.py +7 -7
- strawberry/relay/types.py +31 -28
- strawberry/sanic/utils.py +2 -4
- strawberry/sanic/views.py +1 -1
- strawberry/schema/config.py +0 -1
- strawberry/schema/schema.py +23 -54
- strawberry/static/graphiql.html +5 -5
- strawberry/subscriptions/protocols/graphql_transport_ws/handlers.py +1 -1
- strawberry/subscriptions/protocols/graphql_ws/handlers.py +1 -1
- strawberry/types/arguments.py +5 -4
- strawberry/types/auto.py +1 -1
- strawberry/types/field.py +1 -1
- strawberry/types/fields/resolver.py +1 -1
- strawberry/types/lazy_type.py +1 -1
- strawberry/types/type_resolver.py +1 -1
- strawberry/types/union.py +1 -1
- strawberry/utils/aio.py +20 -1
- strawberry/utils/operation.py +1 -1
- strawberry/utils/typing.py +5 -5
- {strawberry_graphql-0.263.0.dev1743582446.dist-info → strawberry_graphql-0.263.2.dist-info}/METADATA +1 -1
- {strawberry_graphql-0.263.0.dev1743582446.dist-info → strawberry_graphql-0.263.2.dist-info}/RECORD +50 -52
- strawberry/schema/_graphql_core.py +0 -46
- strawberry/streamable.py +0 -36
- {strawberry_graphql-0.263.0.dev1743582446.dist-info → strawberry_graphql-0.263.2.dist-info}/LICENSE +0 -0
- {strawberry_graphql-0.263.0.dev1743582446.dist-info → strawberry_graphql-0.263.2.dist-info}/WHEEL +0 -0
- {strawberry_graphql-0.263.0.dev1743582446.dist-info → strawberry_graphql-0.263.2.dist-info}/entry_points.txt +0 -0
strawberry/printer/printer.py
CHANGED
@@ -151,7 +151,7 @@ def print_schema_directive(
|
|
151
151
|
directive: Any, schema: BaseSchema, *, extras: PrintExtras
|
152
152
|
) -> str:
|
153
153
|
strawberry_directive = cast(
|
154
|
-
StrawberrySchemaDirective, directive.__class__.__strawberry_directive__
|
154
|
+
"StrawberrySchemaDirective", directive.__class__.__strawberry_directive__
|
155
155
|
)
|
156
156
|
schema_converter = schema.schema_converter
|
157
157
|
gql_directive = schema_converter.from_schema_directive(directive.__class__)
|
@@ -178,13 +178,13 @@ def print_schema_directive(
|
|
178
178
|
f_type = f_type.of_type
|
179
179
|
|
180
180
|
if has_object_definition(f_type):
|
181
|
-
extras.types.add(cast(type, f_type))
|
181
|
+
extras.types.add(cast("type", f_type))
|
182
182
|
|
183
183
|
if hasattr(f_type, "_scalar_definition"):
|
184
|
-
extras.types.add(cast(type, f_type))
|
184
|
+
extras.types.add(cast("type", f_type))
|
185
185
|
|
186
186
|
if isinstance(f_type, EnumDefinition):
|
187
|
-
extras.types.add(cast(type, f_type))
|
187
|
+
extras.types.add(cast("type", f_type))
|
188
188
|
|
189
189
|
return f" @{gql_directive.name}{params}"
|
190
190
|
|
@@ -363,7 +363,7 @@ def print_extends(type_: GraphQLObjectType, schema: BaseSchema) -> str:
|
|
363
363
|
from strawberry.schema.schema_converter import GraphQLCoreConverter
|
364
364
|
|
365
365
|
strawberry_type = cast(
|
366
|
-
Optional[StrawberryObjectDefinition],
|
366
|
+
"Optional[StrawberryObjectDefinition]",
|
367
367
|
type_.extensions
|
368
368
|
and type_.extensions.get(GraphQLCoreConverter.DEFINITION_BACKREF),
|
369
369
|
)
|
@@ -380,7 +380,7 @@ def print_type_directives(
|
|
380
380
|
from strawberry.schema.schema_converter import GraphQLCoreConverter
|
381
381
|
|
382
382
|
strawberry_type = cast(
|
383
|
-
Optional[StrawberryObjectDefinition],
|
383
|
+
"Optional[StrawberryObjectDefinition]",
|
384
384
|
type_.extensions
|
385
385
|
and type_.extensions.get(GraphQLCoreConverter.DEFINITION_BACKREF),
|
386
386
|
)
|
@@ -561,9 +561,9 @@ def print_schema_definition(
|
|
561
561
|
def print_directive(
|
562
562
|
directive: GraphQLDirective, *, schema: BaseSchema
|
563
563
|
) -> Optional[str]:
|
564
|
-
strawberry_directive = directive.extensions
|
564
|
+
strawberry_directive = directive.extensions["strawberry-definition"]
|
565
565
|
|
566
|
-
if
|
566
|
+
if (
|
567
567
|
isinstance(strawberry_directive, StrawberrySchemaDirective)
|
568
568
|
and not strawberry_directive.print_definition
|
569
569
|
):
|
@@ -594,7 +594,7 @@ def is_builtin_directive(directive: GraphQLDirective) -> bool:
|
|
594
594
|
|
595
595
|
def print_schema(schema: BaseSchema) -> str:
|
596
596
|
graphql_core_schema = cast(
|
597
|
-
GraphQLSchema,
|
597
|
+
"GraphQLSchema",
|
598
598
|
schema._schema, # type: ignore
|
599
599
|
)
|
600
600
|
extras = PrintExtras()
|
strawberry/quart/views.py
CHANGED
@@ -27,7 +27,7 @@ class QuartHTTPRequestAdapter(AsyncHTTPRequestAdapter):
|
|
27
27
|
|
28
28
|
@property
|
29
29
|
def method(self) -> HTTPMethod:
|
30
|
-
return cast(HTTPMethod, self.request.method.upper())
|
30
|
+
return cast("HTTPMethod", self.request.method.upper())
|
31
31
|
|
32
32
|
@property
|
33
33
|
def content_type(self) -> Optional[str]:
|
strawberry/relay/exceptions.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
|
-
from collections.abc import Callable
|
4
3
|
from functools import cached_property
|
5
4
|
from typing import TYPE_CHECKING, Optional, cast
|
6
5
|
|
@@ -8,6 +7,8 @@ from strawberry.exceptions.exception import StrawberryException
|
|
8
7
|
from strawberry.exceptions.utils.source_finder import SourceFinder
|
9
8
|
|
10
9
|
if TYPE_CHECKING:
|
10
|
+
from collections.abc import Callable
|
11
|
+
|
11
12
|
from strawberry.exceptions.exception_source import ExceptionSource
|
12
13
|
from strawberry.types.fields.resolver import StrawberryResolver
|
13
14
|
|
@@ -101,7 +102,7 @@ class RelayWrongResolverAnnotationError(StrawberryException):
|
|
101
102
|
return None # pragma: no cover
|
102
103
|
|
103
104
|
source_finder = SourceFinder()
|
104
|
-
return source_finder.find_function_from_object(cast(Callable, self.function))
|
105
|
+
return source_finder.find_function_from_object(cast("Callable", self.function))
|
105
106
|
|
106
107
|
|
107
108
|
__all__ = [
|
strawberry/relay/fields.py
CHANGED
@@ -108,7 +108,7 @@ class NodeExtension(FieldExtension):
|
|
108
108
|
|
109
109
|
return resolve()
|
110
110
|
|
111
|
-
return cast(Node, strawberry_cast(node_type, resolved_node))
|
111
|
+
return cast("Node", strawberry_cast(node_type, resolved_node))
|
112
112
|
|
113
113
|
return resolver
|
114
114
|
|
@@ -161,7 +161,7 @@ class NodeExtension(FieldExtension):
|
|
161
161
|
# we could end up resolving to a different type in case more than one
|
162
162
|
# are registered
|
163
163
|
def cast_nodes(node_t: type[Node], nodes: Iterable[Any]) -> list[Node]:
|
164
|
-
return [cast(Node, strawberry_cast(node_t, node)) for node in nodes]
|
164
|
+
return [cast("Node", strawberry_cast(node_t, node)) for node in nodes]
|
165
165
|
|
166
166
|
if awaitable_nodes or asyncgen_nodes:
|
167
167
|
|
@@ -196,7 +196,7 @@ class NodeExtension(FieldExtension):
|
|
196
196
|
|
197
197
|
# Resolve any generator to lists
|
198
198
|
resolved = {
|
199
|
-
node_t: cast_nodes(node_t, cast(Iterable[Node], nodes))
|
199
|
+
node_t: cast_nodes(node_t, cast("Iterable[Node]", nodes))
|
200
200
|
for node_t, nodes in resolved_nodes.items()
|
201
201
|
}
|
202
202
|
return [resolved[index_map[gid][0]][index_map[gid][1]] for gid in ids]
|
@@ -264,7 +264,7 @@ class ConnectionExtension(FieldExtension):
|
|
264
264
|
type_origin = get_origin(f_type) if is_generic_alias(f_type) else f_type
|
265
265
|
|
266
266
|
if not isinstance(type_origin, type) or not issubclass(type_origin, Connection):
|
267
|
-
raise RelayWrongAnnotationError(field.name, cast(type, field.origin))
|
267
|
+
raise RelayWrongAnnotationError(field.name, cast("type", field.origin))
|
268
268
|
|
269
269
|
assert field.base_resolver
|
270
270
|
# TODO: We are not using resolver_type.type because it will call
|
@@ -294,7 +294,7 @@ class ConnectionExtension(FieldExtension):
|
|
294
294
|
):
|
295
295
|
raise RelayWrongResolverAnnotationError(field.name, field.base_resolver)
|
296
296
|
|
297
|
-
self.connection_type = cast(type[Connection[Node]], f_type)
|
297
|
+
self.connection_type = cast("type[Connection[Node]]", f_type)
|
298
298
|
|
299
299
|
def resolve(
|
300
300
|
self,
|
@@ -310,7 +310,7 @@ class ConnectionExtension(FieldExtension):
|
|
310
310
|
) -> Any:
|
311
311
|
assert self.connection_type is not None
|
312
312
|
return self.connection_type.resolve_connection(
|
313
|
-
cast(Iterable[Node], next_(source, info, **kwargs)),
|
313
|
+
cast("Iterable[Node]", next_(source, info, **kwargs)),
|
314
314
|
info=info,
|
315
315
|
before=before,
|
316
316
|
after=after,
|
@@ -339,7 +339,7 @@ class ConnectionExtension(FieldExtension):
|
|
339
339
|
nodes = await nodes
|
340
340
|
|
341
341
|
resolved = self.connection_type.resolve_connection(
|
342
|
-
cast(Iterable[Node], nodes),
|
342
|
+
cast("Iterable[Node]", nodes),
|
343
343
|
info=info,
|
344
344
|
before=before,
|
345
345
|
after=after,
|
strawberry/relay/types.py
CHANGED
@@ -39,7 +39,7 @@ from strawberry.types.lazy_type import LazyType
|
|
39
39
|
from strawberry.types.object_type import interface
|
40
40
|
from strawberry.types.object_type import type as strawberry_type
|
41
41
|
from strawberry.types.private import StrawberryPrivate
|
42
|
-
from strawberry.utils.aio import aenumerate, aislice, resolve_awaitable
|
42
|
+
from strawberry.utils.aio import aclosing, aenumerate, aislice, resolve_awaitable
|
43
43
|
from strawberry.utils.inspect import in_async_context
|
44
44
|
from strawberry.utils.typing import eval_type, is_classvar
|
45
45
|
|
@@ -188,7 +188,7 @@ class GlobalID:
|
|
188
188
|
"""
|
189
189
|
n_type = self.resolve_type(info)
|
190
190
|
node: Node | Awaitable[Node] = cast(
|
191
|
-
Awaitable[Node],
|
191
|
+
"Awaitable[Node]",
|
192
192
|
n_type.resolve_node(
|
193
193
|
self.node_id,
|
194
194
|
info=info,
|
@@ -393,7 +393,7 @@ class Node:
|
|
393
393
|
parent_type = info._raw_info.parent_type
|
394
394
|
type_def = info.schema.get_type_by_name(parent_type.name)
|
395
395
|
assert isinstance(type_def, StrawberryObjectDefinition)
|
396
|
-
origin = cast(type[Node], type_def.origin)
|
396
|
+
origin = cast("type[Node]", type_def.origin)
|
397
397
|
resolve_id = origin.resolve_id
|
398
398
|
resolve_typename = origin.resolve_typename
|
399
399
|
|
@@ -404,7 +404,7 @@ class Node:
|
|
404
404
|
|
405
405
|
if inspect.isawaitable(node_id):
|
406
406
|
return cast(
|
407
|
-
GlobalID,
|
407
|
+
"GlobalID",
|
408
408
|
resolve_awaitable(
|
409
409
|
node_id,
|
410
410
|
lambda resolved: GlobalID(
|
@@ -617,7 +617,7 @@ class Node:
|
|
617
617
|
if inspect.isawaitable(retval):
|
618
618
|
return resolve_awaitable(retval, lambda resolved: next(iter(resolved)))
|
619
619
|
|
620
|
-
return next(iter(cast(Iterable[Self], retval)))
|
620
|
+
return next(iter(cast("Iterable[Self]", retval)))
|
621
621
|
|
622
622
|
|
623
623
|
@strawberry_type(description="Information to aid in pagination.")
|
@@ -810,15 +810,15 @@ class ListConnection(Connection[NodeType]):
|
|
810
810
|
while isinstance(field, StrawberryContainer):
|
811
811
|
field = field.of_type
|
812
812
|
|
813
|
-
edge_class = cast(Edge[NodeType], field)
|
813
|
+
edge_class = cast("Edge[NodeType]", field)
|
814
814
|
|
815
815
|
if isinstance(nodes, (AsyncIterator, AsyncIterable)) and in_async_context():
|
816
816
|
|
817
817
|
async def resolver() -> Self:
|
818
818
|
try:
|
819
819
|
iterator = cast(
|
820
|
-
Union[AsyncIterator[NodeType], AsyncIterable[NodeType]],
|
821
|
-
cast(Sequence, nodes)[
|
820
|
+
"Union[AsyncIterator[NodeType], AsyncIterable[NodeType]]",
|
821
|
+
cast("Sequence", nodes)[
|
822
822
|
slice_metadata.start : slice_metadata.overfetch
|
823
823
|
],
|
824
824
|
)
|
@@ -831,24 +831,25 @@ class ListConnection(Connection[NodeType]):
|
|
831
831
|
slice_metadata.overfetch,
|
832
832
|
)
|
833
833
|
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
834
|
+
async with aclosing(iterator):
|
835
|
+
# The slice above might return an object that now is not async
|
836
|
+
# iterable anymore (e.g. an already cached django queryset)
|
837
|
+
if isinstance(iterator, (AsyncIterator, AsyncIterable)):
|
838
|
+
edges: list[Edge] = [
|
839
|
+
edge_class.resolve_edge(
|
840
|
+
cls.resolve_node(v, info=info, **kwargs),
|
841
|
+
cursor=slice_metadata.start + i,
|
842
|
+
)
|
843
|
+
async for i, v in aenumerate(iterator)
|
844
|
+
]
|
845
|
+
else:
|
846
|
+
edges: list[Edge] = [ # type: ignore[no-redef]
|
847
|
+
edge_class.resolve_edge(
|
848
|
+
cls.resolve_node(v, info=info, **kwargs),
|
849
|
+
cursor=slice_metadata.start + i,
|
850
|
+
)
|
851
|
+
for i, v in enumerate(iterator)
|
852
|
+
]
|
852
853
|
|
853
854
|
has_previous_page = slice_metadata.start > 0
|
854
855
|
if (
|
@@ -882,8 +883,10 @@ class ListConnection(Connection[NodeType]):
|
|
882
883
|
|
883
884
|
try:
|
884
885
|
iterator = cast(
|
885
|
-
Union[Iterator[NodeType], Iterable[NodeType]],
|
886
|
-
cast(Sequence, nodes)[
|
886
|
+
"Union[Iterator[NodeType], Iterable[NodeType]]",
|
887
|
+
cast("Sequence", nodes)[
|
888
|
+
slice_metadata.start : slice_metadata.overfetch
|
889
|
+
],
|
887
890
|
)
|
888
891
|
except TypeError:
|
889
892
|
assert isinstance(nodes, (Iterable, Iterator))
|
strawberry/sanic/utils.py
CHANGED
@@ -3,10 +3,8 @@ from __future__ import annotations
|
|
3
3
|
from io import BytesIO
|
4
4
|
from typing import TYPE_CHECKING, Any, Optional, Union, cast
|
5
5
|
|
6
|
-
from sanic.request import File
|
7
|
-
|
8
6
|
if TYPE_CHECKING:
|
9
|
-
from sanic.request import Request
|
7
|
+
from sanic.request import File, Request
|
10
8
|
|
11
9
|
|
12
10
|
def convert_request_to_files_dict(request: Request) -> dict[str, Any]:
|
@@ -24,7 +22,7 @@ def convert_request_to_files_dict(request: Request) -> dict[str, Any]:
|
|
24
22
|
|
25
23
|
Note that the dictionary entries are lists.
|
26
24
|
"""
|
27
|
-
request_files = cast(Optional[dict[str, list[File]]], request.files)
|
25
|
+
request_files = cast("Optional[dict[str, list[File]]]", request.files)
|
28
26
|
|
29
27
|
if not request_files:
|
30
28
|
return {}
|
strawberry/sanic/views.py
CHANGED
@@ -48,7 +48,7 @@ class SanicHTTPRequestAdapter(AsyncHTTPRequestAdapter):
|
|
48
48
|
|
49
49
|
@property
|
50
50
|
def method(self) -> HTTPMethod:
|
51
|
-
return cast(HTTPMethod, self.request.method.upper())
|
51
|
+
return cast("HTTPMethod", self.request.method.upper())
|
52
52
|
|
53
53
|
@property
|
54
54
|
def headers(self) -> Mapping[str, str]:
|
strawberry/schema/config.py
CHANGED
strawberry/schema/schema.py
CHANGED
@@ -29,6 +29,8 @@ from graphql import (
|
|
29
29
|
parse,
|
30
30
|
validate_schema,
|
31
31
|
)
|
32
|
+
from graphql.execution import ExecutionContext as GraphQLExecutionContext
|
33
|
+
from graphql.execution import execute, subscribe
|
32
34
|
from graphql.execution.middleware import MiddlewareManager
|
33
35
|
from graphql.type.directives import specified_directives
|
34
36
|
from graphql.validation import validate
|
@@ -58,18 +60,10 @@ from strawberry.types.execution import (
|
|
58
60
|
)
|
59
61
|
from strawberry.types.graphql import OperationType
|
60
62
|
from strawberry.utils import IS_GQL_32
|
63
|
+
from strawberry.utils.aio import aclosing
|
61
64
|
from strawberry.utils.await_maybe import await_maybe
|
62
65
|
|
63
66
|
from . import compat
|
64
|
-
from ._graphql_core import (
|
65
|
-
GraphQLExecutionContext,
|
66
|
-
GraphQLIncrementalExecutionResults,
|
67
|
-
ResultType,
|
68
|
-
execute,
|
69
|
-
experimental_execute_incrementally,
|
70
|
-
incremental_execution_directives,
|
71
|
-
subscribe,
|
72
|
-
)
|
73
67
|
from .base import BaseSchema
|
74
68
|
from .config import StrawberryConfig
|
75
69
|
from .exceptions import InvalidOperationTypeError
|
@@ -98,7 +92,6 @@ OriginSubscriptionResult = Union[
|
|
98
92
|
AsyncIterator[OriginalExecutionResult],
|
99
93
|
]
|
100
94
|
|
101
|
-
|
102
95
|
DEFAULT_ALLOWED_OPERATION_TYPES = {
|
103
96
|
OperationType.QUERY,
|
104
97
|
OperationType.MUTATION,
|
@@ -213,7 +206,7 @@ class Schema(BaseSchema):
|
|
213
206
|
scalar_registry: SCALAR_OVERRIDES_DICT_TYPE = {**DEFAULT_SCALAR_REGISTRY}
|
214
207
|
if scalar_overrides:
|
215
208
|
# TODO: check that the overrides are valid
|
216
|
-
scalar_registry.update(cast(SCALAR_OVERRIDES_DICT_TYPE, scalar_overrides))
|
209
|
+
scalar_registry.update(cast("SCALAR_OVERRIDES_DICT_TYPE", scalar_overrides))
|
217
210
|
|
218
211
|
self.schema_converter = GraphQLCoreConverter(
|
219
212
|
self.config, scalar_registry, self.get_fields
|
@@ -222,12 +215,14 @@ class Schema(BaseSchema):
|
|
222
215
|
self.schema_directives = list(schema_directives)
|
223
216
|
|
224
217
|
query_type = self.schema_converter.from_object(
|
225
|
-
cast(
|
218
|
+
cast(
|
219
|
+
"type[WithStrawberryObjectDefinition]", query
|
220
|
+
).__strawberry_definition__
|
226
221
|
)
|
227
222
|
mutation_type = (
|
228
223
|
self.schema_converter.from_object(
|
229
224
|
cast(
|
230
|
-
type[WithStrawberryObjectDefinition], mutation
|
225
|
+
"type[WithStrawberryObjectDefinition]", mutation
|
231
226
|
).__strawberry_definition__
|
232
227
|
)
|
233
228
|
if mutation
|
@@ -236,7 +231,7 @@ class Schema(BaseSchema):
|
|
236
231
|
subscription_type = (
|
237
232
|
self.schema_converter.from_object(
|
238
233
|
cast(
|
239
|
-
type[WithStrawberryObjectDefinition], subscription
|
234
|
+
"type[WithStrawberryObjectDefinition]", subscription
|
240
235
|
).__strawberry_definition__
|
241
236
|
)
|
242
237
|
if subscription
|
@@ -267,16 +262,11 @@ class Schema(BaseSchema):
|
|
267
262
|
graphql_types.append(graphql_type)
|
268
263
|
|
269
264
|
try:
|
270
|
-
directives = specified_directives + tuple(graphql_directives)
|
271
|
-
|
272
|
-
if self.config.enable_experimental_incremental_execution:
|
273
|
-
directives = tuple(directives) + tuple(incremental_execution_directives)
|
274
|
-
|
275
265
|
self._schema = GraphQLSchema(
|
276
266
|
query=query_type,
|
277
267
|
mutation=mutation_type,
|
278
268
|
subscription=subscription_type if subscription else None,
|
279
|
-
directives=
|
269
|
+
directives=specified_directives + tuple(graphql_directives),
|
280
270
|
types=graphql_types,
|
281
271
|
extensions={
|
282
272
|
GraphQLCoreConverter.DEFINITION_BACKREF: self,
|
@@ -454,16 +444,12 @@ class Schema(BaseSchema):
|
|
454
444
|
async def _handle_execution_result(
|
455
445
|
self,
|
456
446
|
context: ExecutionContext,
|
457
|
-
result:
|
447
|
+
result: Union[GraphQLExecutionResult, ExecutionResult],
|
458
448
|
extensions_runner: SchemaExtensionsRunner,
|
459
449
|
*,
|
460
450
|
# TODO: can we remove this somehow, see comment in execute
|
461
451
|
skip_process_errors: bool = False,
|
462
452
|
) -> ExecutionResult:
|
463
|
-
# TODO: handle this, also, why do we have both GraphQLExecutionResult and ExecutionResult?
|
464
|
-
if isinstance(result, GraphQLIncrementalExecutionResults):
|
465
|
-
return result
|
466
|
-
|
467
453
|
# Set errors on the context so that it's easier
|
468
454
|
# to access in extensions
|
469
455
|
if result.errors:
|
@@ -504,14 +490,6 @@ class Schema(BaseSchema):
|
|
504
490
|
extensions_runner = self.create_extensions_runner(execution_context, extensions)
|
505
491
|
middleware_manager = self._get_middleware_manager(extensions)
|
506
492
|
|
507
|
-
execute_function = (
|
508
|
-
experimental_execute_incrementally
|
509
|
-
if self.config.enable_experimental_incremental_execution
|
510
|
-
else execute
|
511
|
-
)
|
512
|
-
|
513
|
-
# TODO: raise if experimental_execute_incrementally is not available
|
514
|
-
|
515
493
|
try:
|
516
494
|
async with extensions_runner.operation():
|
517
495
|
# Note: In graphql-core the schema would be validated here but in
|
@@ -530,7 +508,7 @@ class Schema(BaseSchema):
|
|
530
508
|
async with extensions_runner.executing():
|
531
509
|
if not execution_context.result:
|
532
510
|
result = await await_maybe(
|
533
|
-
|
511
|
+
execute(
|
534
512
|
self._schema,
|
535
513
|
execution_context.graphql_document,
|
536
514
|
root_value=execution_context.root_value,
|
@@ -546,9 +524,7 @@ class Schema(BaseSchema):
|
|
546
524
|
result = execution_context.result
|
547
525
|
# Also set errors on the execution_context so that it's easier
|
548
526
|
# to access in extensions
|
549
|
-
|
550
|
-
# TODO: maybe here use the first result from incremental execution if it exists
|
551
|
-
if isinstance(result, GraphQLExecutionResult) and result.errors:
|
527
|
+
if result.errors:
|
552
528
|
execution_context.errors = result.errors
|
553
529
|
|
554
530
|
# Run the `Schema.process_errors` function here before
|
@@ -598,14 +574,6 @@ class Schema(BaseSchema):
|
|
598
574
|
extensions_runner = self.create_extensions_runner(execution_context, extensions)
|
599
575
|
middleware_manager = self._get_middleware_manager(extensions)
|
600
576
|
|
601
|
-
execute_function = (
|
602
|
-
experimental_execute_incrementally
|
603
|
-
if self.config.enable_experimental_incremental_execution
|
604
|
-
else execute
|
605
|
-
)
|
606
|
-
|
607
|
-
# TODO: raise if experimental_execute_incrementally is not available
|
608
|
-
|
609
577
|
try:
|
610
578
|
with extensions_runner.operation():
|
611
579
|
# Note: In graphql-core the schema would be validated here but in
|
@@ -647,7 +615,7 @@ class Schema(BaseSchema):
|
|
647
615
|
|
648
616
|
with extensions_runner.executing():
|
649
617
|
if not execution_context.result:
|
650
|
-
result =
|
618
|
+
result = execute(
|
651
619
|
self._schema,
|
652
620
|
execution_context.graphql_document,
|
653
621
|
root_value=execution_context.root_value,
|
@@ -659,13 +627,13 @@ class Schema(BaseSchema):
|
|
659
627
|
)
|
660
628
|
|
661
629
|
if isawaitable(result):
|
662
|
-
result = cast(Awaitable[GraphQLExecutionResult], result) # type: ignore[redundant-cast]
|
630
|
+
result = cast("Awaitable[GraphQLExecutionResult]", result) # type: ignore[redundant-cast]
|
663
631
|
ensure_future(result).cancel()
|
664
632
|
raise RuntimeError( # noqa: TRY301
|
665
633
|
"GraphQL execution failed to complete synchronously."
|
666
634
|
)
|
667
635
|
|
668
|
-
result = cast(GraphQLExecutionResult, result) # type: ignore[redundant-cast]
|
636
|
+
result = cast("GraphQLExecutionResult", result) # type: ignore[redundant-cast]
|
669
637
|
execution_context.result = result
|
670
638
|
# Also set errors on the context so that it's easier
|
671
639
|
# to access in extensions
|
@@ -748,12 +716,13 @@ class Schema(BaseSchema):
|
|
748
716
|
)
|
749
717
|
else:
|
750
718
|
try:
|
751
|
-
async
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
719
|
+
async with aclosing(aiter_or_result):
|
720
|
+
async for result in aiter_or_result:
|
721
|
+
yield await self._handle_execution_result(
|
722
|
+
execution_context,
|
723
|
+
result,
|
724
|
+
extensions_runner,
|
725
|
+
)
|
757
726
|
# graphql-core doesn't handle exceptions raised while executing.
|
758
727
|
except Exception as exc: # noqa: BLE001
|
759
728
|
yield await self._handle_execution_result(
|
strawberry/static/graphiql.html
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
<!
|
1
|
+
<!DOCTYPE html>
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<title>Strawberry GraphiQL</title>
|
@@ -61,8 +61,8 @@
|
|
61
61
|
<link
|
62
62
|
crossorigin
|
63
63
|
rel="stylesheet"
|
64
|
-
href="https://unpkg.com/graphiql@3.
|
65
|
-
integrity="sha384-
|
64
|
+
href="https://unpkg.com/graphiql@3.0.9/graphiql.min.css"
|
65
|
+
integrity="sha384-yz3/sqpuplkA7msMo0FE4ekg0xdwdvZ8JX9MVZREsxipqjU4h8IRfmAMRcb1QpUy"
|
66
66
|
/>
|
67
67
|
|
68
68
|
<link
|
@@ -77,8 +77,8 @@
|
|
77
77
|
<div id="graphiql" class="graphiql-container">Loading...</div>
|
78
78
|
<script
|
79
79
|
crossorigin
|
80
|
-
src="https://unpkg.com/graphiql@3.
|
81
|
-
integrity="sha384-
|
80
|
+
src="https://unpkg.com/graphiql@3.0.9/graphiql.min.js"
|
81
|
+
integrity="sha384-Mjte+vxCWz1ZYCzszGHiJqJa5eAxiqI4mc3BErq7eDXnt+UGLXSEW7+i0wmfPiji"
|
82
82
|
></script>
|
83
83
|
<script
|
84
84
|
crossorigin
|
@@ -77,7 +77,7 @@ class BaseGraphQLTransportWSHandler(Generic[Context, RootValue]):
|
|
77
77
|
try:
|
78
78
|
try:
|
79
79
|
async for message in self.websocket.iter_json():
|
80
|
-
await self.handle_message(cast(Message, message))
|
80
|
+
await self.handle_message(cast("Message", message))
|
81
81
|
except NonTextMessageReceived:
|
82
82
|
await self.handle_invalid_message("WebSocket message type must be text")
|
83
83
|
except NonJsonMessageReceived:
|
@@ -65,7 +65,7 @@ class BaseGraphQLWSHandler(Generic[Context, RootValue]):
|
|
65
65
|
async for message in self.websocket.iter_json(
|
66
66
|
ignore_parsing_errors=True
|
67
67
|
):
|
68
|
-
await self.handle_message(cast(OperationMessage, message))
|
68
|
+
await self.handle_message(cast("OperationMessage", message))
|
69
69
|
except NonTextMessageReceived:
|
70
70
|
await self.websocket.close(
|
71
71
|
code=1002, reason="WebSocket message type must be text"
|
strawberry/types/arguments.py
CHANGED
@@ -2,7 +2,6 @@ from __future__ import annotations
|
|
2
2
|
|
3
3
|
import inspect
|
4
4
|
import warnings
|
5
|
-
from collections.abc import Iterable, Mapping
|
6
5
|
from typing import (
|
7
6
|
TYPE_CHECKING,
|
8
7
|
Annotated,
|
@@ -27,6 +26,8 @@ from strawberry.types.unset import UNSET as _deprecated_UNSET # noqa: N811
|
|
27
26
|
from strawberry.types.unset import _deprecated_is_unset # noqa: F401
|
28
27
|
|
29
28
|
if TYPE_CHECKING:
|
29
|
+
from collections.abc import Iterable, Mapping
|
30
|
+
|
30
31
|
from strawberry.schema.config import StrawberryConfig
|
31
32
|
from strawberry.types.base import StrawberryType
|
32
33
|
from strawberry.types.scalar import ScalarDefinition, ScalarWrapper
|
@@ -153,7 +154,7 @@ def convert_argument(
|
|
153
154
|
return convert_argument(value, type_.of_type, scalar_registry, config)
|
154
155
|
|
155
156
|
if isinstance(type_, StrawberryList):
|
156
|
-
value_list = cast(Iterable, value)
|
157
|
+
value_list = cast("Iterable", value)
|
157
158
|
return [
|
158
159
|
convert_argument(x, type_.of_type, scalar_registry, config)
|
159
160
|
for x in value_list
|
@@ -177,7 +178,7 @@ def convert_argument(
|
|
177
178
|
|
178
179
|
type_definition = type_.__strawberry_definition__
|
179
180
|
for field in type_definition.fields:
|
180
|
-
value = cast(Mapping, value)
|
181
|
+
value = cast("Mapping", value)
|
181
182
|
graphql_name = config.name_converter.from_field(field)
|
182
183
|
|
183
184
|
if graphql_name in value:
|
@@ -188,7 +189,7 @@ def convert_argument(
|
|
188
189
|
config,
|
189
190
|
)
|
190
191
|
|
191
|
-
type_ = cast(type, type_)
|
192
|
+
type_ = cast("type", type_)
|
192
193
|
return type_(**kwargs)
|
193
194
|
|
194
195
|
raise UnsupportedTypeError(type_)
|
strawberry/types/auto.py
CHANGED
strawberry/types/field.py
CHANGED
@@ -369,7 +369,7 @@ class StrawberryField(dataclasses.Field):
|
|
369
369
|
# If the field is still generic, try to resolve it from the type_definition
|
370
370
|
# that is asking for it.
|
371
371
|
if (
|
372
|
-
_is_generic(cast(Union[StrawberryType, type], resolved))
|
372
|
+
_is_generic(cast("Union[StrawberryType, type]", resolved))
|
373
373
|
and type_definition is not None
|
374
374
|
and type_definition.type_var_map
|
375
375
|
and isinstance(resolved, StrawberryType)
|
@@ -147,7 +147,7 @@ class ReservedType(NamedTuple):
|
|
147
147
|
return None
|
148
148
|
|
149
149
|
def is_reserved_type(self, other: builtins.type) -> bool:
|
150
|
-
origin = cast(type, get_origin(other)) or other
|
150
|
+
origin = cast("type", get_origin(other)) or other
|
151
151
|
if origin is Annotated:
|
152
152
|
# Handle annotated arguments such as Private[str] and DirectiveValue[str]
|
153
153
|
return type_has_annotation(other, self.type)
|
strawberry/types/lazy_type.py
CHANGED
@@ -105,7 +105,7 @@ class StrawberryLazyReference:
|
|
105
105
|
frame = sys._getframe(2)
|
106
106
|
# TODO: raise a nice error if frame is None
|
107
107
|
assert frame is not None
|
108
|
-
self.package = cast(str, frame.f_globals["__package__"])
|
108
|
+
self.package = cast("str", frame.f_globals["__package__"])
|
109
109
|
|
110
110
|
def resolve_forward_ref(self, forward_ref: ForwardRef) -> LazyType:
|
111
111
|
return LazyType(forward_ref.__forward_arg__, self.module, self.package)
|
@@ -71,7 +71,7 @@ def _get_fields(
|
|
71
71
|
# Find the class the each field was originally defined on so we can use
|
72
72
|
# that scope later when resolving the type, as it may have different names
|
73
73
|
# available to it.
|
74
|
-
origins: dict[str, type] =
|
74
|
+
origins: dict[str, type] = dict.fromkeys(cls.__annotations__, cls)
|
75
75
|
|
76
76
|
for base in cls.__mro__:
|
77
77
|
if has_object_definition(base):
|