strawberry-graphql 0.235.0__py3-none-any.whl → 0.235.1.dev1719337273__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/annotation.py CHANGED
@@ -54,7 +54,7 @@ ASYNC_TYPES = (
54
54
 
55
55
 
56
56
  class StrawberryAnnotation:
57
- __slots__ = "raw_annotation", "namespace", "__eval_cache__"
57
+ __slots__ = "raw_annotation", "namespace", "__resolve_cache__"
58
58
 
59
59
  def __init__(
60
60
  self,
@@ -65,7 +65,7 @@ class StrawberryAnnotation:
65
65
  self.raw_annotation = annotation
66
66
  self.namespace = namespace
67
67
 
68
- self.__eval_cache__: Optional[Type[Any]] = None
68
+ self.__resolve_cache__: Optional[Union[StrawberryType, type]] = None
69
69
 
70
70
  def __eq__(self, other: object) -> bool:
71
71
  if not isinstance(other, StrawberryAnnotation):
@@ -101,19 +101,17 @@ class StrawberryAnnotation:
101
101
  def annotation(self, value: Union[object, str]) -> None:
102
102
  self.raw_annotation = value
103
103
 
104
+ self.__resolve_cache__ = None
105
+
104
106
  def evaluate(self) -> type:
105
107
  """Return evaluated annotation using `strawberry.util.typing.eval_type`."""
106
- evaled_type = self.__eval_cache__
107
- if evaled_type:
108
- return evaled_type
109
-
110
108
  annotation = self.raw_annotation
109
+
111
110
  if isinstance(annotation, str):
112
111
  annotation = ForwardRef(annotation)
113
112
 
114
113
  evaled_type = eval_type(annotation, self.namespace, None)
115
114
 
116
- self.__eval_cache__ = evaled_type
117
115
  return evaled_type
118
116
 
119
117
  def _get_type_with_args(
@@ -131,6 +129,15 @@ class StrawberryAnnotation:
131
129
 
132
130
  def resolve(self) -> Union[StrawberryType, type]:
133
131
  """Return resolved (transformed) annotation."""
132
+ if self.__resolve_cache__ is None:
133
+ self.__resolve_cache__ = self._resolve()
134
+
135
+ return self.__resolve_cache__
136
+
137
+ def _resolve(self) -> Union[StrawberryType, type]:
138
+ # TODO: I wonder if this resolve should be creating types?
139
+ # types should only be created once, in the schema converter maybe?
140
+ # but maybe the cache above is fine
134
141
  evaled_type = cast(Any, self.evaluate())
135
142
 
136
143
  if is_private(evaled_type):
@@ -172,7 +179,7 @@ class StrawberryAnnotation:
172
179
  module = sys.modules[field.origin.__module__]
173
180
  self.namespace = module.__dict__
174
181
 
175
- self.__eval_cache__ = None # Invalidate cache to allow re-evaluation
182
+ self.__resolve_cache__ = None # Invalidate cache to allow re-evaluation
176
183
 
177
184
  def create_concrete_type(self, evaled_type: type) -> type:
178
185
  if has_object_definition(evaled_type):
strawberry/arguments.py CHANGED
@@ -129,7 +129,6 @@ class StrawberryArgument:
129
129
 
130
130
  @property
131
131
  def is_graphql_generic(self) -> bool:
132
- # TODO: double check this
133
132
  from strawberry.schema.compat import is_graphql_generic
134
133
 
135
134
  return is_graphql_generic(self.type)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: strawberry-graphql
3
- Version: 0.235.0
3
+ Version: 0.235.1.dev1719337273
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=Zi1y_XLsZwqX52vvy0Se3S0
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=l5Gb_9twQo1TQuWk7v0dGFry0yM1ivnGztUtwQ_N5-c,6063
10
- strawberry/annotation.py,sha256=YYWKjDUxgwFLuTtHYjrCZTub0R4knUngidDauXovDg8,12887
11
- strawberry/arguments.py,sha256=bIfpFN2kcs4cjmeI8UPV1Xxzm5bb4jmbggejOyouulw,8440
10
+ strawberry/annotation.py,sha256=BH2zt675Gxh4h8GEoewUMLh26WdvT1Xw8UVqkKG5vKM,13192
11
+ strawberry/arguments.py,sha256=yFbL1o9vFemrJSVGadt80wN_ajU1khw2--S0nDjrx78,8406
12
12
  strawberry/asgi/__init__.py,sha256=9s_6505Aa68y_qAgzQV3yXE0IrGVZbuhQ7rIUNPXOlE,6985
13
13
  strawberry/asgi/handlers/__init__.py,sha256=rz5Gth2eJUn7tDq2--99KSNFeMdDPpLFCkfA7vge0cI,235
14
14
  strawberry/asgi/handlers/graphql_transport_ws_handler.py,sha256=obBZ1bQ1R9eZL1_Xcr5eKQObjSPB0FFLtMFj9EAmFc0,2105
@@ -245,8 +245,8 @@ strawberry/utils/logging.py,sha256=flS7hV0JiIOEdXcrIjda4WyIWix86cpHHFNJL8gl1y4,7
245
245
  strawberry/utils/operation.py,sha256=Um-tBCPl3_bVFN2Ph7o1mnrxfxBes4HFCj6T0x4kZxE,1135
246
246
  strawberry/utils/str_converters.py,sha256=avIgPVLg98vZH9mA2lhzVdyyjqzLsK2NdBw9mJQ02Xk,813
247
247
  strawberry/utils/typing.py,sha256=G92wuT2WhEGQrwjek_On2K8l0nyVFtBW3P7I_cfjG-8,13870
248
- strawberry_graphql-0.235.0.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
249
- strawberry_graphql-0.235.0.dist-info/METADATA,sha256=pbG-KszzQKU30_gF1B2tUWz0f9OCMXLoXdlhsiUr-bM,7821
250
- strawberry_graphql-0.235.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
251
- strawberry_graphql-0.235.0.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
252
- strawberry_graphql-0.235.0.dist-info/RECORD,,
248
+ strawberry_graphql-0.235.1.dev1719337273.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
249
+ strawberry_graphql-0.235.1.dev1719337273.dist-info/METADATA,sha256=kPR0Nr5aSHyjpqDjvPEEdt6HXhEID7cpL8CsrxjtVyk,7835
250
+ strawberry_graphql-0.235.1.dev1719337273.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
251
+ strawberry_graphql-0.235.1.dev1719337273.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
252
+ strawberry_graphql-0.235.1.dev1719337273.dist-info/RECORD,,