Implemented OutputValueType for Box<T> and Arc<T>
This commit is contained in:
parent
03d98993f7
commit
85f3bbe3af
45
src/base.rs
45
src/base.rs
|
@ -5,6 +5,7 @@ use graphql_parser::Pos;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
/// Represents a GraphQL type
|
/// Represents a GraphQL type
|
||||||
///
|
///
|
||||||
|
@ -269,3 +270,47 @@ impl<T: OutputValueType + Send + Sync> OutputValueType for &T {
|
||||||
T::resolve(*value, ctx, pos).await
|
T::resolve(*value, ctx, pos).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T: Type + Send + Sync> Type for Box<T> {
|
||||||
|
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<T: OutputValueType + Send + Sync> OutputValueType for Box<T> {
|
||||||
|
#[allow(clippy::trivially_copy_pass_by_ref)]
|
||||||
|
async fn resolve(
|
||||||
|
value: &Self,
|
||||||
|
ctx: &ContextSelectionSet<'_>,
|
||||||
|
pos: Pos,
|
||||||
|
) -> Result<serde_json::Value> {
|
||||||
|
T::resolve(&*value, ctx, pos).await
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: Type + Send + Sync> Type for Arc<T> {
|
||||||
|
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<T: OutputValueType + Send + Sync> OutputValueType for Arc<T> {
|
||||||
|
#[allow(clippy::trivially_copy_pass_by_ref)]
|
||||||
|
async fn resolve(
|
||||||
|
value: &Self,
|
||||||
|
ctx: &ContextSelectionSet<'_>,
|
||||||
|
pos: Pos,
|
||||||
|
) -> Result<serde_json::Value> {
|
||||||
|
T::resolve(&*value, ctx, pos).await
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user