strawberry-graphql 0.190.0.dev1687447182__py3-none-any.whl → 0.192.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.
Files changed (35) hide show
  1. strawberry/annotation.py +24 -3
  2. strawberry/arguments.py +6 -2
  3. strawberry/channels/testing.py +22 -13
  4. strawberry/cli/__init__.py +4 -4
  5. strawberry/cli/commands/upgrade/__init__.py +75 -0
  6. strawberry/cli/commands/upgrade/_fake_progress.py +21 -0
  7. strawberry/cli/commands/upgrade/_run_codemod.py +74 -0
  8. strawberry/codemods/__init__.py +0 -0
  9. strawberry/codemods/annotated_unions.py +185 -0
  10. strawberry/exceptions/invalid_union_type.py +23 -3
  11. strawberry/exceptions/utils/source_finder.py +147 -11
  12. strawberry/extensions/field_extension.py +2 -5
  13. strawberry/fastapi/router.py +5 -4
  14. strawberry/federation/union.py +4 -5
  15. strawberry/field.py +116 -75
  16. strawberry/http/__init__.py +1 -3
  17. strawberry/permission.py +3 -166
  18. strawberry/relay/fields.py +2 -0
  19. strawberry/relay/types.py +14 -4
  20. strawberry/schema/schema.py +1 -1
  21. strawberry/schema/schema_converter.py +106 -38
  22. strawberry/subscriptions/protocols/graphql_transport_ws/handlers.py +20 -8
  23. strawberry/subscriptions/protocols/graphql_transport_ws/types.py +1 -1
  24. strawberry/subscriptions/protocols/graphql_ws/handlers.py +4 -7
  25. strawberry/type.py +2 -2
  26. strawberry/types/type_resolver.py +7 -29
  27. strawberry/types/types.py +6 -0
  28. strawberry/union.py +46 -17
  29. strawberry/utils/typing.py +21 -0
  30. {strawberry_graphql-0.190.0.dev1687447182.dist-info → strawberry_graphql-0.192.1.dist-info}/METADATA +1 -1
  31. {strawberry_graphql-0.190.0.dev1687447182.dist-info → strawberry_graphql-0.192.1.dist-info}/RECORD +34 -30
  32. strawberry/exceptions/permission_fail_silently_requires_optional.py +0 -52
  33. {strawberry_graphql-0.190.0.dev1687447182.dist-info → strawberry_graphql-0.192.1.dist-info}/LICENSE +0 -0
  34. {strawberry_graphql-0.190.0.dev1687447182.dist-info → strawberry_graphql-0.192.1.dist-info}/WHEEL +0 -0
  35. {strawberry_graphql-0.190.0.dev1687447182.dist-info → strawberry_graphql-0.192.1.dist-info}/entry_points.txt +0 -0
@@ -2,7 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  import dataclasses
4
4
  import sys
5
- from typing import Dict, List, Type, TypeVar, cast
5
+ from typing import Dict, List, Type
6
6
 
7
7
  from strawberry.annotation import StrawberryAnnotation
