-
-
Notifications
You must be signed in to change notification settings - Fork 439
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
@delete directive does not return error when delete has failed through observer. #1204
Comments
I think that this case, where a model is not being deleted, is not necessarily an error. If an exception is thrown during a callback, Lighthouse will abort execution - but just returning How about we just return the result of calling type Mutation {
deleteUser(id: ID!): Boolean! @delete(model: "User")
} |
You could also add the @spawnia If this is a problem multiple people have, I think we could consider adding a flag to the directive for throwing an error when CRUD methods on models return false. |
@olivernybroe throwing is a perfectly fine way to bubble up errors and will produce a proper error in the response. I don't want to support the old PHP pattern of returning |
@spawnia I have started throwing exceptions instead of returning false in my observers, which responds with the thrown exception's message as The ideas of returning And I also apologize for the delayed response and my incomplete replies due to lack of knowledge regarding internal specs. |
The solution for a single deletion is simple, but i struggle with what we should do when multiple models are deleted at once. We might buffer the exceptions and throw a list of errors for all ID's where deletion failed. |
Describe the bug
@delete directive does not return error when delete has failed through observer.
Expected behavior/Solution
My mutation in graphql-schema
Note: Im using
Int! @eq
instead ofID!
as my database has id as a incrementing integer.My observer
Note: The first
return false
in thedeleting
method is there for testing purposes.Expected behaviour.
First step is happening as in my test-case delete is not happening as expected.
But GraphQL is not considering that be a failure and is behaving as if it was a successful deletion.
Steps to reproduce
Output/Logs
Click to expand
Environment
Lighthouse Version: v4.8.1
Laravel Version: v6.9.0
The text was updated successfully, but these errors were encountered: