-
Notifications
You must be signed in to change notification settings - Fork 438
Closed
Labels
featureNew feature or requestNew feature or requestk::apiRelated to API (application interface)Related to API (application interface)k::integrationRelated to integration with third-party libraries or systemsRelated to integration with third-party libraries or systemslib::anyhowRelated to `anyhow` crate integrationRelated to `anyhow` crate integration
Milestone
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 Errs 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 FieldResults, 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
Metadata
Metadata
Assignees
Labels
featureNew feature or requestNew feature or requestk::apiRelated to API (application interface)Related to API (application interface)k::integrationRelated to integration with third-party libraries or systemsRelated to integration with third-party libraries or systemslib::anyhowRelated to `anyhow` crate integrationRelated to `anyhow` crate integration