strawberry-graphql 0.248.0__py3-none-any.whl → 0.249.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.
@@ -111,15 +111,17 @@ class GraphQLWebsocketCommunicator(WebsocketCommunicator):
111
111
  await self.send_json_to(
112
112
  ConnectionInitMessage(payload=self.connection_params).as_dict()
113
113
  )
114
- response = await self.receive_json_from()
115
- assert response == ConnectionAckMessage().as_dict()
114
+ graphql_transport_ws_response = await self.receive_json_from()
115
+ assert graphql_transport_ws_response == ConnectionAckMessage().as_dict()
116
116
  else:
117
117
  assert res == (True, GRAPHQL_WS_PROTOCOL)
118
118
  await self.send_json_to(
119
119
  GraphQLWSConnectionInitMessage({"type": "connection_init"})
120
120
  )
121
- response: GraphQLWSConnectionAckMessage = await self.receive_json_from()
122
- assert response["type"] == "connection_ack"
121
+ graphql_ws_response: GraphQLWSConnectionAckMessage = (
122
+ await self.receive_json_from()
123
+ )
124
+ assert graphql_ws_response["type"] == "connection_ack"
123
125
 
124
126
  # Actual `ExecutionResult`` objects are not available client-side, since they
125
127
  # get transformed into `FormattedExecutionResult` on the wire, but we attempt
@@ -4,7 +4,7 @@ import functools
4
4
  import importlib
5
5
  import inspect
6
6
  from pathlib import Path # noqa: TCH003
7
- from typing import List, Optional, Type
7
+ from typing import List, Optional, Type, Union, cast
8
8
 
9
9
  import rich
10
10
  import typer
@@ -61,7 +61,9 @@ def _import_plugin(plugin: str) -> Optional[Type[QueryCodegenPlugin]]:
61
61
 
62
62
 
63
63
  @functools.lru_cache
64
- def _load_plugin(plugin_path: str) -> Type[QueryCodegenPlugin]:
64
+ def _load_plugin(
65
+ plugin_path: str,
66
+ ) -> Union[Type[QueryCodegenPlugin], Type[ConsolePlugin]]:
65
67
  # try to import plugin_name from current folder
66
68
  # then try to import from strawberry.codegen.plugins
67
69
 
@@ -77,7 +79,9 @@ def _load_plugin(plugin_path: str) -> Type[QueryCodegenPlugin]:
77
79
  return plugin
78
80
 
79
81
 
80
- def _load_plugins(plugin_ids: List[str], query: Path) -> List[QueryCodegenPlugin]:
82
+ def _load_plugins(
83
+ plugin_ids: List[str], query: Path
84
+ ) -> List[Union[QueryCodegenPlugin, ConsolePlugin]]:
81
85
  plugins = []
82
86
  for ptype_id in plugin_ids:
83
87
  ptype = _load_plugin(ptype_id)
