strawberry-graphql 0.240.3.dev1726159932__py3-none-any.whl → 0.241.0__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.
@@ -3,7 +3,6 @@ from __future__ import annotations
3
3
  from typing import TYPE_CHECKING, Any, Callable, Dict, Tuple
4
4
 
5
5
  from strawberry.extensions import SchemaExtension
6
- from strawberry.types import Info
7
6
  from strawberry.types.nodes import convert_arguments
8
7
  from strawberry.utils.await_maybe import await_maybe
9
8
 
@@ -81,7 +80,9 @@ def process_directive(
81
80
  field_name=info.field_name,
82
81
  type_name=info.parent_type.name,
83
82
  )
84
- arguments[info_parameter.name] = Info(_raw_info=info, _field=field)
83
+ arguments[info_parameter.name] = schema.config.info_class(
84
+ _raw_info=info, _field=field
85
+ )
85
86
  if value_parameter:
86
87
  arguments[value_parameter.name] = value
87
88
  return strawberry_directive, arguments
@@ -3,6 +3,8 @@ from __future__ import annotations
3
3
  from dataclasses import InitVar, dataclass, field
4
4
  from typing import Any, Callable
5
5
 
6
+ from strawberry.types.info import Info
7
+
6
8
  from .name_converter import NameConverter
7
9
 
8
10
 
@@ -13,6 +15,7 @@ class StrawberryConfig:
13
15
  default_resolver: Callable[[Any, str], object] = getattr
14
16
  relay_max_results: int = 100
15
17
  disable_field_suggestions: bool = False
18
+ info_class: type[Info] = Info
16
19
 
