juniper
juniper copied to clipboard
Replace Unresonable Panics
Is your feature request related to a problem? Please describe. Feeding Juniper queries which have wrong semantics sometimes result in panics. Recently came across a similar issue as https://github.com/graphql-rust/juniper/issues/407. At least when using warp the HTTP server does not crash. However, in general it seems that it is not a good idea to panic in these situations. The panic from the previously mentioned issue is caused by https://github.com/graphql-rust/juniper/blob/f3170c7adf4405cc119d2129f78a591fe2fcd32b/juniper/src/types/base.rs#L451-L457
Describe the solution you'd like These kind of errors should be propagated for two reasons. First the program does not panic. Probably most HTTP servers can handle the panics, but it is better to not panic unreasonably. Second the client should know that the provided query is wrong. If the client does not receive any feedback, it may queries the same query again. I think we should search for these kind of panics and introduce error propagation instead. Besides the usability, there might also be a performance difference between panics and error propagation, depending on the recovery process.
Describe alternatives you've considered Keep it as it is.