strawberry-graphql 0.289.0__py3-none-any.whl → 0.289.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/execution/__init__.py +5 -0
- strawberry/execution/is_awaitable.py +59 -0
- strawberry/schema/schema.py +3 -0
- strawberry/types/lazy_type.py +10 -1
- {strawberry_graphql-0.289.0.dist-info → strawberry_graphql-0.289.2.dist-info}/METADATA +1 -1
- {strawberry_graphql-0.289.0.dist-info → strawberry_graphql-0.289.2.dist-info}/RECORD +9 -7
- {strawberry_graphql-0.289.0.dist-info → strawberry_graphql-0.289.2.dist-info}/WHEEL +1 -1
- {strawberry_graphql-0.289.0.dist-info → strawberry_graphql-0.289.2.dist-info}/entry_points.txt +0 -0
- {strawberry_graphql-0.289.0.dist-info → strawberry_graphql-0.289.2.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"""Optimized is_awaitable implementation for GraphQL execution.
|
|
2
|
+
|
|
3
|
+
This module provides a highly optimized is_awaitable function that adds a fast path
|
|
4
|
+
for common synchronous types, significantly improving performance when dealing with
|
|
5
|
+
large result sets containing primitive values.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from typing import Any
|
|
11
|
+
|
|
12
|
+
from graphql.pyutils.is_awaitable import is_awaitable as graphql_core_is_awaitable
|
|
13
|
+
|
|
14
|
+
__all__ = ["optimized_is_awaitable"]
|
|
15
|
+
|
|
16
|
+
# Common synchronous types that are never awaitable
|
|
17
|
+
# Using a frozenset for O(1) lookup
|
|
18
|
+
_NON_AWAITABLE_TYPES: frozenset[type] = frozenset(
|
|
19
|
+
{
|
|
20
|
+
type(None),
|
|
21
|
+
bool,
|
|
22
|
+
int,
|
|
23
|
+
float,
|
|
24
|
+
str,
|
|
25
|
+
bytes,
|
|
26
|
+
bytearray,
|
|
27
|
+
list,
|
|
28
|
+
tuple,
|
|
29
|
+
dict,
|
|
30
|
+
set,
|
|
31
|
+
frozenset,
|
|
32
|
+
}
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def optimized_is_awaitable(value: Any) -> bool:
|
|
37
|
+
"""Return true if object can be passed to an ``await`` expression.
|
|
38
|
+
|
|
39
|
+
This is an optimized version of graphql-core's is_awaitable that adds a fast path
|
|
40
|
+
for common synchronous types. For large result sets containing mostly primitive
|
|
41
|
+
values (ints, strings, lists, etc.), this can provide significant performance
|
|
42
|
+
improvements.
|
|
43
|
+
|
|
44
|
+
Performance characteristics:
|
|
45
|
+
- Fast path for primitives: O(1) type lookup
|
|
46
|
+
- Falls back to graphql-core's is_awaitable for other types
|
|
47
|
+
|
|
48
|
+
Args:
|
|
49
|
+
value: The value to check
|
|
50
|
+
|
|
51
|
+
Returns:
|
|
52
|
+
True if the value is awaitable, False otherwise
|
|
53
|
+
"""
|
|
54
|
+
# Fast path: check if the type is a known non-awaitable type
|
|
55
|
+
if type(value) in _NON_AWAITABLE_TYPES:
|
|
56
|
+
return False
|
|
57
|
+
|
|
58
|
+
# Fallback to graphql-core's implementation for other types
|
|
59
|
+
return graphql_core_is_awaitable(value)
|
strawberry/schema/schema.py
CHANGED
|
@@ -39,6 +39,7 @@ from graphql.validation import validate
|
|
|
39
39
|
from strawberry import relay
|
|
40
40
|
from strawberry.annotation import StrawberryAnnotation
|
|
41
41
|
from strawberry.exceptions import MissingQueryError
|
|
42
|
+
from strawberry.execution import optimized_is_awaitable
|
|
42
43
|
from strawberry.extensions import SchemaExtension
|
|
43
44
|
from strawberry.extensions.directives import (
|
|
44
45
|
DirectivesExtension,
|
|
@@ -617,6 +618,7 @@ class Schema(BaseSchema):
|
|
|
617
618
|
operation_name=execution_context.operation_name,
|
|
618
619
|
context_value=execution_context.context,
|
|
619
620
|
execution_context_class=self.execution_context_class,
|
|
621
|
+
is_awaitable=optimized_is_awaitable,
|
|
620
622
|
**custom_context_kwargs,
|
|
621
623
|
)
|
|
622
624
|
)
|
|
@@ -752,6 +754,7 @@ class Schema(BaseSchema):
|
|
|
752
754
|
operation_name=execution_context.operation_name,
|
|
753
755
|
context_value=execution_context.context,
|
|
754
756
|
execution_context_class=self.execution_context_class,
|
|
757
|
+
is_awaitable=optimized_is_awaitable,
|
|
755
758
|
**custom_context_kwargs,
|
|
756
759
|
)
|
|
757
760
|
|
strawberry/types/lazy_type.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import importlib
|
|
2
|
+
import importlib.util
|
|
2
3
|
import inspect
|
|
3
4
|
import sys
|
|
4
5
|
import warnings
|
|
@@ -60,12 +61,19 @@ class LazyType(Generic[TypeName, Module]):
|
|
|
60
61
|
|
|
61
62
|
def resolve_type(self) -> type[Any]:
|
|
62
63
|
module = importlib.import_module(self.module, self.package)
|
|
64
|
+
|
|
65
|
+
# Resolve full module name for __main__ comparison
|
|
66
|
+
if self.package:
|
|
67
|
+
full_module_name = importlib.util.resolve_name(self.module, self.package)
|
|
68
|
+
else:
|
|
69
|
+
full_module_name = self.module
|
|
70
|
+
|
|
63
71
|
main_module = sys.modules.get("__main__", None)
|
|
64
72
|
if main_module:
|
|
65
73
|
# If lazy type points to the main module, use it instead of the imported
|
|
66
74
|
# module. Otherwise duplication checks during schema-conversion might fail.
|
|
67
75
|
# Refer to: https://github.com/strawberry-graphql/strawberry/issues/2397
|
|
68
|
-
if main_module.__spec__ and main_module.__spec__.name ==
|
|
76
|
+
if main_module.__spec__ and main_module.__spec__.name == full_module_name:
|
|
69
77
|
module = main_module
|
|
70
78
|
elif hasattr(main_module, "__file__") and hasattr(module, "__file__"):
|
|
71
79
|
main_file = main_module.__file__
|
|
@@ -78,6 +86,7 @@ class LazyType(Generic[TypeName, Module]):
|
|
|
78
86
|
# path contains `strawberry.exe`
|
|
79
87
|
is_samefile = False
|
|
80
88
|
module = main_module if is_samefile else module
|
|
89
|
+
|
|
81
90
|
return module.__dict__[self.type_name]
|
|
82
91
|
|
|
83
92
|
# this empty call method allows LazyTypes to be used in generic types
|
|
@@ -76,6 +76,8 @@ strawberry/exceptions/syntax.py,sha256=A8_qoYI-PEYCpxBCzrvDOrZOdz96rvh8Q4vxGgvtV
|
|
|
76
76
|
strawberry/exceptions/unresolved_field_type.py,sha256=TZvJ_6Dg0IMhDE8IFx9ENLS5MR7m8u0R11MaOchX9xo,1864
|
|
77
77
|
strawberry/exceptions/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
78
78
|
strawberry/exceptions/utils/source_finder.py,sha256=PPgNivWC8M-Fj-Y-ZiAgOd3HD4kl3D6igdkuoyqAAdA,22487
|
|
79
|
+
strawberry/execution/__init__.py,sha256=DIWjV8COzSgVsingGeef-nZ6K8sJPGDrhhUqFpeOokE,138
|
|
80
|
+
strawberry/execution/is_awaitable.py,sha256=vOPp7x6Y8K3b0w_wuIhr7SFU7_b5Prl_u3uwB1kwWBM,1705
|
|
79
81
|
strawberry/experimental/__init__.py,sha256=2HP5XtxL8ZKsPp4EDRAbMCqiP7p2V4Cca278JUGxnt0,102
|
|
80
82
|
strawberry/experimental/pydantic/__init__.py,sha256=UpO8wHNXGpoCYp34YStViInO1tsrGsMyhTVubTpJY7Y,255
|
|
81
83
|
strawberry/experimental/pydantic/_compat.py,sha256=7dJWzQ5Hs7mD0pSLbJdZvW0l3cROQjsu__GBqKmv_hk,9753
|
|
@@ -176,7 +178,7 @@ strawberry/schema/compat.py,sha256=ui3ZsRRo86PgtUxBHbjNF2tqqrPA9eUW-sFY8itGuvc,1
|
|
|
176
178
|
strawberry/schema/config.py,sha256=1i80WOoml_9qzOV-kfcx-LYMXYwWYl0uisdcZX1vMEg,2330
|
|
177
179
|
strawberry/schema/exceptions.py,sha256=SaEWtahVAg_f43coyg2h7H2UMZP10CZ_GJg72khBIAs,1105
|
|
178
180
|
strawberry/schema/name_converter.py,sha256=G3yOj-BmZ6E0bcvvSbb2cWu8ngsXi8M6W0c6rKROMjc,6933
|
|
179
|
-
strawberry/schema/schema.py,sha256=
|
|
181
|
+
strawberry/schema/schema.py,sha256=FKtqHGrOCnYMWhMwy1qWU_VXtw2IxyjpZZScL4PmVlg,39606
|
|
180
182
|
strawberry/schema/schema_converter.py,sha256=nzTZIOyIwe9jCX66ZT7m7vm8UzpcUs-AW25XWnZC9J0,40791
|
|
181
183
|
strawberry/schema/types/__init__.py,sha256=oHO3COWhL3L1KLYCJNY1XFf5xt2GGtHiMC-UaYbFfnA,68
|
|
182
184
|
strawberry/schema/types/base_scalars.py,sha256=ajMeN4W45AALhCnJO8MIisRb9slDZRyIl1S61LvHfSQ,2678
|
|
@@ -217,7 +219,7 @@ strawberry/types/fields/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG
|
|
|
217
219
|
strawberry/types/fields/resolver.py,sha256=sWG4nO8XpsvELna0uLU-rwKzUGiMgwHPzg8N7xRXqe4,16239
|
|
218
220
|
strawberry/types/graphql.py,sha256=gXKzawwKiow7hvoJhq5ApNJOMUCnKmvTiHaKY5CK1Lw,867
|
|
219
221
|
strawberry/types/info.py,sha256=1MTarr040KSsPPdrVx8sDHtKudEfH0LRgQ4adk_1FKA,4698
|
|
220
|
-
strawberry/types/lazy_type.py,sha256=
|
|
222
|
+
strawberry/types/lazy_type.py,sha256=Zwt_etpUp1bBfDNgWk3aamK6UUlnQGYmR8VDNYM-PoQ,5334
|
|
221
223
|
strawberry/types/maybe.py,sha256=ZBNHGDMuVcorpErPAMjJku4W3I2ygPf_3ZLw-N2O_UU,1610
|
|
222
224
|
strawberry/types/mutation.py,sha256=vcrKt1VpcS6SLl1WKfcR-NTAqfQ12LpzjwgT5Bx-U3Q,11549
|
|
223
225
|
strawberry/types/nodes.py,sha256=bM88j05rMIQ5OTS4RqKeU3kjo38MM-hA3Hrmh3IreV0,5121
|
|
@@ -238,8 +240,8 @@ strawberry/utils/logging.py,sha256=Dnivjd0ZhK_lAvjvuyCDkEWDhuURBoK9d3Kt_mIqbRg,7
|
|
|
238
240
|
strawberry/utils/operation.py,sha256=Qs3ttbuC415xEVqmJ6YsWQpJNUo8CZJq9AoMB-yV65w,1215
|
|
239
241
|
strawberry/utils/str_converters.py,sha256=-eH1Cl16IO_wrBlsGM-km4IY0IKsjhjnSNGRGOwQjVM,897
|
|
240
242
|
strawberry/utils/typing.py,sha256=eE9NeMfASeXRstbjLnQFfOPymcSX8xwg3FGw_HCp95E,11828
|
|
241
|
-
strawberry_graphql-0.289.
|
|
242
|
-
strawberry_graphql-0.289.
|
|
243
|
-
strawberry_graphql-0.289.
|
|
244
|
-
strawberry_graphql-0.289.
|
|
245
|
-
strawberry_graphql-0.289.
|
|
243
|
+
strawberry_graphql-0.289.2.dist-info/METADATA,sha256=9wP0VKP6xd2wp6nJUSbKhuyLX7r23Ssj0rulSnjWcbo,7627
|
|
244
|
+
strawberry_graphql-0.289.2.dist-info/WHEEL,sha256=3ny-bZhpXrU6vSQ1UPG34FoxZBp3lVcvK0LkgUz6VLk,88
|
|
245
|
+
strawberry_graphql-0.289.2.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
|
|
246
|
+
strawberry_graphql-0.289.2.dist-info/licenses/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
|
|
247
|
+
strawberry_graphql-0.289.2.dist-info/RECORD,,
|
{strawberry_graphql-0.289.0.dist-info → strawberry_graphql-0.289.2.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{strawberry_graphql-0.289.0.dist-info → strawberry_graphql-0.289.2.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|