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