2024-05-31 00:32:51 +02:00
|
|
|
use async_graphql::{Context, FieldResult, Object};
|
|
|
|
|
use sqlx::postgres::PgPool;
|
|
|
|
|
|
|
|
|
|
use crate::models::hersteller::Hersteller;
|
|
|
|
|
|
|
|
|
|
#[derive(Default)]
|
2024-06-07 14:40:44 +02:00
|
|
|
pub struct HerstellerQuery {}
|
2024-05-31 00:32:51 +02:00
|
|
|
|
|
|
|
|
#[Object(extends)]
|
|
|
|
|
impl HerstellerQuery {
|
2026-05-25 19:26:24 +02:00
|
|
|
async fn hersteller(&self, ctx: &Context<'_>, id: uuid::Uuid) -> FieldResult<Hersteller> {
|
2024-05-31 00:32:51 +02:00
|
|
|
let pool = ctx.data::<PgPool>()?;
|
|
|
|
|
let row = Hersteller::read_one(pool, &id).await?;
|
|
|
|
|
Ok(row)
|
|
|
|
|
}
|
2024-06-07 14:40:44 +02:00
|
|
|
|
2026-05-25 19:26:24 +02:00
|
|
|
async fn alle_hersteller(&self, ctx: &Context<'_>) -> FieldResult<Vec<Hersteller>> {
|
2024-06-07 14:40:44 +02:00
|
|
|
let pool = ctx.data::<PgPool>()?;
|
|
|
|
|
let rows = Hersteller::read_all(pool).await?;
|
|
|
|
|
Ok(rows)
|
|
|
|
|
}
|
2024-05-31 00:32:51 +02:00
|
|
|
}
|