-
Notifications
You must be signed in to change notification settings - Fork 535
Add support for errorsCallback so we got errors detail on server … #37
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at [email protected]. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
Two primary points of feedback: First, please ensure this change is well scoped. This makes some seemingly unrelated changes to the package.json file. Second, could you help me understand the motivation for this change? This seems directionally good, but I'd like to better understand what you're trying to accomplish by proposing this, since there may be other solutions to consider. |
Also please see and mirror existing test formatting rather than including new test mechanisms |
This could be extremely helpful. If And, when promises are used, every request will go through as a success unless there is a So, in the database example above, How would one go about sending back anything other than a The only way I can see to accomplish this would be to have something check the Thoughts? |
@cdonohue For me it's OK now with |
I guess I'm just looking for a solution where errors can be caught and the response be set accordingly. Take the example above. If the graphql backend is connected to a database and for some reason, the database is down (problem outside of graphql). When the graphql query/mutation returns, it will still send a This also means that you would have to handle your client requests a bit differently for axios.post("/path-to-graphql", { query, variables })
.then(response => {
if (response.data.errors && response.data.errors.length) {
throw response.data.errors[0];
}
// --> process data
})
.catch(error => {
// handle client errors
})
; To me, the Maybe this should go in its own issue? But I already saw that #36 has been closed out. How are others handling this case when errors happen on the server and |
Returning 200 is intentional in the case that a nullable portion of a query failed, but other parts of the request succeeded. Express-graphql should return an error code if the whole query fails |
Thanks for clarifying, @leebyron. I'll revisit my example and double-check everything. |
Closing this as I think we have better solutions for the two motivating use cases:
|
I added a test for this but sinon must be used for this test to really work. Didn't know if you are OK to include sinon and sinon-chai ?