Files
axum-async-graphql/src/domain/typ/query/typ.rs

26 lines
670 B
Rust
Raw Normal View History

2024-05-31 00:32:51 +02:00
use async_graphql::{Context, FieldResult, Object};
use sqlx::postgres::PgPool;
2026-06-04 23:12:32 +02:00
use crate::{
domain::typ::{model::Typ, service::Service},
scalar::Ulid,
};
2024-05-31 00:32:51 +02:00
#[derive(Default)]
2024-06-07 14:40:44 +02:00
pub struct TypQuery {}
2024-05-31 00:32:51 +02:00
#[Object(extends)]
impl TypQuery {
2026-05-25 19:26:24 +02:00
async fn typen(&self, ctx: &Context<'_>) -> FieldResult<Vec<Typ>> {
2026-06-04 23:12:32 +02:00
let pool = ctx.data::<PgPool>()?.clone();
let typen = Service::new(pool).typ_alle().await?;
2026-05-31 20:24:10 +02:00
Ok(typen)
2024-05-31 00:32:51 +02:00
}
2026-06-04 23:12:32 +02:00
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)
}
2024-05-31 00:32:51 +02:00
}