use std::sync::Arc; use async_graphql::{Context, Object, Result, SimpleObject, ID}; use scel_core::App; #[derive(SimpleObject, Clone)] pub struct Download { pub id: ID, pub link: String, pub progress: Option, pub file_name: Option, } pub struct QueryRoot; #[Object] impl QueryRoot { async fn get_download(&self, ctx: &Context<'_>, id: ID) -> Result> { let app = ctx.data_unchecked::>(); match app.download_service.get_download(id.to_string()).await { Ok(Some(d)) => Ok(Some(Download { id: ID::from(d.id.expect("ID could not be found")), progress: None, link: d.link, file_name: None, })), Ok(None) => Ok(None), Err(e) => Err(e.into()), } } }