@@ -127,11 +131,11 @@ def codegen(
127
131
 
128
132
  console_plugin_type = _load_plugin(cli_plugin) if cli_plugin else ConsolePlugin
129
133
  console_plugin = console_plugin_type(output_dir)
134
+ assert isinstance(console_plugin, ConsolePlugin)
130
135
  console_plugin.before_any_start()
131
136
 
132
137
  for q in query:
133
- plugins = _load_plugins(selected_plugins, q)
134
- console_plugin.query = q # update the query in the console plugin.
138
+ plugins = cast(List[QueryCodegenPlugin], _load_plugins(selected_plugins, q))
135
139
 
136
140
  code_generator = QueryCodegen(
137
141
  schema_symbol, plugins=plugins, console_plugin=console_plugin
@@ -105,7 +105,7 @@ def _build_dataclass_creation_fields(
105
105
 
106
106
  return DataclassCreationFields(
107
107
  name=field.name,
108
- field_type=field_type,
108
+ field_type=field_type, # type: ignore
109
109
  field=strawberry_field,
110
110
  )
111
111
 
@@ -198,7 +198,7 @@ def type(
198
198
  all_model_fields = [
199
199
  DataclassCreationFields(
200
200
  name=field.name,
201
- field_type=field.type,
201
+ field_type=field.type, # type: ignore
202
202
  field=field,
203
203
  )
204
204
  for field in extra_fields + private_fields
@@ -8,7 +8,6 @@ if TYPE_CHECKING:
8
8
  OpenTelemetryExtension,
9
9
  OpenTelemetryExtensionSync,
10
10
  )
11
- from .sentry import SentryTracingExtension, SentryTracingExtensionSync
12
11
 
13
12
  __all__ = [
14
13
  "ApolloTracingExtension",
@@ -17,8 +16,6 @@ __all__ = [
17
16
  "DatadogTracingExtensionSync",
18
17
  "OpenTelemetryExtension",
19
18
  "OpenTelemetryExtensionSync",
20
- "SentryTracingExtension",
21
- "SentryTracingExtensionSync",
22
19
  ]
23
20
 
24
21
 
@@ -32,7 +29,4 @@ def __getattr__(name: str) -> Any:
32
29
  if name in {"OpenTelemetryExtension", "OpenTelemetryExtensionSync"}:
33
30
  return getattr(importlib.import_module(".opentelemetry", __name__), name)
34
31
 
35
- if name in {"SentryTracingExtension", "SentryTracingExtensionSync"}:
36
- return getattr(importlib.import_module(".sentry", __name__), name)
37
-
38
32
  raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
@@ -169,16 +169,17 @@ class BaseGraphQLWSHandler:
169
169
  await self.websocket.send_json(error_message)
170
170
  else:
171
171
  self.subscriptions[operation_id] = agen_or_err
172
+
172
173
  async for result in agen_or_err:
173
174
  await self.send_data(result, operation_id)
174
- complete_message: CompleteMessage = {
175
- "type": "complete",
176
- "id": operation_id,
177
- }
178
- await self.websocket.send_json(complete_message)
175
+
176
+ await self.websocket.send_json(
177
+ CompleteMessage({"type": "complete", "id": operation_id})
178
+ )
179
179
  except asyncio.CancelledError:
180
- complete_message: CompleteMessage = {"type": "complete", "id": operation_id}
181
- await self.websocket.send_json(complete_message)
180
+ await self.websocket.send_json(
181
+ CompleteMessage({"type": "complete", "id": operation_id})
182
+ )
182
183
 
183
184
  async def cleanup_operation(self, operation_id: str) -> None:
184
185
  if operation_id in self.subscriptions:
@@ -350,7 +350,12 @@ def eval_type(
350
350
  assert ast_unparse
351
351
  type_ = ForwardRef(ast_unparse(ast_obj))
352
352
 
353
- return _eval_type(type_, globalns, localns)
353
+ extra: Dict[str, Any] = {}
354
+
355
+ if sys.version_info >= (3, 13):
356
+ extra = {"type_params": None}
357
+
358
+ return _eval_type(type_, globalns, localns, **extra)
354
359
 
355
360
  origin = get_origin(type_)
356
361
  if origin is not None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: strawberry-graphql
3
- Version: 0.248.0
3
+ Version: 0.249.0
4
4
  Summary: A library for creating GraphQL APIs
5
5
  Home-page: https://strawberry.rocks/
6
6
  License: MIT
@@ -16,11 +16,11 @@ strawberry/channels/handlers/base.py,sha256=KV4KA0eF5NRtikV9m4ssoPI5pmCZvDuRkfoT
16
16
  strawberry/channels/handlers/http_handler.py,sha256=fnQcPwdUz2CboVlnI3s1urQ_ZnZyNZvRx7SM_xPLLEA,11577
17
17
  strawberry/channels/handlers/ws_handler.py,sha256=k9xax8S1g0tfEFSe76UOHkheHqIrnYjEioYlLm4UPLo,6052
18
18
  strawberry/channels/router.py,sha256=DKIbl4zuRBhfvViUVpyu0Rf_WRT41E6uZC-Yic9Ltvo,2024
19
- strawberry/channels/testing.py,sha256=Ae2G8v4bKdkw8Se6itQ-gkaHpZREhrHWPPpF5dbhroY,6592
19
+ strawberry/channels/testing.py,sha256=2cZvF9S4ofYLLRh2G8iyWZTphfQi7XrUcFpRqGjUmPQ,6688
20
20
  strawberry/cli/__init__.py,sha256=byS5VrEiTJatAH6YS4V1Kd4SOwMRAQO2M1oJdIddivg,585
21
21
  strawberry/cli/app.py,sha256=tTMBV1pdWqMcwjWO2yn-8oLDhMhfJvUzyQtWs75LWJ0,54
22
22
  strawberry/cli/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
- strawberry/cli/commands/codegen.py,sha256=f3TKQVeg0iMYV3qcSXlvTNgG73ZWC60zjbeuK_RkQ3M,3825
23
+ strawberry/cli/commands/codegen.py,sha256=79CRVa01AScZ0dactJzMMpWP_2O00urNIjBAyWjPzA8,3910
24
24
  strawberry/cli/commands/export_schema.py,sha256=8XBqbejk0kT2fHky74DzW2TnE8APNMs0cKtatEjErUA,1024
25
25
  strawberry/cli/commands/schema_codegen.py,sha256=G6eV08a51sjVxCm3jn75oPn9hC8YarKiAKOY5bpTuKU,749
26
26
  strawberry/cli/commands/server.py,sha256=M175Etn4163oqP3egHBpZ8ga2Ilk8XgdDJtz6zfHPxM,2189
@@ -79,7 +79,7 @@ strawberry/experimental/pydantic/conversion_types.py,sha256=LdLFp0e7_YPntmHDwZDp
79
79
  strawberry/experimental/pydantic/error_type.py,sha256=kHqACk3F8kKT3V8PZr2h7-KI9M4UNpMjtq_TiOwYI38,4382
80
80
  strawberry/experimental/pydantic/exceptions.py,sha256=Q8Deq3bNkMgc8fwvIYdcfxHSONXVMu-ZB6jcsh1NQYo,1498
81
81
  strawberry/experimental/pydantic/fields.py,sha256=pmBqlq1DUtNkmDlXdA0Hmp3Xy252P6v5uyDF4WGcnl0,2588
82
- strawberry/experimental/pydantic/object_type.py,sha256=4CUtBR5wxe4dP-bpKBwNLU6trje7zygkD39_GoiPVBM,12432
82
+ strawberry/experimental/pydantic/object_type.py,sha256=KWpKIPpCsZRmURJOlkce5qODgWm7xgaJ49YZlJQcB80,12464
83
83
  strawberry/experimental/pydantic/utils.py,sha256=ViR7HGtnlYmyjUwIqGaEoBPo6dcibckwTFgp0GgwO6A,4073
84
84
  strawberry/ext/LICENSE,sha256=_oY0TZg0b_sW0--0T44aMTpy2e2zF1Kiyn8E1qDiivo,1249
85
85
  strawberry/ext/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -101,11 +101,10 @@ strawberry/extensions/parser_cache.py,sha256=IvDbkVpKC_2lDXLZyrvj0VleZghbtkD6l2S
101
101
  strawberry/extensions/pyinstrument.py,sha256=dy2NPagLDW4mU2jTfaHek3H1SBVZCjwYKf0zPMxTYp8,712
102
102
  strawberry/extensions/query_depth_limiter.py,sha256=Jtg-HSmEux97Z09Y5G5nhTbJu56rBiGmMG6lB1_ejz8,9882
103
103
  strawberry/extensions/runner.py,sha256=cVsBzNMBDjD4Pg_0jHNzYHv2cJUIVrNL_SzPr6rd7gk,1885
104
- strawberry/extensions/tracing/__init__.py,sha256=wx8_EAroGhNrP4HiGYMgKo8jnCsfde5ib6lO4OvcLV0,1400
104
+ strawberry/extensions/tracing/__init__.py,sha256=igoDJBlfh7vGhytJ5njx1qQzpxZOUmdfIaH4j5Kmt3E,1112
105
105
  strawberry/extensions/tracing/apollo.py,sha256=XlI88NzSZBSmBHEJ9iitDU9br2-9CdjdtHE_eiTJCIw,5880
106
106
  strawberry/extensions/tracing/datadog.py,sha256=khxvY4_WTjYaeJUb_dn6mLvmk9TCS4tIodnC3G-9pTo,5541
107
107
  strawberry/extensions/tracing/opentelemetry.py,sha256=MH2j71denfLmzInl6zcTzxzckqjcwOzm_F305z8-vYw,7281
108
- strawberry/extensions/tracing/sentry.py,sha256=r_U1OeiDDq-Mf6v30-aEuHhrio2Pckxfrcrdu_OAnWM,5027
109
108
  strawberry/extensions/tracing/utils.py,sha256=tXZNyqfct6YNSWi3GRj4GU1fKQGvSce8ZESfoVeys7U,654
110
109
  strawberry/extensions/utils.py,sha256=YPiacKNLQXvpYj-HI6fR5ORFdM9RrcdabGeM7F8vBGg,1001
111
110
  strawberry/extensions/validation_cache.py,sha256=CZ-brPYA1grL_lW38Rq4TxEVKlHM2n1DC6q9BHlSF4g,1398
@@ -190,7 +189,7 @@ strawberry/subscriptions/protocols/graphql_transport_ws/__init__.py,sha256=wN6dk
190
189
  strawberry/subscriptions/protocols/graphql_transport_ws/handlers.py,sha256=_h-xNf_ZRtjn8PGbxZk3u9qTR-NNNCevdgaFF0uXciw,14728
191
190
  strawberry/subscriptions/protocols/graphql_transport_ws/types.py,sha256=udYxzGtwjETYvY5f23org0t-aY4cimTjEGFYUR3idaY,2596
192
191
  strawberry/subscriptions/protocols/graphql_ws/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
193
- strawberry/subscriptions/protocols/graphql_ws/handlers.py,sha256=IQsOqh_9uWZMuBPmo05ThEzE9cC98WiRFt2K-2GWymk,7703
192
+ strawberry/subscriptions/protocols/graphql_ws/handlers.py,sha256=oM0o85zC24LpBjtVq8VakKx2hBGL0kb3Q9yl0GyFLS8,7614
194
193
  strawberry/subscriptions/protocols/graphql_ws/types.py,sha256=diZ36w56Nb_YmgfWXe6uXGiQOKmWIVjNEkcM-PkjaSs,1939
195
194
  strawberry/test/__init__.py,sha256=U3B5Ng7C_H8GpCpfvgZZcfADMw6cor5hm78gS3nDdMI,115
196
195
  strawberry/test/client.py,sha256=Va7J1tIjZ6PxbOqPl57jSp5lNLOZSueHPmrUuUx5sRY,6462
@@ -229,9 +228,9 @@ strawberry/utils/inspect.py,sha256=2WOeK3o8pjVkIH-rP_TaaLDa_AvroKC1WXc0gSE0Suc,3
229
228
  strawberry/utils/logging.py,sha256=U1cseHGquN09YFhFmRkiphfASKCyK0HUZREImPgVb0c,746
230
229
  strawberry/utils/operation.py,sha256=SSXxN-vMqdHO6W2OZtip-1z7y4_A-eTVFdhDvhKeLCk,1193
231
230
  strawberry/utils/str_converters.py,sha256=KGd7QH90RevaJjH6SQEkiVVsb8KuhJr_wv5AsI7UzQk,897
232
- strawberry/utils/typing.py,sha256=3xws5kxSQGsp8BnYyUwClvxXNzZakMAuOPoq1rjHRuk,14252
233
- strawberry_graphql-0.248.0.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
234
- strawberry_graphql-0.248.0.dist-info/METADATA,sha256=aKYBf7nSLOqh8q-WwFvOugbyH8ZlZBDokIS6Y5HfoMw,7758
235
- strawberry_graphql-0.248.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
236
- strawberry_graphql-0.248.0.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
237
- strawberry_graphql-0.248.0.dist-info/RECORD,,
231
+ strawberry/utils/typing.py,sha256=G6k2wWD1TDQ9WFk-Togekj_hTVFqHV-g7Phf2Wu41ms,14380
232
+ strawberry_graphql-0.249.0.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
233
+ strawberry_graphql-0.249.0.dist-info/METADATA,sha256=y_NXnqJCCHmKI10lZ-r3oodKQHkth_DvEmUTsYaThVc,7758
234
+ strawberry_graphql-0.249.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
235
+ strawberry_graphql-0.249.0.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
236
+ strawberry_graphql-0.249.0.dist-info/RECORD,,
@@ -1,161 +0,0 @@
1
- from __future__ import annotations
2
-
3
- import hashlib
4
- import warnings
5
- from functools import cached_property
6
- from inspect import isawaitable
7
- from typing import TYPE_CHECKING, Any, Callable, Generator, Optional
8
-
9
- from sentry_sdk import configure_scope, start_span
10
-
11
- from strawberry.extensions import SchemaExtension
12
- from strawberry.extensions.tracing.utils import should_skip_tracing
13
-
14
- if TYPE_CHECKING:
15
- from graphql import GraphQLResolveInfo
16
-
17
- from strawberry.types.execution import ExecutionContext
18
-
19
-
20
- class SentryTracingExtension(SchemaExtension):
21
- def __init__(
22
- self,
23
- *,
24
- execution_context: Optional[ExecutionContext] = None,
25
- ) -> None:
26
- warnings.warn(
27
- "The Sentry tracing extension is deprecated, please update to sentry-sdk>=1.32.0",
28
- DeprecationWarning,
29
- stacklevel=2,
30
- )
31
-
32
- if execution_context:
33
- self.execution_context = execution_context
34
-
35
- @cached_property
36
- def _resource_name(self) -> str:
37
- assert self.execution_context.query
38
-
39
- query_hash = self.hash_query(self.execution_context.query)
40
-
41
- if self.execution_context.operation_name:
42
- return f"{self.execution_context.operation_name}:{query_hash}"
43
-
44
- return query_hash
45
-
46
- def hash_query(self, query: str) -> str:
47
- return hashlib.md5(query.encode("utf-8")).hexdigest()
48
-
49
- def on_operation(self) -> Generator[None, None, None]:
50
- self._operation_name = self.execution_context.operation_name
51
- name = f"{self._operation_name}" if self._operation_name else "Anonymous Query"
52
-
53
- with configure_scope() as scope:
54
- if scope.span:
55
- self.gql_span = scope.span.start_child(
56
- op="gql",
57
- description=name,
58
- )
59
- else:
60
- self.gql_span = start_span(
61
- op="gql",
62
- )
63
-
64
- operation_type = "query"
65
-
66
- assert self.execution_context.query
67
-
68
- if self.execution_context.query.strip().startswith("mutation"):
69
- operation_type = "mutation"
70
- if self.execution_context.query.strip().startswith("subscription"):
71
- operation_type = "subscription"
72
-
73
- self.gql_span.set_tag("graphql.operation_type", operation_type)
74
- self.gql_span.set_tag("graphql.resource_name", self._resource_name)
75
- self.gql_span.set_data("graphql.query", self.execution_context.query)
76
-
77
- yield
78
-
79
- self.gql_span.finish()
80
-
81
- def on_validate(self) -> Generator[None, None, None]:
82
- self.validation_span = self.gql_span.start_child(
83
- op="validation", description="Validation"
84
- )
85
-
86
- yield
87
-
88
- self.validation_span.finish()
89
-
90
- def on_parse(self) -> Generator[None, None, None]:
91
- self.parsing_span = self.gql_span.start_child(
92
- op="parsing", description="Parsing"
93
- )
94
-
95
- yield
96
-
97
- self.parsing_span.finish()
98
-
99
- def should_skip_tracing(self, _next: Callable, info: GraphQLResolveInfo) -> bool:
100
- return should_skip_tracing(_next, info)
101
-
102
- async def resolve(
103
- self,
104
- _next: Callable,
105
- root: Any,
106
- info: GraphQLResolveInfo,
107
- *args: str,
108
- **kwargs: Any,
109
- ) -> Any:
110
- if self.should_skip_tracing(_next, info):
111
- result = _next(root, info, *args, **kwargs)
112
-
113
- if isawaitable(result): # pragma: no cover
114
- result = await result
115
-
116
- return result
117
-
118
- field_path = f"{info.parent_type}.{info.field_name}"
119
-
120
- with self.gql_span.start_child(
121
- op="resolve", description=f"Resolving: {field_path}"
122
- ) as span:
123
- span.set_tag("graphql.field_name", info.field_name)
124
- span.set_tag("graphql.parent_type", info.parent_type.name)
125
- span.set_tag("graphql.field_path", field_path)
126
- span.set_tag("graphql.path", ".".join(map(str, info.path.as_list())))
127
-
128
- result = _next(root, info, *args, **kwargs)
129
-
130
- if isawaitable(result):
131
- result = await result
132
-
133
- return result
134
-
135
-
136
- class SentryTracingExtensionSync(SentryTracingExtension):
137
- def resolve(
138
- self,
139
- _next: Callable,
140
- root: Any,
141
- info: GraphQLResolveInfo,
142
- *args: str,
143
- **kwargs: Any,
144
- ) -> Any:
145
- if self.should_skip_tracing(_next, info):
146
- return _next(root, info, *args, **kwargs)
147
-
148
- field_path = f"{info.parent_type}.{info.field_name}"
149
-
150
- with self.gql_span.start_child(
151
- op="resolve", description=f"Resolving: {field_path}"
152
- ) as span:
153
- span.set_tag("graphql.field_name", info.field_name)
154
- span.set_tag("graphql.parent_type", info.parent_type.name)
155
- span.set_tag("graphql.field_path", field_path)
156
- span.set_tag("graphql.path", ".".join(map(str, info.path.as_list())))
157
-
158
- return _next(root, info, *args, **kwargs)
159
-
160
-
161
- __all__ = ["SentryTracingExtension", "SentryTracingExtensionSync"]