strawberry-graphql 0.225.1__py3-none-any.whl → 0.226.1__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.
@@ -487,12 +487,23 @@ def strawberry_pydantic_class_callback(ctx: ClassDefContext) -> None:
487
487
  initializer=None,
488
488
  kind=ARG_OPT,
489
489
  )
490
+ extra_type = ctx.api.named_type(
491
+ "builtins.dict",
492
+ [ctx.api.named_type("builtins.str"), AnyType(TypeOfAny.explicit)],
493
+ )
494
+
495
+ extra_argument = Argument(
496
+ variable=Var(name="extra", type=UnionType([NoneType(), extra_type])),
497
+ type_annotation=UnionType([NoneType(), extra_type]),
498
+ initializer=None,
499
+ kind=ARG_OPT,
500
+ )
490
501
 
491
502
  add_static_method_to_class(
492
503
  ctx.api,
493
504
  ctx.cls,
494
505
  name="from_pydantic",
495
- args=[model_argument],
506
+ args=[model_argument, extra_argument],
496
507
  return_type=fill_typevars(ctx.cls.info),
497
508
  )
498
509
 
@@ -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,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: strawberry-graphql
3
- Version: 0.225.1
3
+ Version: 0.226.1
4
4
  Summary: A library for creating GraphQL APIs
5
5
  Home-page: https://strawberry.rocks/
6
6
  License: MIT
@@ -96,7 +96,7 @@ strawberry/ext/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
96
96
  strawberry/ext/dataclasses/LICENSE,sha256=WZgm35K_3NJwLqxpEHJJi7CWxVrwTumEz5D3Dtd7WnA,13925
97
97
  strawberry/ext/dataclasses/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
98
98
  strawberry/ext/dataclasses/dataclasses.py,sha256=Le32f96qmahuenVsMW5xjIr-EPnO7WKljbOPLpU800Q,2254
99
- strawberry/ext/mypy_plugin.py,sha256=AGWu3xTguWMetqQP7bnaLRJBdLplPOtZ_eRGYt0Gfg8,18956
99
+ strawberry/ext/mypy_plugin.py,sha256=VdeNIrV6jVV-2xepneo0TNFI7wWfjTGAcLHxARzxRTw,19380
100
100
  strawberry/extensions/__init__.py,sha256=SZ-YEMnxAzoDZFo-uHXMHOaY_PPkYm1muPpK4ccJ3Xk,1248
101
101
  strawberry/extensions/add_validation_rules.py,sha256=l1cCl6VGQ8c2EELK3cIjmn6RftonHD1jKoWQ5-hMTf0,1366
102
102
  strawberry/extensions/base_extension.py,sha256=XvYKIsSaxfTCVWdphOFll-Fo0wJd5Ib4QdKuYule6S0,2000
@@ -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=XkWwmxEsmecscH29o4qU0iSe-hgwJJ2X0DPBVlka2OE,640
188
188
  strawberry/schema/exceptions.py,sha256=T-DsvBtjx9svkegIm1YrVPGPswpVEpMTFc0_7flLEkM,542
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=MOC8k6NHolFGrCyqrungv0ciCImLdXTlbmo7y7rLRas,13734
192
192
  strawberry/schema/schema_converter.py,sha256=DT6HWJeTdaFuEoVzlVGeEIXeg_vdaiJ4YGSakXaRTlQ,34785
@@ -241,8 +241,8 @@ strawberry/utils/logging.py,sha256=flS7hV0JiIOEdXcrIjda4WyIWix86cpHHFNJL8gl1y4,7
241
241
  strawberry/utils/operation.py,sha256=Um-tBCPl3_bVFN2Ph7o1mnrxfxBes4HFCj6T0x4kZxE,1135
242
242
  strawberry/utils/str_converters.py,sha256=avIgPVLg98vZH9mA2lhzVdyyjqzLsK2NdBw9mJQ02Xk,813
243
243
  strawberry/utils/typing.py,sha256=Qxz1LwyVsNGV7LQW1dFsaUbsswj5LHBOdKLMom5eyEA,13491
244
- strawberry_graphql-0.225.1.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
245
- strawberry_graphql-0.225.1.dist-info/METADATA,sha256=Nu3tLVwHoZOo3r5XIoRHS6e5r7ffPh2fMBBjFjSgwxk,7740
246
- strawberry_graphql-0.225.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
247
- strawberry_graphql-0.225.1.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
248
- strawberry_graphql-0.225.1.dist-info/RECORD,,
244
+ strawberry_graphql-0.226.1.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
245
+ strawberry_graphql-0.226.1.dist-info/METADATA,sha256=bbV0w8Q9lfWBuPg0AQY07CpZMXxiH5jvpQ00RephDj0,7740
246
+ strawberry_graphql-0.226.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
247
+ strawberry_graphql-0.226.1.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
248
+ strawberry_graphql-0.226.1.dist-info/RECORD,,