fluentci_graphql/schema/
cache.rs

1use std::sync::{Arc, Mutex};
2
3use super::objects::cache::Cache;
4use async_graphql::{Context, Error, Object};
5use fluentci_common::cache::cache as common_cache;
6use fluentci_core::deps::Graph;
7
8#[derive(Default, Clone)]
9pub struct CacheQuery;
10
11#[Object]
12impl CacheQuery {
13    async fn cache(&self, ctx: &Context<'_>, key: String) -> Result<Cache, Error> {
14        let graph = ctx.data::<Arc<Mutex<Graph>>>().unwrap();
15        let cache = common_cache(graph.clone(), &key)?;
16        Ok(Cache::from(cache))
17    }
18}