use async_graphql::{Context, FieldResult, Object}; use sqlx::postgres::PgPool; use crate::{models::typ::Typ, scalar::Id}; #[derive(Default)] pub struct TypQuery {} #[Object(extends)] impl TypQuery { async fn typen<'a>(&self, ctx: &'a Context<'_>) -> FieldResult> { let pool = ctx.data::()?; let rows = Typ::read_all(pool).await?; Ok(rows) } async fn typ<'a>(&self, ctx: &'a Context<'_>, id: Id) -> FieldResult { let pool = ctx.data::()?; let row = Typ::read_one(pool, &id).await?; Ok(row) } }