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