strawberry-graphql 0.279.0.dev1754156227__py3-none-any.whl → 0.279.0.dev1754159379__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.
@@ -1,5 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
+ import contextlib
3
4
  import dataclasses
4
5
  import sys
5
6
  from functools import partial, reduce
@@ -731,14 +732,27 @@ class GraphQLCoreConverter:
731
732
  ) -> Any:
732
733
  # parse field arguments into Strawberry input types and convert
733
734
  # field names to Python equivalents
734
- field_args, field_kwargs = get_arguments(
735
- field=field,
736
- source=_source,
737
- info=info,
738
- kwargs=kwargs,
739
- config=self.config,
740
- scalar_registry=self.scalar_registry,
741
- )
735
+ try:
736
+ field_args, field_kwargs = get_arguments(
737
+ field=field,
738
+ source=_source,
739
+ info=info,
740
+ kwargs=kwargs,
741
+ config=self.config,
742
+ scalar_registry=self.scalar_registry,
743
+ )
744
+ except Exception as exc:
745
+ # Try to import Pydantic ValidationError
746
+ with contextlib.suppress(ImportError):
747
+ from pydantic import ValidationError
748
+
749
+ if isinstance(
750
+ exc, ValidationError
751
+ ) and self._should_convert_validation_error(field):
752
+ from strawberry.pydantic import Error
753
+
754
+ return Error.from_validation_error(exc)
755
+ raise
742
756
 
743
757
  resolver_requested_info = False
744
758
  if "info" in field_kwargs:
@@ -799,6 +813,22 @@ class GraphQLCoreConverter:
799
813
  _resolver._is_default = not field.base_resolver # type: ignore
800
814
  return _resolver
801
815
 
816
+ def _should_convert_validation_error(self, field: StrawberryField) -> bool:
817
+ """Check if field return type is a Union containing strawberry.pydantic.Error."""
818
+ from strawberry.types.union import StrawberryUnion
819
+
820
+ field_type = field.type
821
+ if isinstance(field_type, StrawberryUnion):
822
+ # Import Error dynamically to avoid circular imports
823
+ try:
824
+ from strawberry.pydantic import Error
825
+
826
+ return any(union_type is Error for union_type in field_type.types)
827
+ except ImportError:
828
+ # If strawberry.pydantic doesn't exist or Error isn't available
829
+ return False
830
+ return False
831
+
802
832
  def from_scalar(self, scalar: type) -> GraphQLScalarType:
803
833
  from strawberry.relay.types import GlobalID
804
834
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: strawberry-graphql
3
- Version: 0.279.0.dev1754156227
3
+ Version: 0.279.0.dev1754159379
4
4
  Summary: A library for creating GraphQL APIs
5
5
  License: MIT
6
6
  Keywords: graphql,api,rest,starlette,async
@@ -177,7 +177,7 @@ strawberry/schema/config.py,sha256=bkEMn0EkBRg2Tl6ZZH5hpOGBNiAw9QcOclt5dI_Yd1g,1
177
177
  strawberry/schema/exceptions.py,sha256=8gsMxxFDynMvRkUDuVL9Wwxk_zsmo6QoJ2l4NPxd64M,1137
178
178
  strawberry/schema/name_converter.py,sha256=JG5JKLr9wp8BMJIvG3_bVkwFdoLGbknNR1Bt75urXN0,6950
179
179
  strawberry/schema/schema.py,sha256=EZ6YLV5wqHrjxi3rVJ0HvbGeIlZrbSOZqEomKlu4-OY,39433
180
- strawberry/schema/schema_converter.py,sha256=ZGkZjLsqjZ-0y5NItsECHZbOOhjJioYRT6YROwmo4Gg,40125
180
+ strawberry/schema/schema_converter.py,sha256=6wgiLkQtA77AEBCH9TqKdGWmRsv4HScKx9YahnZlQQg,41441
181
181
  strawberry/schema/types/__init__.py,sha256=oHO3COWhL3L1KLYCJNY1XFf5xt2GGtHiMC-UaYbFfnA,68
182
182
  strawberry/schema/types/base_scalars.py,sha256=JRUq0WjEkR9dFewstZnqnZKp0uOEipo4UXNF5dzRf4M,1971
183
183
  strawberry/schema/types/concrete_type.py,sha256=axIyFZgdwNv-XYkiqX67464wuFX6Vp0jYATwnBZSUvM,750
@@ -240,8 +240,8 @@ strawberry/utils/logging.py,sha256=U1cseHGquN09YFhFmRkiphfASKCyK0HUZREImPgVb0c,7
240
240
  strawberry/utils/operation.py,sha256=ZgVOw3K2jQuLjNOYUHauF7itJD0QDNoPw9PBi0IYf6k,1234
241
241
  strawberry/utils/str_converters.py,sha256=-eH1Cl16IO_wrBlsGM-km4IY0IKsjhjnSNGRGOwQjVM,897
242
242
  strawberry/utils/typing.py,sha256=SDvX-Du-9HAV3-XXjqi7Q5f5qPDDFd_gASIITiwBQT4,14073
243
- strawberry_graphql-0.279.0.dev1754156227.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
244
- strawberry_graphql-0.279.0.dev1754156227.dist-info/METADATA,sha256=eVH1vDqpWl0QgJtrdbBWBLGpevUJJjqwsD8VOezP5cc,7407
245
- strawberry_graphql-0.279.0.dev1754156227.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
246
- strawberry_graphql-0.279.0.dev1754156227.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
247
- strawberry_graphql-0.279.0.dev1754156227.dist-info/RECORD,,
243
+ strawberry_graphql-0.279.0.dev1754159379.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
244
+ strawberry_graphql-0.279.0.dev1754159379.dist-info/METADATA,sha256=d3JxV0Ow32IbDnXy_XQBZmYFP9dfbrzcXbycU5arydU,7407
245
+ strawberry_graphql-0.279.0.dev1754159379.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
246
+ strawberry_graphql-0.279.0.dev1754159379.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
247
+ strawberry_graphql-0.279.0.dev1754159379.dist-info/RECORD,,