Implement IntoFieldError for Infallible (#796)

Makes it possible to use `Result<T, Infallible>` as your return type
from resolvers, which can be handy sometimes.
This commit is contained in:
David Pedersen 2020-10-29 14:39:59 +01:00 committed by GitHub
parent f6ec735ba9
commit eca049ac28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 0 deletions

View file

@ -0,0 +1,8 @@
struct Query;
#[juniper::graphql_object]
impl Query {
fn ping() -> Result<bool, std::convert::Infallible> {
Ok(false)
}
}

View file

@ -7,6 +7,8 @@ mod custom_scalar;
#[cfg(test)]
mod explicit_null;
#[cfg(test)]
mod infallible_as_field_error;
#[cfg(test)]
mod issue_371;
#[cfg(test)]
mod issue_398;

View file

@ -37,6 +37,9 @@
- Added support for distinguishing between between implicit and explicit null. ([#795](https://github.com/graphql-rust/juniper/pull/795))
- Implement `IntoFieldError` for `std::convert::Infallible`. ([#796](https://github.com/graphql-rust/juniper/pull/796))
## Fixes
- Massively improved the `#[graphql_union]` proc macro. ([#666](https://github.com/graphql-rust/juniper/pull/666)):

View file

@ -246,6 +246,12 @@ impl<S> IntoFieldError<S> for FieldError<S> {
}
}
impl<S> IntoFieldError<S> for std::convert::Infallible {
fn into_field_error(self) -> FieldError<S> {
match self {}
}
}
#[doc(hidden)]
pub trait IntoResolvable<'a, S, T, C>
where