use crate::models::modell::*; use async_graphql::{Context, FieldResult}; use sqlx::postgres::PgPool; #[derive(Default)] pub struct ModellMutation; #[async_graphql::Object] impl ModellMutation { async fn create_modell( &self, ctx: &Context<'_>, modell: ModellCreateInput, ) -> FieldResult { let pool = ctx.data::()?; let row = Modell::create(pool, &modell).await?; Ok(row) } async fn update_modell( &self, ctx: &Context<'_>, modell: ModellUpdateInput, ) -> FieldResult { let pool = ctx.data::()?; let row = Modell::update(pool, &modell).await?; Ok(row) } async fn delete_modell(&self, ctx: &Context<'_>, id: i32) -> FieldResult { let pool = ctx.data::()?; Ok(Modell::delete(pool, &id).await?) } }