graphql-python / graphql-python/graphene-django
Django ValidationError are serialized as string instead of error array
- Dominant language
- Python
- Stars
- 4.4k
- Forks
- 760
- PR merge metrics
- No merged PRs in 30d
Description
* **What is the current behavior?**
Django ValidationError are serialized as string instead of error array.
```python
from django.core.exceptions import ValidationError
from graphene import ObjectType, Schema, Int
class Query(ObjectType):
test = Int()
def resolve_test(root, context, **kwargs):
raise ValidationError("error message")
schema = Schema(query=Query)
```
or [https://repl.it/repls/AffectionateObviousBookmark#cookbook/schema.py](https://repl.it/repls/AffectionateObviousBookmark#cookbook/schema.py)
For the following query:
```
query Test {
test
}
```
We got the following response:
```
{
"errors": [
{
"message": "['error message']",
"locations": [
{
"line": 33,
"column": 3
}
],
"path": [
"test"
]
}
],
"data": {
"test": null
}
}
```
Look at the message field ...
* **What is the expected behavior?**
```
{
"errors": [
{
"message": "error message",
"locations": [
{
"line": 33,
"column": 3
}
],
"path": [
"test"
]
}
],
"data": {
"test": null
}
}
```
* **Please tell us about your environment:**
- Version: django (^3.1), django-graphene (^2.13)
- Platform: linux
* **Other information** (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow)
Contributor guide
Assessment
This issue has not been assessed yet.