8
8
  from strawberry.exceptions import (
@@ -14,23 +14,6 @@ from strawberry.field import StrawberryField
14
14
  from strawberry.private import is_private
15
15
  from strawberry.type import has_object_definition
16
16
  from strawberry.unset import UNSET
17
- from strawberry.utils.inspect import get_specialized_type_var_map
18
-
19
-
20
- def _resolve_specialized_type_var(cls: Type, type_: Type) -> Type:
21
- if isinstance(type_, TypeVar):
22
- specialized_type_var_map = get_specialized_type_var_map(cls)
23
- # If type_ is specialized and a TypeVar, replace it with its
24
- # mapped type
25
- if specialized_type_var_map and type_ in specialized_type_var_map:
26
- return specialized_type_var_map[type_]
27
- else:
28
- specialized_type_var_map = get_specialized_type_var_map(type_)
29
- # If type_ is specialized, copy its type_var_map to the definition
30
- if specialized_type_var_map:
31
- return type_.__strawberry_definition__.copy_with(specialized_type_var_map)
32
-
33
- return type_
34
17
 
35
18
 
36
19
  def _get_fields(cls: Type) -> List[StrawberryField]:
@@ -138,14 +121,11 @@ def _get_fields(cls: Type) -> List[StrawberryField]:
138
121
  # Note: We do this here rather in the `Strawberry.type` setter
139
122
  # function because at that point we don't have a link to the object
140
123
  # type that the field as attached to.
141
- if isinstance(field.type_annotation, StrawberryAnnotation):
142
- type_annotation = field.type_annotation
143
- type_annotation.annotation = _resolve_specialized_type_var(
144
- cls,
145
- cast(type, type_annotation.annotation),
146
- )
147
- if type_annotation.namespace is None:
148
- type_annotation.set_namespace_from_field(field)
124
+ if (
125
+ isinstance(field.type_annotation, StrawberryAnnotation)
126
+ and field.type_annotation.namespace is None
127
+ ):
128
+ field.type_annotation.set_namespace_from_field(field)
149
129
 
150
130
  # Create a StrawberryField for fields that didn't use strawberry.field
151
131
  else:
@@ -153,8 +133,6 @@ def _get_fields(cls: Type) -> List[StrawberryField]:
153
133
  if is_private(field.type):
154
134
  continue
155
135
 
156
- field_type = _resolve_specialized_type_var(cls, field.type)
157
-
158
136
  origin = origins.get(field.name, cls)
159
137
  module = sys.modules[origin.__module__]
160
138
 
@@ -163,7 +141,7 @@ def _get_fields(cls: Type) -> List[StrawberryField]:
163
141
  python_name=field.name,
164
142
  graphql_name=None,
165
143
  type_annotation=StrawberryAnnotation(
166
- annotation=field_type,
144
+ annotation=field.type,
167
145
  namespace=module.__dict__,
168
146
  ),
169
147
  origin=origin,
strawberry/types/types.py CHANGED
@@ -5,6 +5,7 @@ from typing import (
5
5
  TYPE_CHECKING,
6
6
  Any,
7
7
  Callable,
8
+ Dict,
8
9
  List,
9
10
  Mapping,
10
11
  Optional,
@@ -21,6 +22,7 @@ from strawberry.type import (
21
22
  WithStrawberryObjectDefinition,
22
23
  )
23
24
  from strawberry.utils.deprecations import DEPRECATION_MESSAGES, DeprecatedDescriptor
25
+ from strawberry.utils.inspect import get_specialized_type_var_map
24
26
  from strawberry.utils.typing import (
25
27
  is_generic as is_type_generic,
26
28
  )
@@ -134,6 +136,10 @@ class StrawberryObjectDefinition(StrawberryType):
134
136
  def is_specialized_generic(self) -> bool:
135
137
  return self.is_generic and not getattr(self.origin, "__parameters__", None)
136
138
 
139
+ @property
140
+ def specialized_type_var_map(self) -> Optional[Dict[TypeVar, type]]:
141
+ return get_specialized_type_var_map(self.origin)
142
+
137
143
  @property
138
144
  def type_params(self) -> List[TypeVar]:
139
145
  type_params: List[TypeVar] = []
strawberry/union.py CHANGED
@@ -1,6 +1,8 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import itertools
4
+ import sys
5
+ import warnings
4
6
  from itertools import chain
5
7
  from typing import (
6
8
  TYPE_CHECKING,
@@ -28,6 +30,7 @@ from strawberry.exceptions import (
28
30
  UnallowedReturnTypeForUnion,
29
31
  WrongReturnTypeForUnion,
30
32
  )
33
+ from strawberry.exceptions.handler import should_use_rich_exceptions
31
34
  from strawberry.lazy_type import LazyType
32
35
  from strawberry.type import (
33
36
  StrawberryOptional,
@@ -47,6 +50,10 @@ if TYPE_CHECKING:
47
50
 
48
51
 
49
52
  class StrawberryUnion(StrawberryType):
53
+ # used for better error messages
54
+ _source_file: Optional[str] = None
55
+ _source_line: Optional[int] = None
56
+
50
57
  def __init__(
51
58
  self,
52
59
  name: Optional[str] = None,
@@ -58,6 +65,8 @@ class StrawberryUnion(StrawberryType):
58
65
  self.type_annotations = type_annotations
59
66
  self.description = description
60
67
  self.directives = directives
68
+ self._source_file = None
69
+ self._source_line = None
61
70
 
62
71
  def __eq__(self, other: object) -> bool:
63
72
  if isinstance(other, StrawberryType):
@@ -75,13 +84,13 @@ class StrawberryUnion(StrawberryType):
75
84
  return hash((self.graphql_name, self.type_annotations, self.description))
76
85
 
77
86
  def __or__(self, other: Union[StrawberryType, type]) -> StrawberryType:
87
+ # TODO: this will be removed in future versions, you should
88
+ # use Annotated[Union[...], strawberry.union(...)] instead
89
+
78
90
  if other is None:
79
91
  # Return the correct notation when using `StrawberryUnion | None`.
80
92
  return StrawberryOptional(of_type=self)
81
93
 
82
- # Raise an error in any other case.
83
- # There is Work in progress to deal with more merging cases, see:
84
- # https://github.com/strawberry-graphql/strawberry/pull/1455
85
94
  raise InvalidTypeForUnionMergeError(self, other)
86
95
 
87
96
  @property
@@ -222,30 +231,28 @@ class StrawberryUnion(StrawberryType):
222
231
 
223
232
  # Can't confidently assert that these types are valid/invalid within Unions
224
233
  # until full type resolving stage is complete
234
+
225
235
  ignored_types = (LazyType, TypeVar)
236
+
226
237
  if isinstance(type_, ignored_types):
227
238
  return True
239
+
240
+ if isinstance(type_, StrawberryUnion):
241
+ return True
242
+
228
243
  if get_origin(type_) is Annotated:
229
244
  return True
230
245
 
231
246
  return False
232
247
 
233
248
 
234
- Types = TypeVar("Types", bound=Type)
235
-
236
-
237
- # We return a Union type here in order to allow to use the union type as type
238
- # annotation.
239
- # For the `types` argument we'd ideally use a TypeVarTuple, but that's not
240
- # yet supported in any python implementation (or in typing_extensions).
241
- # See https://www.python.org/dev/peps/pep-0646/ for more information
242
249
  def union(
243
250
  name: str,
244
- types: Collection[Types],
251
+ types: Optional[Collection[Type[Any]]] = None,
245
252
  *,
246
253
  description: Optional[str] = None,
247
254
  directives: Iterable[object] = (),
248
- ) -> Union[Types]:
255
+ ) -> StrawberryUnion:
249
256
  """Creates a new named Union type.
250
257
 
251
258
  Example usages:
@@ -254,9 +261,33 @@ def union(
254
261
  ... class A: ...
255
262
  >>> @strawberry.type
256
263
  ... class B: ...
257
- >>> strawberry.union("Name", (A, Optional[B]))
264
+ >>> Annotated[A | B, strawberry.union("Name")]
258
265
  """
259
266
 
267
+ if types is None:
268
+ union = StrawberryUnion(
269
+ name=name,
270
+ description=description,
271
+ directives=directives,
272
+ )
273
+
274
+ if should_use_rich_exceptions():
275
+ frame = sys._getframe(1)
276
+
277
+ union._source_file = frame.f_code.co_filename
278
+ union._source_line = frame.f_lineno
279
+
280
+ return union
281
+
282
+ warnings.warn(
283
+ (
284
+ "Passing types to `strawberry.union` is deprecated. Please use "
285
+ f'{name} = Annotated[Union[A, B], strawberry.union("{name}")] instead'
286
+ ),
287
+ DeprecationWarning,
288
+ stacklevel=2,
289
+ )
290
+
260
291
  # Validate types
261
292
  if not types:
262
293
  raise TypeError("No types passed to `union`")
@@ -267,11 +298,9 @@ def union(
267
298
  if not StrawberryUnion.is_valid_union_type(type_):
268
299
  raise InvalidUnionTypeError(union_name=name, invalid_type=type_)
269
300
 
270
- union_definition = StrawberryUnion(
301
+ return StrawberryUnion(
271
302
  name=name,
272
303
  type_annotations=tuple(StrawberryAnnotation(type_) for type_ in types),
273
304
  description=description,
274
305
  directives=directives,
275
306
  )
276
-
277
- return union_definition # type: ignore
@@ -1,4 +1,5 @@
1
1
  import ast
2
+ import dataclasses
2
3
  import sys
3
4
  import typing
4
5
  from functools import lru_cache
@@ -161,6 +162,26 @@ def is_type_var(annotation: Type) -> bool:
161
162
  return isinstance(annotation, TypeVar)
162
163
 
163
164
 
165
+ def is_classvar(cls: type, annotation: Union[ForwardRef, str]) -> bool:
166
+ """Returns True if the annotation is a ClassVar."""
167
+ # This code was copied from the dataclassses cpython implementation to check
168
+ # if a field is annotated with ClassVar or not, taking future annotations
169
+ # in consideration.
170
+ if dataclasses._is_classvar(annotation, typing): # type: ignore
171
+ return True
172
+
173
+ annotation_str = (
174
+ annotation.__forward_arg__ if isinstance(annotation, ForwardRef) else annotation
175
+ )
176
+ return isinstance(annotation_str, str) and dataclasses._is_type( # type: ignore
177
+ annotation_str,
178
+ cls,
179
+ typing,
180
+ typing.ClassVar,
181
+ dataclasses._is_classvar, # type: ignore
182
+ )
183
+
184
+
164
185
  def get_parameters(annotation: Type) -> Union[Tuple[object], Tuple[()]]:
165
186
  if (
166
187
  isinstance(annotation, _GenericAlias)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: strawberry-graphql
3
- Version: 0.190.0.dev1687447182
3
+ Version: 0.192.1
4
4
  Summary: A library for creating GraphQL APIs
5
5
  Home-page: https://strawberry.rocks/
6
6
  License: MIT
@@ -7,8 +7,8 @@ strawberry/aiohttp/handlers/graphql_ws_handler.py,sha256=0wy0IjBapHwlkfMhVk6frgp
7
7
  strawberry/aiohttp/test/__init__.py,sha256=4xxdUZtIISSOwjrcnmox7AvT4WWjowCm5bUuPdQneMg,71
8
8
  strawberry/aiohttp/test/client.py,sha256=tlpHymSWqhiQbLmKwodcaX2vdc8BW1IaNTFTHlWKlOY,1323
9
9
  strawberry/aiohttp/views.py,sha256=l85Dy_-e6-19t5szkWn2NQZAkkqSQ-qT47ZXRDXOyfE,5705
10
- strawberry/annotation.py,sha256=Zss1xrO-sbA7cXZnJOzvodRiybfxcgawkXcBfZCGkP4,9899
11
- strawberry/arguments.py,sha256=WjURffvXSJZpF_SZNY7xGRZ_gDl1tqB7hwyN0IiwCfg,8073
10
+ strawberry/annotation.py,sha256=yYVf-JaRDDuqGiN3hmXpfheR5hE9k48FVdiLP9uzaVA,10542
11
+ strawberry/arguments.py,sha256=iAZwc0wYVWyt2ou_7yabw1xzUe9csLZ-iLHONgx0h5s,8217
12
12
  strawberry/asgi/__init__.py,sha256=dXiMHkXfsATl_gDklKnmkgv93SFr6TMqflxV5qzsGIw,6629
13
13
  strawberry/asgi/handlers/__init__.py,sha256=rz5Gth2eJUn7tDq2--99KSNFeMdDPpLFCkfA7vge0cI,235
14
14
  strawberry/asgi/handlers/graphql_transport_ws_handler.py,sha256=czeQetwtgpOliJP81PzUQHjOUa8T8l58nKQsP0NS5ro,2080
@@ -25,13 +25,16 @@ strawberry/channels/handlers/graphql_ws_handler.py,sha256=PHRkwnXt3tY4E0XBVHh4hp
25
25
  strawberry/channels/handlers/http_handler.py,sha256=NWdzwR5zgn1WqePbtkw6rqsy-iqky37naC0BawxLcJc,8810
26
26
  strawberry/channels/handlers/ws_handler.py,sha256=sHL44eay4tNoKzkrRn3WewSYH-3ZSJzxJpmBJ-aTkeM,4650
27
27
  strawberry/channels/router.py,sha256=dyOBbSF8nFiygP0zz6MM14mhkvFQAEbbLBXzcpubSHM,1927
28
- strawberry/channels/testing.py,sha256=QYMMaO_xPrbrSIMqL8C1WzkRU090xo2RmDvDbatWUhQ,4848
29
- strawberry/cli/__init__.py,sha256=ApfZAn-DDLRhwOz9C-3cy3yztTrgLB-UxWIXWTLbVtE,202
28
+ strawberry/channels/testing.py,sha256=MJIjPtshwOF5mXOy7atUYm8AF_7hihqczhqvMMZf2yw,5363
29
+ strawberry/cli/__init__.py,sha256=jgqzwsDTFyEJj196rlOf5yrJqyzXYNqEs02bI7ZPFVI,296
30
30
  strawberry/cli/app.py,sha256=tTMBV1pdWqMcwjWO2yn-8oLDhMhfJvUzyQtWs75LWJ0,54
31
31
  strawberry/cli/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
32
  strawberry/cli/commands/codegen.py,sha256=hiz9B6RipCUqn8_jgXlwEACSnLB2C0izm1FiqXEsvFA,4344
33
33
  strawberry/cli/commands/export_schema.py,sha256=vI3zhhiLE8C7LH2VcJyqDscZftRz2hUPnbesMjh5C6g,668
34
34
  strawberry/cli/commands/server.py,sha256=527LH6H7Kor2MPUs1ZsXI8LpLaPv8GbsPloWvk3h-cA,2169
35
+ strawberry/cli/commands/upgrade/__init__.py,sha256=5vvuMfHQiga7GcWaHpJQfjBuIpK-k5v_EAuQSvdZTAU,2166
36
+ strawberry/cli/commands/upgrade/_fake_progress.py,sha256=19gnWH4vqcRrGM8UWryCEFMr_IGCV2lVtmmV2BAAihc,476
37
+ strawberry/cli/commands/upgrade/_run_codemod.py,sha256=Afun9I5iB7Y_llrJ5oKOnx0xAX635T-ngb6yokFyzgs,2031
35
38
  strawberry/cli/constants.py,sha256=GhhDZOl9lN4glq50OI1oSbPSGqQXEarZ6r_Grq8pcpI,138
36
39
  strawberry/cli/debug_server.py,sha256=wyczYrKHT-XHLQNkW72nY5eHuKoIscHAXpI4G-DRxLg,967
37
40
  strawberry/cli/utils/__init__.py,sha256=RhfKIsINPYzzCBTAyVh9_YOYUY8fgWMYl9b9lFHBOpw,678
@@ -44,6 +47,8 @@ strawberry/codegen/plugins/python.py,sha256=ADGEQQVRIwAHgpi_b76sUx6a8sjmNWfQ84r7
44
47
  strawberry/codegen/plugins/typescript.py,sha256=QhabDXIlgbGcb3U7Jr0HHRYcsFxPT86IH0MDIpe-6SQ,3610
45
48
  strawberry/codegen/query_codegen.py,sha256=8XFxPzwCcQXZkld4Y41n-35zc6FTiqq-zglcCfcT-eg,25798
46
49
  strawberry/codegen/types.py,sha256=zU2NWUMTAy1dfPcDXZE5bB9FUoIQv2Txnrn55h69Xqk,3430
50
+ strawberry/codemods/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
51
+ strawberry/codemods/annotated_unions.py,sha256=la6ayC5vUv_UBqREyiMOC30rKN1zx0ApukOPLvezLHo,5904
47
52
  strawberry/custom_scalar.py,sha256=Wa3j-713zzHrdqtRjeuYG11BJsXvgcP2VP7fmfr9mKg,5670
48
53
  strawberry/dataloader.py,sha256=HO8pnK9kQEJfvpFaMHnpSESvkef2c6AZHCQSp_aZJno,7697
49
54
  strawberry/directive.py,sha256=chHtjNN5G_doeGO03olldpi7qB11_ACESzjIkDkNK7c,2330
@@ -60,20 +65,19 @@ strawberry/exceptions/exception.py,sha256=EpJXcxPavYiE1o2yXkLKhtOyLNlyE76r5b8qGF
60
65
  strawberry/exceptions/exception_source.py,sha256=Krr9KprJLMuiDBYRzRYULvLIuSjd8gIaiXmPoPCHEDo,404
61
66
  strawberry/exceptions/handler.py,sha256=P136yJ_LaUxk7XPbyKfhMWF_pGMgBcWhE7uw9Rq28tU,2914
62
67
  strawberry/exceptions/invalid_argument_type.py,sha256=sH5FV1-VpwMKubif4zx2EiEzA51-tjmbfK3ntluMj-I,2197
63
- strawberry/exceptions/invalid_union_type.py,sha256=Bu4KeYLkm0tydYzMmhJ0fyLb7gA2xRwJx4dPpxo1-Vg,3080
68
+ strawberry/exceptions/invalid_union_type.py,sha256=Jr7O3zl-ylFbsDf1rNx-REjwo3PIynzlYblnZyifbuY,3631
64
69
  strawberry/exceptions/missing_arguments_annotations.py,sha256=F4gKF_jaU2jSmmgpjFSeFhHK-Y3aagI-U4cvFEecc2o,1984
65
70
  strawberry/exceptions/missing_field_annotation.py,sha256=M1zawqnDTlWVdlPOGkYfrsvHryWX-zA5Uc-wxK6dWJw,1354
66
71
  strawberry/exceptions/missing_return_annotation.py,sha256=i7M6RSmtWxMRW2kZ4NdIRE36yerKVZZYCLKtvzUb1_A,1389
67
72
  strawberry/exceptions/not_a_strawberry_enum.py,sha256=Ujn3W_pjGiqSOO0bYd3emDFyvrXUFYaizecVC9VTRd0,1121
68
73
  strawberry/exceptions/object_is_not_a_class.py,sha256=WOzTBfz55OPaOlUMEbPx3ry1ZJSqr51k_x0kgB8GVw0,2024
69
74
  strawberry/exceptions/object_is_not_an_enum.py,sha256=z83PHOAAZhueX4csKl1e2qfEvLIfYxK2DowUNS2j7Hw,1285
70
- strawberry/exceptions/permission_fail_silently_requires_optional.py,sha256=iGdxYZ5dhDWci_bW5vd6QFQSqkzmLOnmGZ-hsrEm9h4,1742
71
75
  strawberry/exceptions/private_strawberry_field.py,sha256=l7wktatCBwdSLzKrbvVIXWQhoBaf_039hKv3663WWvk,1350
72
76
  strawberry/exceptions/scalar_already_registered.py,sha256=JQK1ZwKxP7K5a8kJpYLagY9Td6tOn8VctS1lkKVEzBU,1864
73
77
  strawberry/exceptions/syntax.py,sha256=OCz2Ai1Yn0jonRZXCDI2h30tPNsa8L5wMU8vcqIO4cg,1758
74
78
  strawberry/exceptions/unresolved_field_type.py,sha256=fAtoJqHyv6euAJerEZRSxsYizLN2IpIW_11ZyNZ2QXs,1880
75
79
  strawberry/exceptions/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
76
- strawberry/exceptions/utils/source_finder.py,sha256=6pbqt6h4PDwDGvziw6jLPQjxQo_RwgpjeOk_VGhJI4w,14964
80
+ strawberry/exceptions/utils/source_finder.py,sha256=8BmBoU1CgqFeOFxKgL5tCdETRidwTe0TNe7wHXdGvDs,20052
77
81
  strawberry/experimental/__init__.py,sha256=n6Ytr6wBgXt47jLY8rEXQs7G4gZEkm9BCLL0Q8opWfw,94
78
82
  strawberry/experimental/pydantic/__init__.py,sha256=jlsYH1j_9W4ieRpUKgt5zQPERDL7nc1ZBNQ3dAhJs8w,241
79
83
  strawberry/experimental/pydantic/conversion.py,sha256=Oc5eOGCMEW5QHIiSzatZGx54uYD2gdNWssQ1eWY6PGk,4143
@@ -95,7 +99,7 @@ strawberry/extensions/base_extension.py,sha256=IRsssFnsipe2FJyZ3gK6fZPhB4TjUCpGV
95
99
  strawberry/extensions/context.py,sha256=hBCbOEzf3S0V3Q0-xj9CaLKgO-rSVrtjGtl_JoTnvgg,6964
96
100
  strawberry/extensions/directives.py,sha256=ulS80mDTDE-pM8d9IEk16O84kzjkXM1P4vMcqYp5Q1U,2968
97
101
  strawberry/extensions/disable_validation.py,sha256=eLlZ0SEuvK3HUSvLm4PpdgrtP30ckG25sV3hGd2W-sM,720
98
- strawberry/extensions/field_extension.py,sha256=ePQxQdo2uxBrfTmzWpUZU2mJMcuYdT00sjNAQUyLt1k,5667
102
+ strawberry/extensions/field_extension.py,sha256=alCie3SySeZZDqdveN1QQPxKyJC3TbGKkbnPa-qJoyk,5599
99
103
  strawberry/extensions/mask_errors.py,sha256=D6Bga-op1vwdA07wpSZqssl1-wr3Pb56rQcjjyOv7UQ,1425
100
104
  strawberry/extensions/max_aliases.py,sha256=ID5nF-Dh0_N_4dPGkbDfWdGrBW7htbLK7-XYFNnFpFQ,2361
101
105
  strawberry/extensions/max_tokens.py,sha256=Fa-Zcugo2Y1WRINTdTRWzsRhAnBFCLAoplfnlS8j_nY,1014
@@ -116,7 +120,7 @@ strawberry/fastapi/context.py,sha256=hxLoihS9TM16iyUPiAGQf-0i4wv975CJYHHI6EwOewA
116
120
  strawberry/fastapi/handlers/__init__.py,sha256=TziBHyibYBOGiidjpCkjNThYbVY7K_nt0hnRLVHVh3I,241
117
121
  strawberry/fastapi/handlers/graphql_transport_ws_handler.py,sha256=k8BhP1xQAFc1GnbQoFhi8KQSWwY1x-ngR9qIDVJW_ic,549
118
122
  strawberry/fastapi/handlers/graphql_ws_handler.py,sha256=U84lpd7Lxl2bEnFr9QroswmEaMO5ipLCZTeYRAaZH-g,504
119
- strawberry/fastapi/router.py,sha256=l7V5fivGvchqy1S3lkc6phtX4F-X8xjmJG1KYmCN5mA,11400
123
+ strawberry/fastapi/router.py,sha256=ZcFU8wpkVsC3wyEDMNnJ5n6MhD7rpt-CYAzmCfWpEmE,11470
120
124
  strawberry/federation/__init__.py,sha256=FeUxLiBVuk9TKBmJJi51SeUaI8c80rS8hbl9No-hjII,535
121
125
  strawberry/federation/argument.py,sha256=5qyJYlQGEZd6iXWseQ7dnnejCYj5HyglfK10jOCIJBg,802
122
126
  strawberry/federation/enum.py,sha256=KpcQfL_efoaNBbb2gl-CYO5PtyVsuyz1LcluTMuRcks,2185
@@ -128,8 +132,8 @@ strawberry/federation/schema.py,sha256=XCFf7m15oACjRB6-kHJyxpcFaRy8F0H4Xki5UUXhC
128
132
  strawberry/federation/schema_directive.py,sha256=TpqoVeN3-iE-acndIRAVyU4LIXh6FTHz-Pv2kI8zGu0,1719
129
133
  strawberry/federation/schema_directives.py,sha256=TKIAqmMEyq0SwNxiNr0YLiqAUjS5kKxZyHW_NPS5nkM,4780
130
134
  strawberry/federation/types.py,sha256=mM70g1aLgjplOc3SdtuJjy7NAKFLv35Z4BDC4s_j5us,301
131
- strawberry/federation/union.py,sha256=PN8TtF5h5BvT1-QMDTNdc-y3Wk_HSwyMfGHNLPfIirw,980
132
- strawberry/field.py,sha256=x5-t7eao9IYB9hLmvAe1yT7XYQ321Udjb7HvSuP0D_E,17250
135
+ strawberry/federation/union.py,sha256=QXeh-nhApqFtXa3To9MX_IwvtwErZBhWYnssUK7JB2E,1005
136
+ strawberry/field.py,sha256=i8RZ-eAVakucF4-5sDSQjYagwdE8FqjKshi0vztTyB0,18478
133
137
  strawberry/field_extensions/__init__.py,sha256=0z6RG9jEO7jpAuyEaQhRI5A_30rdcvsBM0qMhLs8y2s,96
134
138
  strawberry/field_extensions/input_mutation.py,sha256=U9TlPDO2kk8LP5RsfKolD6j-YUmTWYWZrj7mI7mDfjs,2683
135
139
  strawberry/file_uploads/__init__.py,sha256=v2-6FGBqnTnMPSUTFOiXpIutDMl-ga0PFtw5tKlcagk,50
@@ -138,7 +142,7 @@ strawberry/file_uploads/utils.py,sha256=U8gk1aHjWOBa_Opyvc47h6OpYToGq1QiSnEkI2kp
138
142
  strawberry/flask/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
139
143
  strawberry/flask/graphiql.py,sha256=YnLRPOJRdzyG62T2TuFOqQ1WX0uiIU6xHLtOvmyBpw4,275
140
144
  strawberry/flask/views.py,sha256=GlK2zovhrcwVirl3qoacM1oHrPzVXHk7xEpKm_4wRC8,4966
141
- strawberry/http/__init__.py,sha256=MMp6ZM0nqV5NrqCwhpSr9KZE5UklJIxRDwd_OgsQnhs,1493
145
+ strawberry/http/__init__.py,sha256=t-Inc7JHEr1Tr_Afu9uAb042ujpYx-jEbe_gqCfuOlc,1403
142
146
  strawberry/http/async_base_view.py,sha256=sNnUXszBJnHzGnl4ssXoH9GhBcJzkx4_VKQIqzQ2V5M,6894
143
147
  strawberry/http/base.py,sha256=GkpqEJ2Xxr3G5TQVKOlOfn2dmOkv0tFBlXEp5Qbu5lY,1865
144
148
  strawberry/http/exceptions.py,sha256=4lgbMQ-UF2HHu2PczqkS1vGAcU08cEGY03FMrVvjqeA,155
@@ -149,7 +153,7 @@ strawberry/http/typevars.py,sha256=Kc2xRx3Jic7AruCtv3FOuv2hqeQQzcCLP1E53Nwmpts,2
149
153
  strawberry/lazy_type.py,sha256=Bvq5q_GBX_DyGVh0YWSl0KMHRLmbgBlAHn7firGqbgI,3103
150
154
  strawberry/mutation.py,sha256=NROPvHJU1BBxZB7Wj4Okxw4hDIYM59MCpukAGEmSNYA,255
151
155
  strawberry/object_type.py,sha256=5nmZmvFhs-73IvUF0qlZ79bQQpQkIa73lj4BvTplZEg,11303
152
- strawberry/permission.py,sha256=BnfEi77pzAAh6PyeA6j4GyTGeQk82mu9mtof6Unxm_Q,5913
156
+ strawberry/permission.py,sha256=jHkzU7iS1-0QkD3hr4RGfSx57X1ltD7g4k-KICNMVCY,512
153
157
  strawberry/printer/__init__.py,sha256=DmepjmgtkdF5RxK_7yC6qUyRWn56U-9qeZMbkztYB9w,62
154
158
  strawberry/printer/ast_from_value.py,sha256=MFIX2V51d9ocRvD0Njemjk8YIzKh2BB1g2iUcX6a3d8,4946
155
159
  strawberry/printer/printer.py,sha256=x6qGNchRAb75yBxOJV8jzHYSE42uaJns_PC9ulKVsYI,17454
@@ -157,8 +161,8 @@ strawberry/private.py,sha256=AUagjVgVzr5waF_ZW9Ma0_b4IlJY8nhYonZKBpmt52M,613
157
161
  strawberry/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
158
162
  strawberry/relay/__init__.py,sha256=Vi4btvA_g6Cj9Tk_F9GCSegapIf2WqkOWV8y3P0cTCs,553
159
163
  strawberry/relay/exceptions.py,sha256=gZuyozUaI3f0yAjT6VA0JaxULmPK3GIFw_3PK6s5Kiw,3915
160
- strawberry/relay/fields.py,sha256=yfxwiTgDPdBBpBKxmm5DzBIVVwaDUWH3kJDJXSW4ODw,15494
161
- strawberry/relay/types.py,sha256=xnj-L-UlXtajww4MOiOEKtjM4rHQhr3m3FMd6gukjaQ,28490
164
+ strawberry/relay/fields.py,sha256=m_k1s7xXA3eB1boCj-F3JYZcy5sNf7fevbOyTIly4F4,15591
165
+ strawberry/relay/types.py,sha256=SRrQWoAkzDmcWriWglmczQ5CgjmJ3edOBWvJ4zDY3R8,28947
162
166
  strawberry/relay/utils.py,sha256=Dot-2Y6ix93V3j8T3Os3aDoCBFMf8nUCVA8H_YSWqKY,1694
163
167
  strawberry/resolvers.py,sha256=g7_g3jmXszziGydY1UG6IItf9s6B1lGLUCnwW1kb8U0,224
164
168
  strawberry/sanic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -174,8 +178,8 @@ strawberry/schema/config.py,sha256=N9KsqkSTnm5snizoBZAVneaWQprhaTd8PFyMuR-jfUs,6
174
178
  strawberry/schema/exceptions.py,sha256=_9Ua-lLRCJfbtd8B6MXILNKGI2SwHkcBNkAHYM7ITp8,534
175
179
  strawberry/schema/execute.py,sha256=6U-JOTtYn6qQgEpHpJvqkm9z5n5IwsdCSjy8yFgMVcw,10295
176
180
  strawberry/schema/name_converter.py,sha256=KZHCYy29sS1tvlPu0H46PJwAclsFVbMxYG7aHUw8xGQ,6582
177
- strawberry/schema/schema.py,sha256=np9AgDbP-Rtw3bbVV3QnS0iDSt54Nb2AenUAU1aV6ZM,13186
178
- strawberry/schema/schema_converter.py,sha256=ymTKVrF0ygx-1-bSmNOdhRl7utGmfydpQHBRO2ip6ZA,32045
181
+ strawberry/schema/schema.py,sha256=3ZEOizfj63AwEYUT5pCjU2b0mfUopHqfZYy3jnn8v9E,13183
182
+ strawberry/schema/schema_converter.py,sha256=O-G-JuR2EcJP3y4AtFt1GBwIZvxWOAEnE2mcoMiwYVY,34095
179
183
  strawberry/schema/types/__init__.py,sha256=oHO3COWhL3L1KLYCJNY1XFf5xt2GGtHiMC-UaYbFfnA,68
180
184
  strawberry/schema/types/base_scalars.py,sha256=Z_BmgwLicNexLipGyw6MmZ7OBnkGJU3ySgaY9SwBWrw,1837
181
185
  strawberry/schema/types/concrete_type.py,sha256=HB30G1hMUuuvjAvfSe6ADS35iI_T_wKO-EprVOWTMSs,746
@@ -189,17 +193,17 @@ strawberry/static/graphiql.html,sha256=SnCnMZseGxNgZpFd_wGXiEHswA1JgMyldr16bX6PG
189
193
  strawberry/subscriptions/__init__.py,sha256=AkrFEgvz8T2JL6rxh_kHg9j61C8S3Pm7Q0XbWgLsqKM,90
190
194
  strawberry/subscriptions/protocols/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
191
195
  strawberry/subscriptions/protocols/graphql_transport_ws/__init__.py,sha256=M5oqSp7tCnj3yKcLrQST12JYSOXGk_Z_StTe485oCK8,83
192
- strawberry/subscriptions/protocols/graphql_transport_ws/handlers.py,sha256=1HvQ5yMPtf-eM_I1ojHt3BkMsyQCtBArWKb2mhiT6dU,14168
193
- strawberry/subscriptions/protocols/graphql_transport_ws/types.py,sha256=B8ZC-DEtbRhkfJuWTqqZBQgXkOaJCpwwx6pbMNBms8M,2280
196
+ strawberry/subscriptions/protocols/graphql_transport_ws/handlers.py,sha256=bOzfZLJj32-yswgLIZswbNNOWQTN56qlvn83E2cRocs,14517
197
+ strawberry/subscriptions/protocols/graphql_transport_ws/types.py,sha256=Gxj6kFfk5hn21WJQ5x_C8e-BjvWessweg0dOmCUAY4s,2289
194
198
  strawberry/subscriptions/protocols/graphql_ws/__init__.py,sha256=S30U7VJGNy-rYOGfSc42AS4uS1-_XQEbXnHIudOOSh4,305
195
- strawberry/subscriptions/protocols/graphql_ws/handlers.py,sha256=-UMkF9L7aU0NCtagytV0Mh_IUSwtJR60tz1CD42WQl0,7703
199
+ strawberry/subscriptions/protocols/graphql_ws/handlers.py,sha256=5__6JFqN2MBgd2o6_FkAJ5UZh0z6buXoVl-BbXpKFb8,7532
196
200
  strawberry/subscriptions/protocols/graphql_ws/types.py,sha256=9C4IddwVJXoyVfh158e9t5kYxSWSjqtz31lewefh72w,820
197
201
  strawberry/test/__init__.py,sha256=U3B5Ng7C_H8GpCpfvgZZcfADMw6cor5hm78gS3nDdMI,115
198
202
  strawberry/test/client.py,sha256=MwyXMBzxujPyXt_iqm1BfCaUCIOJUiysbcDQXzHKK34,5717
199
203
  strawberry/tools/__init__.py,sha256=pdGpZx8wpq03VfUZJyF9JtYxZhGqzzxCiipsalWxJX4,127
200
204
  strawberry/tools/create_type.py,sha256=QxLRT9-DrSgo6vsu_L818wtlbO3wRtI0dOos0gmn1xk,1593
201
205
  strawberry/tools/merge_types.py,sha256=YZ2GSMoDD82bfuvCT0COpN6SLFVRZpTXFFm9LHUyi10,1014
202
- strawberry/type.py,sha256=OxwZobdaieNGjlTeTlBugdUqttx7wjKEGh6ZUzsa1Mc,6553
206
+ strawberry/type.py,sha256=dGfZkhnqcyhdM43oESEgsFAEIEDSAKQ8YbHv_qJtx3c,6549
203
207
  strawberry/types/__init__.py,sha256=APb1Cjy6bxqFxIfDfempP6eb9NE3LYDwQ3gX7r07lXI,139
204
208
  strawberry/types/execution.py,sha256=wPXvgaWDaF1o_qJ3WzqpVOp64_uGbB87nbyL69Gdy_4,2768
205
209
  strawberry/types/fields/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -207,9 +211,9 @@ strawberry/types/fields/resolver.py,sha256=uDf3GliivpO9mhvGjxb7gbyDUCTKJiIsNS8t5
207
211
  strawberry/types/graphql.py,sha256=3SWZEsa0Zy1eVW6vy75BnB7t9_lJVi6TBV3_1j3RNBs,687
208
212
  strawberry/types/info.py,sha256=E883OofhMnXaHURw741AKuc5kWlq5-88zro80qyF0p4,2800
209
213
  strawberry/types/nodes.py,sha256=2ZVa1HOFgHZ96QTfz3QEr1fufi6Sz9hAzcZxsN7KtGE,5026
210
- strawberry/types/type_resolver.py,sha256=BfNQ2FMubi0kUjTK-rTLdYLoZ5xETQe_z1ap6DlYu8U,7387
211
- strawberry/types/types.py,sha256=x6xcs1uh683opp1qKodP_wvDNqRb8A5wdnWU2wSpivQ,6579
212
- strawberry/union.py,sha256=VNedC9hOu5yAUS2UoSly82RD2XGmLM_1ulNiDE0Ybtg,9342
214
+ strawberry/types/type_resolver.py,sha256=_S50GYclrjdwQ0k3SlaVsPwVPTNk8WQ9AuIJIQ-oq5A,6350
215
+ strawberry/types/types.py,sha256=ozwVAoL86zweTpW-Dt3KROAX7bJzV8KLJokZwP3prfg,6800
216
+ strawberry/union.py,sha256=Hp84TxDYFl_q0t1Uz2UVYhJySlMeYS20BLiQvhJEHnE,9890
213
217
  strawberry/unset.py,sha256=_180_Wxvw-umn-URMb3CmO-WegBfZHjVZW0L0RXrQrI,1097
214
218
  strawberry/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
215
219
  strawberry/utils/aio.py,sha256=nRu0VYg9RLpkY90t6UfUlCJhIS1qpmqLdQHlwTOK89g,1608
@@ -225,9 +229,9 @@ strawberry/utils/inspect.py,sha256=EvINTsbjri90OWUAqEG-v0VVp8aQKrgJVBLatOxkPYU,2
225
229
  strawberry/utils/logging.py,sha256=pz1pRJtx5xX2ejGKNN-fG8zPA4SJjnq1HK9xaQpjd4s,1106
226
230
  strawberry/utils/operation.py,sha256=Um-tBCPl3_bVFN2Ph7o1mnrxfxBes4HFCj6T0x4kZxE,1135
227
231
  strawberry/utils/str_converters.py,sha256=VdOnzaxhwJnmQl1Lon0VOjl72uXhM8tLfGxoGwn3arI,657
228
- strawberry/utils/typing.py,sha256=WE64RFkYDdUbhZjWpZeLOwfDALOCPO1PKU3zXZuOeqk,12423
229
- strawberry_graphql-0.190.0.dev1687447182.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
230
- strawberry_graphql-0.190.0.dev1687447182.dist-info/METADATA,sha256=nfG6iMuHixeUbBWo3CGeSEQXW5loBIwGMXd9Q76zINg,7648
231
- strawberry_graphql-0.190.0.dev1687447182.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
232
- strawberry_graphql-0.190.0.dev1687447182.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
233
- strawberry_graphql-0.190.0.dev1687447182.dist-info/RECORD,,
232
+ strawberry/utils/typing.py,sha256=_PvVDZJrT_iciDvIEwwh4knAog6stKe9sLpxqy00GmI,13182
233
+ strawberry_graphql-0.192.1.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
234
+ strawberry_graphql-0.192.1.dist-info/METADATA,sha256=N__Rhm402LA8X0-wbiQ_OlR-VUs9ENuyEq3O_hIAuMc,7634
235
+ strawberry_graphql-0.192.1.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
236
+ strawberry_graphql-0.192.1.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
237
+ strawberry_graphql-0.192.1.dist-info/RECORD,,
@@ -1,52 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from typing import TYPE_CHECKING, Optional
4
-
5
- from strawberry.utils.cached_property import cached_property
6
-
7
- from .exception import StrawberryException
8
- from .utils.source_finder import SourceFinder
9
-
10
- if TYPE_CHECKING:
11
- from ..field import StrawberryField
12
- from .exception_source import ExceptionSource
13
-
14
-
15
- class PermissionFailSilentlyRequiresOptionalError(StrawberryException):
16
- def __init__(self, field: StrawberryField):
17
- self.field = field
18
- self.message = (
19
- "Cannot use fail_silently=True with a non-optional " "or non-list field"
20
- )
21
- self.rich_message = (
22
- "fail_silently permissions can only be used with fields of type "
23
- f"optional or list. Provided field `[underline]{field.name}[/]` "
24
- f"is of type `[underline]{field.type}[/]`"
25
- )
26
- self.annotation_message = "field defined here"
27
- self.suggestion = (
28
- "To fix this error, make sure you apply use `fail_silently`"
29
- " on a field that is either a list or nullable."
30
- )
31
-
32
- super().__init__(self.message)
33
-
34
- @cached_property
35
- def exception_source(self) -> Optional[ExceptionSource]:
36
- origin = self.field.origin
37
- source_finder = SourceFinder()
38
-
39
- source = None
40
- if origin is not None:
41
- source = source_finder.find_class_attribute_from_object(
42
- origin,
43
- self.field.python_name,
44
- )
45
-
46
- # in case it is a function
47
- if source is None and self.field.base_resolver is not None:
48
- source = source_finder.find_function_from_object(
49
- self.field.base_resolver.wrapped_func
50
- )
51
-
52
- return source