Closed
Description
Is your feature request related to a problem? Please describe.
anyhow is a dominant error handling library for rust. Currently, there is no convenient way to use anyhow Err
s in juniper code. For example,
struct Mutation;
#[juniper::graphql_object]
impl Mutation {
async fn Foo(line_number: i32) -> FieldResult<bool> {
anyhow::ensure!(line_number >= 0);
Ok(true)
}
}
doesn't work.
IntoFieldResult offers a way of translating custom error types into FieldResult
s, but unfortunately implementing IntoFieldResult
for anyhow::Error
is not possible due to https://doc.rust-lang.org/error-index.html#E0117.
Side note: why is there IntoFieldResult
instead of simply Into<FieldResult>
?
Describe the solution you'd like
Not 100% clear what the exact solution ought to be, but I think just implementing IntoFieldResult
for anyhow::Error
would do the trick.
Describe alternatives you've considered
n/a
Additional context
n/a