graphql-python / graphene-django

Build powerful, efficient, and flexible GraphQL APIs with seamless Django integration.
http://docs.graphene-python.org/projects/django/en/latest/
MIT License
4.31k stars 770 forks source link

All exceptions during execution are considered "invalid" ExecutionResults, and return null data #763

Open ajroberts0417 opened 5 years ago

ajroberts0417 commented 5 years ago

https://github.com/graphql-python/graphene-django/blob/b0cba398a1bacd9305c50e784b862785348fca2d/graphene_django/views.py#L284-L285

Currently Graphene-Django assumes any exception during execution is cause for an invalid ExecutionResult, meaning I can't obtain partial data, and my data field is "null".

This is an issue for several reasons, the most obvious being that my client should be able to obtain partial data, even on an exception during execution. Sometimes these exceptions are caused by user error (e.g. bad input).

graphql-core allows partial data to be sent on error: https://github.com/graphql-python/graphql-core/blob/fa4eeda36029680205e20059379e89189b946032/graphql/execution/base.py#L23-L39

What's the rationale behind setting invalid=True on all execution errors?

EDIT:

From this tutorial it's clear that this behavior isn't what graphql-python expects: https://www.howtographql.com/graphql-python/6-error-handling/

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

anpr commented 4 years ago

We currently have exactly this problem: we'd like to sent back partial data to the user, even if there was an error. This doesn't seem to be possible with graphene-django :-(