strawberry-graphql 0.227.0.dev1713463204__py3-none-any.whl → 0.227.0.dev1713475585__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 CHANGED
@@ -7,7 +7,7 @@ from .enum import enum, enum_value
7
7
  from .field import field
8
8
  from .lazy_type import LazyType, lazy
9
9
  from .mutation import mutation, subscription
10
- from .object_type import asdict, input, interface, one_of_input, type
10
+ from .object_type import asdict, input, interface, type
11
11
  from .parent import Parent
12
12
  from .permission import BasePermission
13
13
  from .private import Private
@@ -38,7 +38,6 @@ __all__ = [
38
38
  "federation",
39
39
  "field",
40
40
  "input",
41
- "one_of_input",
42
41
  "interface",
43
42
  "mutation",
44
43
  "scalar",
@@ -31,6 +31,7 @@ def _impl_type(
31
31
  *,
32
32
  name: Optional[str] = None,
33
33
  description: Optional[str] = None,
34
+ one_of: Optional[bool] = None,
34
35
  directives: Iterable[object] = (),
35
36
  authenticated: bool = False,
36
37
  keys: Iterable[Union["Key", str]] = (),
@@ -54,6 +55,7 @@ def _impl_type(
54
55
  Shareable,
55
56
  Tag,
56
57
  )
58
+ from strawberry.schema_directives import OneOf
57
59
 
58
60
  directives = list(directives)
59
61
 
@@ -83,6 +85,9 @@ def _impl_type(
83
85
  if is_interface_object:
84
86
  directives.append(InterfaceObject())
85
87
 
88
+ if one_of:
89
+ directives.append(OneOf())
90
+
86
91
  return base_type( # type: ignore
87
92
  cls,
88
93
  name=name,
@@ -182,6 +187,7 @@ def input(
182
187
  cls: T,
183
188
  *,
184
189
  name: Optional[str] = None,
190
+ one_of: Optional[bool] = None,
185
191
  description: Optional[str] = None,
186
192
  directives: Sequence[object] = (),
187
193
  inaccessible: bool = UNSET,
@@ -200,6 +206,7 @@ def input(
200
206
  *,
201
207
  name: Optional[str] = None,
202
208
  description: Optional[str] = None,
209
+ one_of: Optional[bool] = None,
203
210
  directives: Sequence[object] = (),
204
211
  inaccessible: bool = UNSET,
205
212
  tags: Iterable[str] = (),
@@ -211,6 +218,7 @@ def input(
211
218
  cls: Optional[T] = None,
212
219
  *,
213
220
  name: Optional[str] = None,
221
+ one_of: Optional[bool] = None,
214
222
  description: Optional[str] = None,
215
223
  directives: Sequence[object] = (),
216
224
  inaccessible: bool = UNSET,
@@ -223,6 +231,7 @@ def input(
223
231
  directives=directives,
224
232
  inaccessible=inaccessible,
225
233
  is_input=True,
234
+ one_of=one_of,
226
235
  tags=tags,
227
236
  )
228
237
 
strawberry/object_type.py CHANGED
@@ -264,60 +264,6 @@ def type(
264
264
  return wrap(cls)
265
265
 
266
266
 
267
- @overload
268
- @dataclass_transform(
269
- order_default=True, kw_only_default=True, field_specifiers=(field, StrawberryField)
270
- )
271
- def one_of_input(
272
- cls: T,
273
- *,
274
- name: Optional[str] = None,
275
- description: Optional[str] = None,
276
- directives: Optional[Sequence[object]] = (),
277
- ) -> T:
278
- ...
279
-
280
-
281
- @overload
282
- @dataclass_transform(
283
- order_default=True, kw_only_default=True, field_specifiers=(field, StrawberryField)
284
- )
285
- def one_of_input(
286
- *,
287
- name: Optional[str] = None,
288
- description: Optional[str] = None,
289
- directives: Optional[Sequence[object]] = (),
290
- ) -> Callable[[T], T]:
291
- ...
292
-
293
-
294
- def one_of_input(
295
- cls: Optional[T] = None,
296
- *,
297
- name: Optional[str] = None,
298
- description: Optional[str] = None,
299
- directives: Optional[Sequence[object]] = (),
300
- ):
301
- """Annotates a class as a GraphQL Input type with the @oneOf directive.
302
- Example usage:
303
- >>> @strawberry.one_of_input
304
- >>> class X:
305
- >>> field_abc: str = "ABC"
306
- """
307
-
308
- from strawberry.schema_directives import OneOf
309
-
310
- directives = (*(directives or tuple()), OneOf())
311
-
312
- return type( # type: ignore # not sure why mypy complains here
313
- cls,
314
- name=name,
315
- description=description,
316
- directives=directives,
317
- is_input=True,
318
- )
319
-
320
-
321
267
  @overload
322
268
  @dataclass_transform(
323
269
  order_default=True, kw_only_default=True, field_specifiers=(field, StrawberryField)
@@ -326,6 +272,7 @@ def input(
326
272
  cls: T,
327
273
  *,
328
274
  name: Optional[str] = None,
275
+ one_of: Optional[bool] = None,
329
276
  description: Optional[str] = None,
330
277
  directives: Optional[Sequence[object]] = (),
331
278
  ) -> T:
@@ -339,6 +286,7 @@ def input(
339
286
  def input(
340
287
  *,
341
288
  name: Optional[str] = None,
289
+ one_of: Optional[bool] = None,
342
290
  description: Optional[str] = None,
343
291
  directives: Optional[Sequence[object]] = (),
344
292
  ) -> Callable[[T], T]:
@@ -349,6 +297,7 @@ def input(
349
297
  cls: Optional[T] = None,
350
298
  *,
351
299
  name: Optional[str] = None,
300
+ one_of: Optional[bool] = None,
352
301
  description: Optional[str] = None,
353
302
  directives: Optional[Sequence[object]] = (),
354
303
  ):
@@ -359,6 +308,11 @@ def input(
359
308
  >>> field_abc: str = "ABC"
360
309
  """
361
310
 
311
+ from strawberry.schema_directives import OneOf
312
+
313
+ if one_of:
314
+ directives = (*(directives or ()), OneOf())
315
+
362
316
  return type( # type: ignore # not sure why mypy complains here
363
317
  cls,
364
318
  name=name,
@@ -56,7 +56,10 @@ def validate_document(
56
56
  document: DocumentNode,
57
57
  validation_rules: Tuple[Type[ASTValidationRule], ...],
58
58
  ) -> List[GraphQLError]:
59
- validation_rules += (OneOfInputValidationRule,)
59
+ validation_rules = (
60
+ *validation_rules,
61
+ OneOfInputValidationRule,
62
+ )
60
63
  return validate(
61
64
  schema,
62
65
  document,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: strawberry-graphql
3
- Version: 0.227.0.dev1713463204
3
+ Version: 0.227.0.dev1713475585
4
4
  Summary: A library for creating GraphQL APIs
5
5
  Home-page: https://strawberry.rocks/
6
6
  License: MIT
@@ -1,4 +1,4 @@
1
- strawberry/__init__.py,sha256=O2Izq7j-7oMXp3U87Qvmadx2pVBrAf0BDbNV4Vtrh-o,1138
1
+ strawberry/__init__.py,sha256=NP_R8Benm6W-v3Qqj3MSPm_CMickSCJIMaW2sZZ5oGs,1104
2
2
  strawberry/__main__.py,sha256=3U77Eu21mJ-LY27RG-JEnpbh6Z63wGOom4i-EoLtUcY,59
3
3
  strawberry/aiohttp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  strawberry/aiohttp/handlers/__init__.py,sha256=7EeGIIwrgJYHAS9XJnZLfRGL_GHrligKm39rrVt7qDA,241
@@ -130,7 +130,7 @@ strawberry/federation/argument.py,sha256=5qyJYlQGEZd6iXWseQ7dnnejCYj5HyglfK10jOC
130
130
  strawberry/federation/enum.py,sha256=wpM1z2NOkoBCqTVyD6vJJXoNlcnrNIERt2YpB4R9ybU,2977
131
131
  strawberry/federation/field.py,sha256=HHOs8FL52_jxuYxPiR2EwJsXtk7LyapJeBUPqvJ6pCg,6184
132
132
  strawberry/federation/mutation.py,sha256=0lV5HJwgw4HYR_59pwxWqnPs342HwakTNMc98w5Hb-c,43
133
- strawberry/federation/object_type.py,sha256=nQLFbuS6KvAnGCGie_KXxjmtJC6gnQZFh5FAwFHTH-c,9037
133
+ strawberry/federation/object_type.py,sha256=moxIUYxs7n0WdjtEWhoTesmZ63ymIr_U1qIuaiNrvhY,9302
134
134
  strawberry/federation/scalar.py,sha256=jrSvaqfGEnj_Vl7b-LYMdq_NDMwfdu0t5Pfzlw5WAmU,3807
135
135
  strawberry/federation/schema.py,sha256=9g7jp6eUTTP3atW81dLMtaqeY0tQB4YGdR8beKZ-JX8,13715
136
136
  strawberry/federation/schema_directive.py,sha256=TpqoVeN3-iE-acndIRAVyU4LIXh6FTHz-Pv2kI8zGu0,1719
@@ -160,7 +160,7 @@ strawberry/litestar/controller.py,sha256=CPVnXA36O3OQb9NnHdD3ycox21rarjrS-I2HiOO
160
160
  strawberry/litestar/handlers/graphql_transport_ws_handler.py,sha256=q_erlgzPsxarohRQXGp1yK0mjKyS8vsWntMYEmrQx4s,2008
161
161
  strawberry/litestar/handlers/graphql_ws_handler.py,sha256=vVpjd5rJOldF8aQWEGjmmNd60WE1p6q6hFmB_DtCzDU,2250
162
162
  strawberry/mutation.py,sha256=NROPvHJU1BBxZB7Wj4Okxw4hDIYM59MCpukAGEmSNYA,255
163
- strawberry/object_type.py,sha256=BVrl_d7Y2hUPf7I6kjMggv4eavZkk30SaFyxShHRSnk,12662
163
+ strawberry/object_type.py,sha256=90KgHnOnAY_rlbqMs_89gurmLQmRH9X7PIuh12z6YGs,11623
164
164
  strawberry/parent.py,sha256=mCnJcLBQKwtokXcGxkm5HqGg7Wkst97rn61ViuaotrM,829
165
165
  strawberry/permission.py,sha256=dcKx4Zlg4ZhcxEDBOSWzz0CUN4WPkcc_kJUVuvLLs6w,5925
166
166
  strawberry/printer/__init__.py,sha256=DmepjmgtkdF5RxK_7yC6qUyRWn56U-9qeZMbkztYB9w,62
@@ -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=nmbcOeUih6mKgxLT6w6psjmwKSEw6FbIlJUply5tKyM,11113
189
+ strawberry/schema/execute.py,sha256=dwxMrJrR2Qdd1nPGcIS9-Viq7h5qtPfsD6qdujALoMw,11153
190
190
  strawberry/schema/name_converter.py,sha256=UdNyd-QtqF2HsDCQK-nsOcLGxDTj4hJwYFNvMtZnpq4,6533
191
191
  strawberry/schema/schema.py,sha256=bfQdLmFXR_BQd80IGO8qa0431cQMUDr22XLNnBL7Tu0,14252
192
192
  strawberry/schema/schema_converter.py,sha256=_DfYbWLhbtjBR-w596O5xUwTd3OvHS0P7e5G52JaKXI,35956
@@ -244,8 +244,8 @@ strawberry/utils/logging.py,sha256=flS7hV0JiIOEdXcrIjda4WyIWix86cpHHFNJL8gl1y4,7
244
244
  strawberry/utils/operation.py,sha256=Um-tBCPl3_bVFN2Ph7o1mnrxfxBes4HFCj6T0x4kZxE,1135
245
245
  strawberry/utils/str_converters.py,sha256=avIgPVLg98vZH9mA2lhzVdyyjqzLsK2NdBw9mJQ02Xk,813
246
246
  strawberry/utils/typing.py,sha256=Qxz1LwyVsNGV7LQW1dFsaUbsswj5LHBOdKLMom5eyEA,13491
247
- strawberry_graphql-0.227.0.dev1713463204.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
248
- strawberry_graphql-0.227.0.dev1713463204.dist-info/METADATA,sha256=euUQigHSQGfU2Zh4INE4XJReh9Q_2EH5Iw8_B4rlmOo,7754
249
- strawberry_graphql-0.227.0.dev1713463204.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
250
- strawberry_graphql-0.227.0.dev1713463204.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
251
- strawberry_graphql-0.227.0.dev1713463204.dist-info/RECORD,,
247
+ strawberry_graphql-0.227.0.dev1713475585.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
248
+ strawberry_graphql-0.227.0.dev1713475585.dist-info/METADATA,sha256=Hl3n4V8EBrYh2QrTGqWT7F08HZDuWGKUZNB7JchFx_s,7754
249
+ strawberry_graphql-0.227.0.dev1713475585.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
250
+ strawberry_graphql-0.227.0.dev1713475585.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
251
+ strawberry_graphql-0.227.0.dev1713475585.dist-info/RECORD,,