Let graphene handle serializer errors
See original GitHub issueCurrently, we have separate errors field rather than using already existing error feature provided by graphene.
~https://github.com/graphql-python/graphene-django/blob/master/graphene_django/rest_framework/mutation.py#L77~ https://github.com/graphql-python/graphene-django/blob/master/graphene_django/rest_framework/mutation.py#L128
So instead we could simply raise the ValidationError
raised by serializer, and let graphene handle it.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:17 (6 by maintainers)
Top Results From Across the Web
Let graphene handle serializer errors - - Bountysource
Let graphene handle serializer errors ... Currently, we have separate errors field rather than using already existing error feature provided by graphene. ~https ......
Read more >Django + Graphene: From REST to GraphQL - FullStack Labs
This walk-through demonstrates the power of using Graphene with Django by covering the basics, testing, and more advanced features.
Read more >[Answered]-How to use DRF serializers with Graphene-django
Consider we have model Subject. Let's create CRUD api for it. from graphene.types.scalars import Scalar class ObjectField(Scalar): # to serialize error ...
Read more >GraphQL response error message from DRF serializer
you should query for errors that have field and messages ... I actually wrote a CRUD django-graphene rest serializers library here, ...
Read more >Django Rest Framework: Is it just me, or is it more trouble than ...
In particular, it's the serializers that bother me. ... For example it made error handling and raising exceptions way easier, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have just bumped into the same issue and first thought this is a bug before I have encountered this issue.
I think this decision should be reconsidered, let me outline why:
Reference for status codes: https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
What do you think?
I am happy to work on a PR if we can agree that this should be adjusted.
I am a bit confused by this statement in the related issue as the specification doesn’t explicitly state that this is the case (at least that’s how I read it).
The specification rather states:
Trying to rephrase this for our case: Each field returned by mutation which is null because of an error should have an error in
errors
.Hence I suggest Graphene Django adds one error for each validation exception. This might need changes on
graphql-core
as well? The way how you have suggested would also be a good first step to move forward.Also such a change depends on a fix for issue https://github.com/graphql-python/graphql-core/issues/203
All in all changing this won’t be trivial as changes in
graphql-core
are most likely necessary. But could we still reopen this issue? This way users with the same issue will find it better as the discussion continues. And as stated when we agree on a solution I am open to help with a PR if needed.