17
20
  def __post_init__(
18
21
  self,
@@ -21,5 +24,8 @@ class StrawberryConfig:
21
24
  if auto_camel_case is not None:
22
25
  self.name_converter.auto_camel_case = auto_camel_case
23
26
 
27
+ if not issubclass(self.info_class, Info):
28
+ raise TypeError("`info_class` must be a subclass of strawberry.Info")
29
+
24
30
 
25
31
  __all__ = ["StrawberryConfig"]
@@ -123,18 +123,14 @@ async def _handle_execution_result(
123
123
  context: ExecutionContext,
124
124
  result: Union[GraphQLExecutionResult, ExecutionResult],
125
125
  extensions_runner: SchemaExtensionsRunner,
126
- process_errors: ProcessErrors,
126
+ process_errors: ProcessErrors | None,
127
127
  ) -> ExecutionResult:
128
128
  # Set errors on the context so that it's easier
129
129
  # to access in extensions
130
130
  if result.errors:
131
131
  context.errors = result.errors
132
-
133
- # Run the `Schema.process_errors` function here before
134
- # extensions have a chance to modify them (see the MaskErrors
135
- # extension). That way we can log the original errors but
136
- # only return a sanitised version to the client.
137
- process_errors(result.errors, context)
132
+ if process_errors:
133
+ process_errors(result.errors, context)
138
134
  if isinstance(result, GraphQLExecutionResult):
139
135
  result = ExecutionResult(data=result.data, errors=result.errors)
140
136
  result.extensions = await extensions_runner.get_extensions_results(context)
@@ -171,7 +167,7 @@ async def execute(
171
167
  assert execution_context.graphql_document
172
168
  async with extensions_runner.executing():
173
169
  if not execution_context.result:
174
- res = await await_maybe(
170
+ result = await await_maybe(
175
171
  original_execute(
176
172
  schema,
177
173
  execution_context.graphql_document,
@@ -183,9 +179,20 @@ async def execute(
183
179
  execution_context_class=execution_context_class,
184
180
  )
185
181
  )
186
-
182
+ execution_context.result = result
187
183
  else:
188
- res = execution_context.result
184
+ result = execution_context.result
185
+ # Also set errors on the execution_context so that it's easier
186
+ # to access in extensions
187
+ if result.errors:
188
+ execution_context.errors = result.errors
189
+
190
+ # Run the `Schema.process_errors` function here before
191
+ # extensions have a chance to modify them (see the MaskErrors
192
+ # extension). That way we can log the original errors but
193
+ # only return a sanitised version to the client.
194
+ process_errors(result.errors, execution_context)
195
+
189
196
  except (MissingQueryError, InvalidOperationTypeError) as e:
190
197
  raise e
191
198
  except Exception as exc:
@@ -195,10 +202,9 @@ async def execute(
195
202
  extensions_runner,
196
203
  process_errors,
197
204
  )
198
-
199
205
  # return results after all the operation completed.
200
206
  return await _handle_execution_result(
201
- execution_context, res, extensions_runner, process_errors
207
+ execution_context, result, extensions_runner, None
202
208
  )
203
209
 
204
210
 
@@ -64,7 +64,6 @@ from strawberry.types.base import (
64
64
  )
65
65
  from strawberry.types.enum import EnumDefinition
66
66
  from strawberry.types.field import UNRESOLVED
67
- from strawberry.types.info import Info
68
67
  from strawberry.types.lazy_type import LazyType
69
68
  from strawberry.types.private import is_private
70
69
  from strawberry.types.scalar import ScalarWrapper
@@ -90,6 +89,7 @@ if TYPE_CHECKING:
90
89
  from strawberry.schema_directive import StrawberrySchemaDirective
91
90
  from strawberry.types.enum import EnumValue
92
91
  from strawberry.types.field import StrawberryField
92
+ from strawberry.types.info import Info
93
93
  from strawberry.types.scalar import ScalarDefinition
94
94
 
95
95
 
@@ -664,7 +664,7 @@ class GraphQLCoreConverter:
664
664
  return _get_basic_result
665
665
 
666
666
  def _strawberry_info_from_graphql(info: GraphQLResolveInfo) -> Info:
667
- return Info(
667
+ return self.config.info_class(
668
668
  _raw_info=info,
669
669
  _field=field,
670
670
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: strawberry-graphql
3
- Version: 0.240.3.dev1726159932
3
+ Version: 0.241.0
4
4
  Summary: A library for creating GraphQL APIs
5
5
  Home-page: https://strawberry.rocks/
6
6
  License: MIT
@@ -100,7 +100,7 @@ strawberry/extensions/__init__.py,sha256=SZ-YEMnxAzoDZFo-uHXMHOaY_PPkYm1muPpK4cc
100
100
  strawberry/extensions/add_validation_rules.py,sha256=abkOaXG-unAZj2xL2sspeUXpZKBCpj5Kr5h7TreN4gM,1338
101
101
  strawberry/extensions/base_extension.py,sha256=Wf-Xu38lPXXBPuhsxpMi18yL5oH0uoskPhs08hfSYXg,2362
102
102
  strawberry/extensions/context.py,sha256=j2pxKnZ8HOgugm_P_YJV6Fbp_SXkS-U5OLQvn-ofjRM,7210
103
- strawberry/extensions/directives.py,sha256=UNTdzYf60kUtN8BHRwLZ7dKogixywoK9i6gkXkyYlJg,3037
103
+ strawberry/extensions/directives.py,sha256=5L6vSXbVuEjSSolKLE7LLfSejJyJhyhwDJgQ8HfTeVA,3045
104
104
  strawberry/extensions/disable_validation.py,sha256=wupc5zATOLyZmay14WI-FKaPZo0jj23hv8_4H3jvbMQ,741
105
105
  strawberry/extensions/field_extension.py,sha256=PHsb1ctvyrjOmgWVQdABFDAlnPYsalExYM7jYu5VPVg,5740
106
106
  strawberry/extensions/mask_errors.py,sha256=Khfun5JtrU57rhnP2Sxsl8Q6Eo70GYoQcn9sPDLg4nY,1460
@@ -180,12 +180,12 @@ strawberry/scalars.py,sha256=c3y8EOmX-KUxSgRqk1TNercMA6_rgBHhQPp0z3C2zBU,2240
180
180
  strawberry/schema/__init__.py,sha256=u1QCyDVQExUVDA20kyosKPz3TS5HMCN2NrXclhiFAL4,92
181
181
  strawberry/schema/base.py,sha256=yarj62fhfCp0kToJPpWlNcCjyZV2CafbfpZ-yamjNVg,3730
182
182
  strawberry/schema/compat.py,sha256=rRqUm5-XgPXC018_u0Mrd4iad7tTRCNA45Ko4NaT6gk,1836
183
- strawberry/schema/config.py,sha256=Aa01oqnHb0ZPlw8Ti_O840LxlT827LNio15BQrc37A0,717
183
+ strawberry/schema/config.py,sha256=6BpCbNNCuekGgiKEPt2mliMqLH_wIjJmSW0tLbnJwk4,924
184
184
  strawberry/schema/exceptions.py,sha256=rqVNb_oYrKM0dHPgvAemqCG6Um282LPPu4zwQ5cZqs4,584
185
- strawberry/schema/execute.py,sha256=XbArky5xmCWo_r2ootm8WREzzzZ0SsU9FoyfxA6Vc8g,11490
185
+ strawberry/schema/execute.py,sha256=EWNmu3hvlZMV2EWi8IbWVLUQYRH45AFB68DrOnx3BEI,11913
186
186
  strawberry/schema/name_converter.py,sha256=tpqw2XCSFvJI-H844iWhE2Z1sKic7DrjIZxt11eJN5Y,6574
187
187
  strawberry/schema/schema.py,sha256=rdsZrnAZZDV_eU_9s2K21hgROtP29GRt5MjUrwVBwyE,19034
188
- strawberry/schema/schema_converter.py,sha256=lckL2LoxAb6mNfJIVcerht2buzBG573ly3BHyl7wra4,36859
188
+ strawberry/schema/schema_converter.py,sha256=znAKbouf_Vh5sXMhuxSABAatZ7HrvM3gONAZkjPMeDE,36881
189
189
  strawberry/schema/subscribe.py,sha256=wg-U2S-SrHxvtJA9KttnBQnyUOh-qy7UaPjumNk2Czw,6007
190
190
  strawberry/schema/types/__init__.py,sha256=oHO3COWhL3L1KLYCJNY1XFf5xt2GGtHiMC-UaYbFfnA,68
191
191
  strawberry/schema/types/base_scalars.py,sha256=NTj_tYqWLQLEOPDhBhSE1My4JXoieyg0jO8B6RNK-xA,1913
@@ -245,8 +245,8 @@ strawberry/utils/logging.py,sha256=U1cseHGquN09YFhFmRkiphfASKCyK0HUZREImPgVb0c,7
245
245
  strawberry/utils/operation.py,sha256=SSXxN-vMqdHO6W2OZtip-1z7y4_A-eTVFdhDvhKeLCk,1193
246
246
  strawberry/utils/str_converters.py,sha256=KGd7QH90RevaJjH6SQEkiVVsb8KuhJr_wv5AsI7UzQk,897
247
247
  strawberry/utils/typing.py,sha256=3xws5kxSQGsp8BnYyUwClvxXNzZakMAuOPoq1rjHRuk,14252
248
- strawberry_graphql-0.240.3.dev1726159932.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
249
- strawberry_graphql-0.240.3.dev1726159932.dist-info/METADATA,sha256=OGhqrqrIWMS0ConpfeIpGizFZUl2KdeUMOC9aGvdEIg,7721
250
- strawberry_graphql-0.240.3.dev1726159932.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
251
- strawberry_graphql-0.240.3.dev1726159932.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
252
- strawberry_graphql-0.240.3.dev1726159932.dist-info/RECORD,,
248
+ strawberry_graphql-0.241.0.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
249
+ strawberry_graphql-0.241.0.dist-info/METADATA,sha256=ZSvM67VyfBvf-dDf8uoTlYpPa0KL4_bBBmTIt4js4x8,7707
250
+ strawberry_graphql-0.241.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
251
+ strawberry_graphql-0.241.0.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
252
+ strawberry_graphql-0.241.0.dist-info/RECORD,,