Files
axum-async-graphql/src/domain/typ/query/typ.rs
2026-06-06 17:03:35 +02:00

26 lines
670 B
Rust

use async_graphql::{Context, FieldResult, Object};
use sqlx::postgres::PgPool;
use crate::{
domain::typ::{model::Typ, service::Service},
scalar::Ulid,
};
#[derive(Default)]
pub struct TypQuery {}
#[Object(extends)]
impl TypQuery {
async fn typen(&self, ctx: &Context<'_>) -> FieldResult<Vec<Typ>> {
let pool = ctx.data::<PgPool>()?.clone();
let typen = Service::new(pool).typ_alle().await?;
Ok(typen)
}
async fn einen_typen(&self, ctx: &Context<'_>, id: Ulid) -> FieldResult<Typ> {
let pool = ctx.data::<PgPool>()?.clone();
let typ = Service::new(pool).typ_einen_zeigen(id).await?;
Ok(typ)
}
}