Files
axum-async-graphql/src/domain/benutzer/queries/benutzer.rs
2026-05-31 22:03:06 +02:00

25 lines
686 B
Rust

use async_graphql::{Context, FieldResult, Object};
use sqlx::postgres::PgPool;
use crate::domain::benutzer::{model::Benutzer, service::Service};
#[derive(Default)]
pub struct BenutzerQuery {}
#[Object(extends)]
impl BenutzerQuery {
// async fn rolle<'a>(&self, ctx: &'a Context<'_>, id: Id) -> FieldResult<Modell> {
// let pool = ctx.data::<PgPool>()?;
// let row = Modell::read_one(pool, &id).await?;
// Ok(row)
// }
async fn benutzer_alle(&self, ctx: &Context<'_>) -> FieldResult<Vec<Benutzer>> {
let pool = ctx.data::<PgPool>()?;
let benutzer = Service::new(pool.clone()).alle_benutzer().await?;
Ok(benutzer)
}
}