use async_graphql::{Context, EmptySubscription, Object, Schema}; use como_domain::item::{requests::CreateItemDto, responses::CreatedItemDto}; use crate::services::users_service::UserService; pub type CibusSchema = Schema; pub struct MutationRoot; #[Object] impl MutationRoot { async fn login( &self, ctx: &Context<'_>, username: String, password: String, ) -> anyhow::Result { let user_service = ctx.data_unchecked::(); let valid = user_service.validate_user(username, password).await?; let returnvalid = match valid { Some(..) => true, None => false, }; Ok(returnvalid) } async fn register( &self, ctx: &Context<'_>, username: String, password: String, ) -> anyhow::Result { let user_service = ctx.data_unchecked::(); let user_id = user_service.add_user(username, password).await?; Ok(user_id) } async fn create_item( &self, ctx: &Context<'_>, item: CreateItemDto, ) -> anyhow::Result { let services_register = ctx.data_unchecked::() } } pub struct QueryRoot; #[Object] impl QueryRoot { async fn get_upcoming(&self, _ctx: &Context<'_>) -> Vec {} }