refactor queries

This commit is contained in:
2026-05-31 22:03:06 +02:00
parent 90a88c15dc
commit 7ffd06f446
13 changed files with 15 additions and 7 deletions

View File

@@ -0,0 +1 @@
pub mod gruppe;

View File

@@ -0,0 +1,23 @@
use async_graphql::{Context, FieldResult, Object};
use sqlx::postgres::PgPool;
use crate::domain::gruppe::{model::Gruppe, service::Service};
#[derive(Default)]
pub struct GruppeQuery {}
#[Object(extends)]
impl GruppeQuery {
// async fn gruppe(&self, ctx: &Context<'_>, id: uuid::Uuid) -> FieldResult<Gruppe> {
// todo!();
// // let pool = ctx.data::<PgPool>()?;
// //
// // Ok(row)
// }
async fn gruppen(&self, ctx: &Context<'_>) -> FieldResult<Vec<Gruppe>> {
let pool = ctx.data::<PgPool>()?;
let rows = Service::new(pool.clone()).gruppe_alle().await?;
Ok(rows)
}
}