strawberry-graphql 0.219.1__py3-none-any.whl → 0.220.0.dev1709543239__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.
@@ -6,7 +6,6 @@ from typing import (
6
6
  Any,
7
7
  List,
8
8
  NamedTuple,
9
- NoReturn,
10
9
  Set,
11
10
  Tuple,
12
11
  Type,
@@ -126,7 +125,7 @@ def get_default_factory_for_field(
126
125
 
127
126
  def ensure_all_auto_fields_in_pydantic(
128
127
  model: Type[BaseModel], auto_fields: Set[str], cls_name: str
129
- ) -> Union[NoReturn, None]:
128
+ ) -> None:
130
129
  # Raise error if user defined a strawberry.auto field not present in the model
131
130
  non_existing_fields = list(auto_fields - get_model_fields(model).keys())
132
131
 
@@ -135,4 +134,4 @@ def ensure_all_auto_fields_in_pydantic(
135
134
  fields=non_existing_fields, cls_name=cls_name, model=model
136
135
  )
137
136
  else:
138
- return None
137
+ return
@@ -65,7 +65,7 @@ def create_validator(max_alias_count: int) -> Type[ValidationRule]:
65
65
 
66
66
 
67
67
  def count_fields_with_alias(
68
- selection_set_owner: Union[ExecutableDefinitionNode, FieldNode, InlineFragmentNode]
68
+ selection_set_owner: Union[ExecutableDefinitionNode, FieldNode, InlineFragmentNode],
69
69
  ) -> int:
70
70
  if selection_set_owner.selection_set is None:
71
71
  return 0
@@ -88,77 +88,82 @@ async def execute(
88
88
  extensions=list(extensions),
89
89
  )
90
90
 
91
- async with extensions_runner.operation():
92
- # Note: In graphql-core the schema would be validated here but in
93
- # Strawberry we are validating it at initialisation time instead
94
- if not execution_context.query:
95
- raise MissingQueryError()
96
-
97
- async with extensions_runner.parsing():
98
- try:
99
- if not execution_context.graphql_document:
100
- execution_context.graphql_document = parse_document(
101
- execution_context.query, **execution_context.parse_options
91
+ try:
92
+ async with extensions_runner.operation():
93
+ # Note: In graphql-core the schema would be validated here but in
94
+ # Strawberry we are validating it at initialisation time instead
95
+ if not execution_context.query:
96
+ raise MissingQueryError()
97
+
98
+ async with extensions_runner.parsing():
99
+ try:
100
+ if not execution_context.graphql_document:
101
+ execution_context.graphql_document = parse_document(
102
+ execution_context.query, **execution_context.parse_options
103
+ )
104
+
105
+ except GraphQLError as exc:
106
+ execution_context.errors = [exc]
107
+ process_errors([exc], execution_context)
108
+ return ExecutionResult(
109
+ data=None,
110
+ errors=[exc],
111
+ extensions=await extensions_runner.get_extensions_results(),
102
112
  )
103
113
 
104
- except GraphQLError as error:
105
- execution_context.errors = [error]
106
- process_errors([error], execution_context)
107
- return ExecutionResult(
108
- data=None,
109
- errors=[error],
110
- extensions=await extensions_runner.get_extensions_results(),
111
- )
112
-
113
- except Exception as error: # pragma: no cover
114
- error = GraphQLError(str(error), original_error=error)
115
-
116
- execution_context.errors = [error]
117
- process_errors([error], execution_context)
118
-
119
- return ExecutionResult(
120
- data=None,
121
- errors=[error],
122
- extensions=await extensions_runner.get_extensions_results(),
123
- )
124
-
125
- if execution_context.operation_type not in allowed_operation_types:
126
- raise InvalidOperationTypeError(execution_context.operation_type)
127
-
128
- async with extensions_runner.validation():
129
- _run_validation(execution_context)
130
- if execution_context.errors:
131
- process_errors(execution_context.errors, execution_context)
132
- return ExecutionResult(data=None, errors=execution_context.errors)
133
-
134
- async with extensions_runner.executing():
135
- if not execution_context.result:
136
- result = original_execute(
137
- schema,
138
- execution_context.graphql_document,
139
- root_value=execution_context.root_value,
140
- middleware=extensions_runner.as_middleware_manager(),
141
- variable_values=execution_context.variables,
142
- operation_name=execution_context.operation_name,
143
- context_value=execution_context.context,
144
- execution_context_class=execution_context_class,
145
- )
146
-
147
- if isawaitable(result):
148
- result = await cast(Awaitable["GraphQLExecutionResult"], result)
149
-
150
- result = cast("GraphQLExecutionResult", result)
151
- execution_context.result = result
152
- # Also set errors on the execution_context so that it's easier
153
- # to access in extensions
154
- if result.errors:
155
- execution_context.errors = result.errors
156
-
157
- # Run the `Schema.process_errors` function here before
158
- # extensions have a chance to modify them (see the MaskErrors
159
- # extension). That way we can log the original errors but
160
- # only return a sanitised version to the client.
161
- process_errors(result.errors, execution_context)
114
+ if execution_context.operation_type not in allowed_operation_types:
115
+ raise InvalidOperationTypeError(execution_context.operation_type)
116
+
117
+ async with extensions_runner.validation():
118
+ _run_validation(execution_context)
119
+ if execution_context.errors:
120
+ process_errors(execution_context.errors, execution_context)
121
+ return ExecutionResult(data=None, errors=execution_context.errors)
122
+
123
+ async with extensions_runner.executing():
124
+ if not execution_context.result:
125
+ result = original_execute(
126
+ schema,
127
+ execution_context.graphql_document,
128
+ root_value=execution_context.root_value,
129
+ middleware=extensions_runner.as_middleware_manager(),
130
+ variable_values=execution_context.variables,
131
+ operation_name=execution_context.operation_name,
132
+ context_value=execution_context.context,
133
+ execution_context_class=execution_context_class,
134
+ )
135
+
136
+ if isawaitable(result):
137
+ result = await cast(Awaitable["GraphQLExecutionResult"], result)
138
+
139
+ result = cast("GraphQLExecutionResult", result)
140
+ execution_context.result = result
141
+ # Also set errors on the execution_context so that it's easier
142
+ # to access in extensions
143
+ if result.errors:
144
+ execution_context.errors = result.errors
145
+
146
+ # Run the `Schema.process_errors` function here before
147
+ # extensions have a chance to modify them (see the MaskErrors
148
+ # extension). That way we can log the original errors but
149
+ # only return a sanitised version to the client.
150
+ process_errors(result.errors, execution_context)
151
+
152
+ except (MissingQueryError, InvalidOperationTypeError) as e:
153
+ raise e
154
+ except Exception as exc:
155
+ error = (
156
+ exc
157
+ if isinstance(exc, GraphQLError)
158
+ else GraphQLError(str(exc), original_error=exc)
159
+ )
160
+ execution_context.errors = [error]
161
+ process_errors([error], execution_context)
162
+ return ExecutionResult(
163
+ data=None,
164
+ errors=[error],
165
+ extensions=await extensions_runner.get_extensions_results(),
166
+ )
162
167
 
163
168
  return ExecutionResult(
164
169
  data=execution_context.result.data,
@@ -181,80 +186,86 @@ def execute_sync(
181
186
  extensions=list(extensions),
182
187
  )
183
188
 
184
- with extensions_runner.operation():
185
- # Note: In graphql-core the schema would be validated here but in
186
- # Strawberry we are validating it at initialisation time instead
187
- if not execution_context.query:
188
- raise MissingQueryError()
189
-
190
- with extensions_runner.parsing():
191
- try:
192
- if not execution_context.graphql_document:
193
- execution_context.graphql_document = parse_document(
194
- execution_context.query, **execution_context.parse_options
189
+ try:
190
+ with extensions_runner.operation():
191
+ # Note: In graphql-core the schema would be validated here but in
192
+ # Strawberry we are validating it at initialisation time instead
193
+ if not execution_context.query:
194
+ raise MissingQueryError()
195
+
196
+ with extensions_runner.parsing():
197
+ try:
198
+ if not execution_context.graphql_document:
199
+ execution_context.graphql_document = parse_document(
200
+ execution_context.query, **execution_context.parse_options
201
+ )
202
+
203
+ except GraphQLError as exc:
204
+ execution_context.errors = [exc]
205
+ process_errors([exc], execution_context)
206
+ return ExecutionResult(
207
+ data=None,
208
+ errors=[exc],
209
+ extensions=extensions_runner.get_extensions_results_sync(),
195
210
  )
196
211
 
197
- except GraphQLError as error:
198
- execution_context.errors = [error]
199
- process_errors([error], execution_context)
200
- return ExecutionResult(
201
- data=None,
202
- errors=[error],
203
- extensions=extensions_runner.get_extensions_results_sync(),
204
- )
205
-
206
- except Exception as error: # pragma: no cover
207
- error = GraphQLError(str(error), original_error=error)
208
-
209
- execution_context.errors = [error]
210
- process_errors([error], execution_context)
211
- return ExecutionResult(
212
- data=None,
213
- errors=[error],
214
- extensions=extensions_runner.get_extensions_results_sync(),
215
- )
216
-
217
- if execution_context.operation_type not in allowed_operation_types:
218
- raise InvalidOperationTypeError(execution_context.operation_type)
219
-
220
- with extensions_runner.validation():
221
- _run_validation(execution_context)
222
- if execution_context.errors:
223
- process_errors(execution_context.errors, execution_context)
224
- return ExecutionResult(data=None, errors=execution_context.errors)
225
-
226
- with extensions_runner.executing():
227
- if not execution_context.result:
228
- result = original_execute(
229
- schema,
230
- execution_context.graphql_document,
231
- root_value=execution_context.root_value,
232
- middleware=extensions_runner.as_middleware_manager(),
233
- variable_values=execution_context.variables,
234
- operation_name=execution_context.operation_name,
235
- context_value=execution_context.context,
236
- execution_context_class=execution_context_class,
237
- )
238
-
239
- if isawaitable(result):
240
- result = cast(Awaitable["GraphQLExecutionResult"], result)
241
- ensure_future(result).cancel()
242
- raise RuntimeError(
243
- "GraphQL execution failed to complete synchronously."
212
+ if execution_context.operation_type not in allowed_operation_types:
213
+ raise InvalidOperationTypeError(execution_context.operation_type)
214
+
215
+ with extensions_runner.validation():
216
+ _run_validation(execution_context)
217
+ if execution_context.errors:
218
+ process_errors(execution_context.errors, execution_context)
219
+ return ExecutionResult(data=None, errors=execution_context.errors)
220
+
221
+ with extensions_runner.executing():
222
+ if not execution_context.result:
223
+ result = original_execute(
224
+ schema,
225
+ execution_context.graphql_document,
226
+ root_value=execution_context.root_value,
227
+ middleware=extensions_runner.as_middleware_manager(),
228
+ variable_values=execution_context.variables,
229
+ operation_name=execution_context.operation_name,
230
+ context_value=execution_context.context,
231
+ execution_context_class=execution_context_class,
244
232
  )
245
233
 
246
- result = cast("GraphQLExecutionResult", result)
247
- execution_context.result = result
248
- # Also set errors on the execution_context so that it's easier
249
- # to access in extensions
250
- if result.errors:
251
- execution_context.errors = result.errors
252
-
253
- # Run the `Schema.process_errors` function here before
254
- # extensions have a chance to modify them (see the MaskErrors
255
- # extension). That way we can log the original errors but
256
- # only return a sanitised version to the client.
257
- process_errors(result.errors, execution_context)
234
+ if isawaitable(result):
235
+ result = cast(Awaitable["GraphQLExecutionResult"], result)
236
+ ensure_future(result).cancel()
237
+ raise RuntimeError(
238
+ "GraphQL execution failed to complete synchronously."
239
+ )
240
+
241
+ result = cast("GraphQLExecutionResult", result)
242
+ execution_context.result = result
243
+ # Also set errors on the execution_context so that it's easier
244
+ # to access in extensions
245
+ if result.errors:
246
+ execution_context.errors = result.errors
247
+
248
+ # Run the `Schema.process_errors` function here before
249
+ # extensions have a chance to modify them (see the MaskErrors
250
+ # extension). That way we can log the original errors but
251
+ # only return a sanitised version to the client.
252
+ process_errors(result.errors, execution_context)
253
+
254
+ except (MissingQueryError, InvalidOperationTypeError) as e:
255
+ raise e
256
+ except Exception as exc:
257
+ error = (
258
+ exc
259
+ if isinstance(exc, GraphQLError)
260
+ else GraphQLError(str(exc), original_error=exc)
261
+ )
262
+ execution_context.errors = [error]
263
+ process_errors([error], execution_context)
264
+ return ExecutionResult(
265
+ data=None,
266
+ errors=[error],
267
+ extensions=extensions_runner.get_extensions_results_sync(),
268
+ )
258
269
 
259
270
  return ExecutionResult(
260
271
  data=execution_context.result.data,
strawberry/utils/aio.py CHANGED
@@ -24,7 +24,7 @@ async def aenumerate(
24
24
  i = 0
25
25
  async for element in iterable:
26
26
  yield i, element
27
- i += 1
27
+ i += 1 # noqa: SIM113
28
28
 
29
29
 
30
30
  async def aislice(
@@ -214,7 +214,7 @@ def _ast_replace_union_operation(expr: ast.Expr) -> ast.Expr:
214
214
 
215
215
 
216
216
  def _ast_replace_union_operation(
217
- expr: Union[ast.Expr, ast.expr]
217
+ expr: Union[ast.Expr, ast.expr],
218
218
  ) -> Union[ast.Expr, ast.expr]:
219
219
  if isinstance(expr, ast.Expr) and isinstance(
220
220
  expr.value, (ast.BinOp, ast.Subscript)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: strawberry-graphql
3
- Version: 0.219.1
3
+ Version: 0.220.0.dev1709543239
4
4
  Summary: A library for creating GraphQL APIs
5
5
  Home-page: https://strawberry.rocks/
6
6
  License: MIT
@@ -53,7 +53,7 @@ Requires-Dist: pydantic (>1.6.1) ; extra == "pydantic"
53
53
  Requires-Dist: pygments (>=2.3,<3.0) ; extra == "debug-server" or extra == "cli"
54
54
  Requires-Dist: pyinstrument (>=4.0.0) ; extra == "pyinstrument"
55
55
  Requires-Dist: python-dateutil (>=2.7.0,<3.0.0)
56
- Requires-Dist: python-multipart (>=0.0.5,<0.0.7) ; extra == "asgi" or extra == "debug-server" or extra == "fastapi"
56
+ Requires-Dist: python-multipart (>=0.0.7) ; extra == "asgi" or extra == "debug-server" or extra == "fastapi"
57
57
  Requires-Dist: quart (>=0.19.3) ; extra == "quart"
58
58
  Requires-Dist: rich (>=12.0.0) ; extra == "debug" or extra == "debug-server" or extra == "cli"
59
59
  Requires-Dist: sanic (>=20.12.2) ; extra == "sanic"
@@ -90,7 +90,7 @@ strawberry/experimental/pydantic/error_type.py,sha256=Fy7m2E03a86XsF76UoAUeroiJL
90
90
  strawberry/experimental/pydantic/exceptions.py,sha256=GJt22DTolA24A0ZHcHsy-fcRkBnavgUZYOo0MBIVcjs,1427
91
91
  strawberry/experimental/pydantic/fields.py,sha256=m7LJEQ39wko4NRIjYPxhUbwNyZcubrbZmyBumG34CJM,5356
92
92
  strawberry/experimental/pydantic/object_type.py,sha256=kb1gwHw7vQCshk84a7DMRBp_9zDntrAK3bbI58vjqf0,12160
93
- strawberry/experimental/pydantic/utils.py,sha256=4vFNTyFLI6o9akUBf2ZNvWv-FFvQDm0F-i2_KagmQcE,3864
93
+ strawberry/experimental/pydantic/utils.py,sha256=vh9Mz33b5QhomuCMVygZ2mp2jrBOxVejIRK0XdfpygI,3828
94
94
  strawberry/ext/LICENSE,sha256=_oY0TZg0b_sW0--0T44aMTpy2e2zF1Kiyn8E1qDiivo,1249
95
95
  strawberry/ext/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
96
96
  strawberry/ext/dataclasses/LICENSE,sha256=WZgm35K_3NJwLqxpEHJJi7CWxVrwTumEz5D3Dtd7WnA,13925
@@ -105,7 +105,7 @@ strawberry/extensions/directives.py,sha256=ulS80mDTDE-pM8d9IEk16O84kzjkXM1P4vMcq
105
105
  strawberry/extensions/disable_validation.py,sha256=eLlZ0SEuvK3HUSvLm4PpdgrtP30ckG25sV3hGd2W-sM,720
106
106
  strawberry/extensions/field_extension.py,sha256=1UXGdrPEz9y1m6OcsZTKTnPD1vMvWph3YOsk6QYtG5k,5643
107
107
  strawberry/extensions/mask_errors.py,sha256=D6Bga-op1vwdA07wpSZqssl1-wr3Pb56rQcjjyOv7UQ,1425
108
- strawberry/extensions/max_aliases.py,sha256=ID5nF-Dh0_N_4dPGkbDfWdGrBW7htbLK7-XYFNnFpFQ,2361
108
+ strawberry/extensions/max_aliases.py,sha256=aAKZ0xvSD72tNOtl7fQ6BOOB8qFjdADrTzAgMbVX18w,2362
109
109
  strawberry/extensions/max_tokens.py,sha256=Fa-Zcugo2Y1WRINTdTRWzsRhAnBFCLAoplfnlS8j_nY,1014
110
110
  strawberry/extensions/parser_cache.py,sha256=-HYjMsrLEBaHhwkNAXazXzvHMg2HSZ7BxN1LT02zCx0,1220
111
111
  strawberry/extensions/pyinstrument.py,sha256=hJZdF48eJ7QY-6rKalnUGNWK2ZrpFayUi1J0cj9tPC0,876
@@ -186,7 +186,7 @@ strawberry/schema/base.py,sha256=lQBJyzG2ZhKc544oLbXEbpYOPOjaXBop3lxp68h_lfI,297
186
186
  strawberry/schema/compat.py,sha256=n0r3UPUcGemMqK8vklgtCkkuCA1p6tWAYbc6Vl4iNOw,1684
187
187
  strawberry/schema/config.py,sha256=N9KsqkSTnm5snizoBZAVneaWQprhaTd8PFyMuR-jfUs,632
188
188
  strawberry/schema/exceptions.py,sha256=_9Ua-lLRCJfbtd8B6MXILNKGI2SwHkcBNkAHYM7ITp8,534
189
- strawberry/schema/execute.py,sha256=MAfuE2o89qBmnBpgaTmUA9xJ682KvEQw52EOh4XVE00,10415
189
+ strawberry/schema/execute.py,sha256=6OE7_5v4G3t_wxp1_mfwu8TTiIkTJNBQaeGCVAljUYw,10982
190
190
  strawberry/schema/name_converter.py,sha256=UdNyd-QtqF2HsDCQK-nsOcLGxDTj4hJwYFNvMtZnpq4,6533
191
191
  strawberry/schema/schema.py,sha256=HvdOmXK2yHCliD-xyAV01rw3PoGW2f8oEzOYo-cA0AM,13726
192
192
  strawberry/schema/schema_converter.py,sha256=r5T0mwM4qY51yq_0bWDKRqeod9hzJJg3OGzV8siXnRU,34730
@@ -229,7 +229,7 @@ strawberry/types/types.py,sha256=t5MOV4xiutPL2Ka02u3Z2V3eqy2R2JPYQxsqCnY2Aqk,713
229
229
  strawberry/union.py,sha256=5DOzsmsrI4tU4aXO7BBEN-570ABQ9_VkRDvUJUrIofY,9926
230
230
  strawberry/unset.py,sha256=_180_Wxvw-umn-URMb3CmO-WegBfZHjVZW0L0RXrQrI,1097
231
231
  strawberry/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
232
- strawberry/utils/aio.py,sha256=nRu0VYg9RLpkY90t6UfUlCJhIS1qpmqLdQHlwTOK89g,1608
232
+ strawberry/utils/aio.py,sha256=ZAA7Y9nM55s9XlYTWqRjPHrO2O9zu5KElCz_dx25nG4,1624
233
233
  strawberry/utils/await_maybe.py,sha256=fgycBJZzaexrx0Vw0KbVZ4PJYoN_zh7F6Z0T-FObBdE,362
234
234
  strawberry/utils/dataclasses.py,sha256=BNnX7hDd-2sgiQpObyuCl3Zj-U16RiSyE2V53FrpdNQ,821
235
235
  strawberry/utils/debug.py,sha256=-MtRqM5e1J-GDNgKQXoVFcBB9f3dHvhEGrTc82uN4LM,1379
@@ -240,9 +240,9 @@ strawberry/utils/inspect.py,sha256=6z-tJpiWWm6E4-O6OUfhu689W9k1uY0m3FDwAfVCiNs,2
240
240
  strawberry/utils/logging.py,sha256=flS7hV0JiIOEdXcrIjda4WyIWix86cpHHFNJL8gl1y4,713
241
241
  strawberry/utils/operation.py,sha256=Um-tBCPl3_bVFN2Ph7o1mnrxfxBes4HFCj6T0x4kZxE,1135
242
242
  strawberry/utils/str_converters.py,sha256=avIgPVLg98vZH9mA2lhzVdyyjqzLsK2NdBw9mJQ02Xk,813
243
- strawberry/utils/typing.py,sha256=xkRDUaSJH669jtmdUvWIqrj66Vx4tsbrXSuuYy0FPxU,13490
244
- strawberry_graphql-0.219.1.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
245
- strawberry_graphql-0.219.1.dist-info/METADATA,sha256=KIk_A7mmdB8Ny1b4CYfcg-WFE6BIg3zYjyWoxoF3gsM,7747
246
- strawberry_graphql-0.219.1.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
247
- strawberry_graphql-0.219.1.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
248
- strawberry_graphql-0.219.1.dist-info/RECORD,,
243
+ strawberry/utils/typing.py,sha256=Qxz1LwyVsNGV7LQW1dFsaUbsswj5LHBOdKLMom5eyEA,13491
244
+ strawberry_graphql-0.220.0.dev1709543239.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
245
+ strawberry_graphql-0.220.0.dev1709543239.dist-info/METADATA,sha256=jkAZjN8RDuaeEREHhENLaroXtadRJqyEHGmu1PGHaHI,7754
246
+ strawberry_graphql-0.220.0.dev1709543239.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
247
+ strawberry_graphql-0.220.0.dev1709543239.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
248
+ strawberry_graphql-0.220.0.dev1709543239.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.8.1
2
+ Generator: poetry-core 1.9.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any