use async_graphql::{Context, Result};
use std::any::Any;
pub trait Resolver: Send + Sync {
fn as_any(&self) -> &dyn Any;
}
pub trait QueryResolver: Resolver {
fn type_name() -> &'static str
where
Self: Sized;
}
pub trait MutationResolver: Resolver {
fn type_name() -> &'static str
where
Self: Sized;
}
pub trait SubscriptionResolver: Resolver {
fn type_name() -> &'static str
where
Self: Sized;
}
pub trait ContextExt {
fn get_service<T: Send + Sync + 'static>(&self) -> Result<&T>;
}
impl<'a> ContextExt for Context<'a> {
fn get_service<T: Send + Sync + 'static>(&self) -> Result<&T> {
self.data::<T>()
}
}