2024-11-29 10:35:10 +01:00
|
|
|
use async_graphql::{Context, FieldResult, Object};
|
|
|
|
|
use sqlx::postgres::PgPool;
|
|
|
|
|
|
2024-12-06 14:06:27 +01:00
|
|
|
use crate::domain::benutzer::{model::Benutzer, service::Service};
|
2024-11-29 10:35:10 +01:00
|
|
|
|
|
|
|
|
#[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)
|
|
|
|
|
// }
|
|
|
|
|
|
2026-05-25 19:26:24 +02:00
|
|
|
async fn benutzer_alle(&self, ctx: &Context<'_>) -> FieldResult<Vec<Benutzer>> {
|
2024-11-29 10:35:10 +01:00
|
|
|
let pool = ctx.data::<PgPool>()?;
|
|
|
|
|
|
2024-12-06 14:06:27 +01:00
|
|
|
let benutzer = Service::new(pool.clone()).alle_benutzer().await?;
|
2024-11-29 10:35:10 +01:00
|
|
|
|
|
|
|
|
Ok(benutzer)
|
|
|
|
|
}
|
|
|
|
|
}
|