diff --git a/src/base.rs b/src/base.rs index 4c8eb4f4..6ac14e3e 100644 --- a/src/base.rs +++ b/src/base.rs @@ -5,6 +5,7 @@ use graphql_parser::Pos; use std::borrow::Cow; use std::future::Future; use std::pin::Pin; +use std::sync::Arc; /// Represents a GraphQL type /// @@ -269,3 +270,47 @@ impl OutputValueType for &T { T::resolve(*value, ctx, pos).await } } + +impl Type for Box { + fn type_name() -> Cow<'static, str> { + T::type_name() + } + + fn create_type_info(registry: &mut Registry) -> String { + T::create_type_info(registry) + } +} + +#[async_trait::async_trait] +impl OutputValueType for Box { + #[allow(clippy::trivially_copy_pass_by_ref)] + async fn resolve( + value: &Self, + ctx: &ContextSelectionSet<'_>, + pos: Pos, + ) -> Result { + T::resolve(&*value, ctx, pos).await + } +} + +impl Type for Arc { + fn type_name() -> Cow<'static, str> { + T::type_name() + } + + fn create_type_info(registry: &mut Registry) -> String { + T::create_type_info(registry) + } +} + +#[async_trait::async_trait] +impl OutputValueType for Arc { + #[allow(clippy::trivially_copy_pass_by_ref)] + async fn resolve( + value: &Self, + ctx: &ContextSelectionSet<'_>, + pos: Pos, + ) -> Result { + T::resolve(&*value, ctx, pos).await + } +}