feat: with items

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2023-06-04 11:02:51 +02:00
parent 12c7c8f6ee
commit 534b2e4a23
25 changed files with 517 additions and 111 deletions

View File

@@ -2,7 +2,6 @@ use async_graphql::{Context, Object};
use como_domain::{
item::{queries::GetItemQuery, ItemDto, ItemState},
projects::queries::GetProjectQuery,
users::User,
};
use como_infrastructure::register::ServiceRegister;
use uuid::Uuid;
@@ -16,12 +15,12 @@ pub struct CreatedItem {
#[Object]
impl CreatedItem {
pub async fn item(&self, ctx: &Context<'_>) -> anyhow::Result<Item> {
let user = ctx.data_unchecked::<User>();
let context = ctx.data_unchecked::<como_domain::Context>();
let item = ctx
.data_unchecked::<ServiceRegister>()
.item_service
.get_item(GetItemQuery { item_id: self.id }, user)
.get_item(context, GetItemQuery { item_id: self.id })
.await?;
Ok(item.into())
@@ -55,12 +54,16 @@ impl Item {
}
pub async fn project(&self, ctx: &Context<'_>) -> anyhow::Result<Project> {
let context = ctx.data_unchecked::<como_domain::Context>();
let project = ctx
.data_unchecked::<ServiceRegister>()
.project_service
.get_project(GetProjectQuery {
project_id: self.project_id,
})
.get_project(
context,
GetProjectQuery {
project_id: self.project_id,
},
)
.await?;
Ok(project.into())