strawberry-graphql 0.279.0.dev1754138688__py3-none-any.whl → 0.279.0.dev1754156227__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/pydantic/__init__.py +2 -1
- strawberry/pydantic/error.py +51 -0
- {strawberry_graphql-0.279.0.dev1754138688.dist-info → strawberry_graphql-0.279.0.dev1754156227.dist-info}/METADATA +1 -1
- {strawberry_graphql-0.279.0.dev1754138688.dist-info → strawberry_graphql-0.279.0.dev1754156227.dist-info}/RECORD +7 -6
- {strawberry_graphql-0.279.0.dev1754138688.dist-info → strawberry_graphql-0.279.0.dev1754156227.dist-info}/LICENSE +0 -0
- {strawberry_graphql-0.279.0.dev1754138688.dist-info → strawberry_graphql-0.279.0.dev1754156227.dist-info}/WHEEL +0 -0
- {strawberry_graphql-0.279.0.dev1754138688.dist-info → strawberry_graphql-0.279.0.dev1754156227.dist-info}/entry_points.txt +0 -0
strawberry/pydantic/__init__.py
CHANGED
@@ -10,6 +10,7 @@ Example:
|
|
10
10
|
age: int
|
11
11
|
"""
|
12
12
|
|
13
|
+
from .error import Error
|
13
14
|
from .object_type import input as input_decorator
|
14
15
|
from .object_type import interface
|
15
16
|
from .object_type import type as type_decorator
|
@@ -18,4 +19,4 @@ from .object_type import type as type_decorator
|
|
18
19
|
input = input_decorator
|
19
20
|
type = type_decorator
|
20
21
|
|
21
|
-
__all__ = ["input", "interface", "type"]
|
22
|
+
__all__ = ["Error", "input", "interface", "type"]
|
@@ -0,0 +1,51 @@
|
|
1
|
+
"""Generic error type for Pydantic validation errors in Strawberry GraphQL.
|
2
|
+
|
3
|
+
This module provides a generic Error type that can be used to represent
|
4
|
+
Pydantic validation errors in GraphQL responses.
|
5
|
+
"""
|
6
|
+
|
7
|
+
from __future__ import annotations
|
8
|
+
|
9
|
+
from typing import TYPE_CHECKING
|
10
|
+
|
11
|
+
from strawberry.types.object_type import type as strawberry_type
|
12
|
+
|
13
|
+
if TYPE_CHECKING:
|
14
|
+
from pydantic import ValidationError
|
15
|
+
|
16
|
+
|
17
|
+
@strawberry_type
|
18
|
+
class ErrorDetail:
|
19
|
+
"""Represents a single validation error detail."""
|
20
|
+
|
21
|
+
type: str
|
22
|
+
loc: list[str]
|
23
|
+
msg: str
|
24
|
+
|
25
|
+
|
26
|
+
@strawberry_type
|
27
|
+
class Error:
|
28
|
+
"""Generic error type for Pydantic validation errors."""
|
29
|
+
|
30
|
+
errors: list[ErrorDetail]
|
31
|
+
|
32
|
+
@staticmethod
|
33
|
+
def from_validation_error(exc: ValidationError) -> Error:
|
34
|
+
"""Create an Error instance from a Pydantic ValidationError.
|
35
|
+
|
36
|
+
Args:
|
37
|
+
exc: The Pydantic ValidationError to convert
|
38
|
+
|
39
|
+
Returns:
|
40
|
+
An Error instance containing all validation errors
|
41
|
+
"""
|
42
|
+
return Error(
|
43
|
+
errors=[
|
44
|
+
ErrorDetail(
|
45
|
+
type=error["type"],
|
46
|
+
loc=[str(loc) for loc in error["loc"]],
|
47
|
+
msg=error["msg"],
|
48
|
+
)
|
49
|
+
for error in exc.errors()
|
50
|
+
]
|
51
|
+
)
|
@@ -152,7 +152,8 @@ strawberry/printer/__init__.py,sha256=DmepjmgtkdF5RxK_7yC6qUyRWn56U-9qeZMbkztYB9
|
|
152
152
|
strawberry/printer/ast_from_value.py,sha256=Tkme60qlykbN2m3dNPNMOe65X-wj6EmcDQwgQv7gUkc,4987
|
153
153
|
strawberry/printer/printer.py,sha256=5E9w0wDsUv1hvkeXof12277NLMiCVy5MgJ6gSo_NJhQ,19177
|
154
154
|
strawberry/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
155
|
-
strawberry/pydantic/__init__.py,sha256=
|
155
|
+
strawberry/pydantic/__init__.py,sha256=_QAGALzygcRyKE2iiK_rHt4s_d0g3ms0SUP64rEjrYI,592
|
156
|
+
strawberry/pydantic/error.py,sha256=EvS2R99CCoe5Oo5Dh3V9Xc6eGcSFpo-r4F5Wq8RjF7U,1271
|
156
157
|
strawberry/pydantic/fields.py,sha256=8oBY7Z-sTj6Tt3l9sNl1Wqk2ERxh-Doe2onQYnsGCP4,7188
|
157
158
|
strawberry/pydantic/object_type.py,sha256=sxFTE_VSpAcmOm7-EGL-tp0aobjoctOSjVQs34fRcD8,10785
|
158
159
|
strawberry/quart/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -239,8 +240,8 @@ strawberry/utils/logging.py,sha256=U1cseHGquN09YFhFmRkiphfASKCyK0HUZREImPgVb0c,7
|
|
239
240
|
strawberry/utils/operation.py,sha256=ZgVOw3K2jQuLjNOYUHauF7itJD0QDNoPw9PBi0IYf6k,1234
|
240
241
|
strawberry/utils/str_converters.py,sha256=-eH1Cl16IO_wrBlsGM-km4IY0IKsjhjnSNGRGOwQjVM,897
|
241
242
|
strawberry/utils/typing.py,sha256=SDvX-Du-9HAV3-XXjqi7Q5f5qPDDFd_gASIITiwBQT4,14073
|
242
|
-
strawberry_graphql-0.279.0.
|
243
|
-
strawberry_graphql-0.279.0.
|
244
|
-
strawberry_graphql-0.279.0.
|
245
|
-
strawberry_graphql-0.279.0.
|
246
|
-
strawberry_graphql-0.279.0.
|
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,,
|
File without changes
|
File without changes
|