async_graphql/types/external/tokio/sync/
rw_lock.rs

1use std::borrow::Cow;
2
3use async_graphql_parser::types::Field;
4use tokio::sync::RwLock;
5
6use crate::{ContextSelectionSet, OutputType, Positioned, ServerResult, Value, registry};
7
8#[cfg_attr(feature = "boxed-trait", async_trait::async_trait)]
9impl<T: OutputType> OutputType for RwLock<T> {
10    fn type_name() -> Cow<'static, str> {
11        T::type_name()
12    }
13
14    fn create_type_info(registry: &mut registry::Registry) -> String {
15        <T as OutputType>::create_type_info(registry)
16    }
17
18    async fn resolve(
19        &self,
20        ctx: &ContextSelectionSet<'_>,
21        field: &Positioned<Field>,
22    ) -> ServerResult<Value> {
23        self.read().await.resolve(ctx, field).await
24    }
25}