-
Notifications
You must be signed in to change notification settings - Fork 822
Question: Document how to raise exceptions to get an "errors" list in response #1469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I believe that this problem is caused by |
hoi @khink, somehow my comment on this was not posted. It's been some time since then so I'll need to look again, sorry! |
@erikwrede |
I have same issue, please help! |
+1 for this issue. I have been breaking my head for a day around this. There is little to no documentation around error handling and things also seem to be broken. Will appreciate a fix for the issue and would love to see some proper documentation with custom handlers etc. |
Is anyone able to post a minimal reproduction as a gist (including django setup)? I'm no longer able to reproduce the behavior on a simple django app using the newest versions. |
Reproduced it with a minimal setup: https://github.com/khink/graphene-issue-1469/ |
@khink I see why my reproduction didn't work anymore. I had debug mode disabled. Setting The problem is in the The correct way to handle exceptions in graphql core 3 is to raise them. Promises are treated like a valid response object. In your case, the promise can be converted to the ID type which is an implicit To solve the issue, you can try disabling the middleware or send a PR to the You can disable the middleware by removing |
Thanks, i'd never have found that. Thanks especially since the reason is not within this project. I'll think about whether i want to report this at graphene-django, for now i'm happy that i was able to get everything working. Edit: There's already a ticket, i think graphql-python/graphene-django#1367 covers exactly this. |
Great to hear I could help! I've forwarded the issue to @firaskafri - hopefully it will be resolved soon! 🙂 |
Hello! Solved in graphql-python/graphene-django#1388 |
First off, this is a question. I apologize for creating a ticket here. As suggested in the "bug report" issue template, i asked on StackOverflow first, but unfortunately there are no responses yet. I realize this does not give me the right to create an issue . I'm hoping my question might benefit the documentation in some way.
I don't know how to raise an exception in such a way that it results in an
"errors"
list in the response data.In #1410 (comment), @erikwrede wrote that we can just raise a GraphQLError. I don't think that's documented yet. All i found about GraphQLError usage is with regard to validators: https://docs.graphene-python.org/en/latest/execution/queryvalidation/#implementing-custom-validators There's nothing there that says that the response will have an
"errors"
list.The reason is ask is that this used to work for us with older Graphene versions (graphene==3.0, graphene-django==3.0.0b7, graphql-core==3.1.7) but stopped working after we upgrade (graphene==3.1.1, graphene-django==3.0.0 and graphql-core==3.2.3).
This used to work:
It would result in a response like this:
However, after upgrade this gives
I've read through the changelog of graphene and graphene-django. As this "broke" (for us) in graphene-django 3.0.0b8, i thought graphql-python/graphene-django#1327 might have something to do with it. But then, that also requires a newer version of graphene.
Thanks for taking the time to read this.
The text was updated successfully, but these errors were encountered: