felicity-lims/felicity/api/gql/storage/query.py
2024-07-27 21:52:31 +02:00

61 lines
2.4 KiB
Python

from typing import List, Optional
import strawberry # noqa
from felicity.api.gql.permissions import IsAuthenticated
from felicity.api.gql.storage import types
from felicity.apps.storage.services import (StorageContainerService,
StorageLocationService,
StorageSectionService,
StoreRoomService)
@strawberry.type
class StorageQuery:
@strawberry.field(permission_classes=[IsAuthenticated])
async def store_room_all(self, info) -> List[types.StoreRoomType]:
return await StoreRoomService().all()
@strawberry.field(permission_classes=[IsAuthenticated])
async def store_room_by_uid(self, info, uid: str) -> Optional[types.StoreRoomType]:
return await StoreRoomService().get(uid=uid)
@strawberry.field(permission_classes=[IsAuthenticated])
async def storage_locations(
self, info, store_room_uid: str
) -> List[types.StorageLocationType]:
return await StorageLocationService().get_all(store_room_uid=store_room_uid)
@strawberry.field(permission_classes=[IsAuthenticated])
async def storage_location_by_uid(
self, info, uid: str
) -> Optional[types.StorageLocationType]:
return await StorageLocationService().get(uid=uid)
@strawberry.field(permission_classes=[IsAuthenticated])
async def storage_sections(
self, info, storage_location_uid: str
) -> List[types.StorageSectionType]:
return await StorageLocationService().get_all(
storage_location_uid=storage_location_uid
)
@strawberry.field(permission_classes=[IsAuthenticated])
async def storage_section_by_uid(
self, info, uid: str
) -> Optional[types.StorageSectionType]:
return await StorageSectionService().get(uid=uid)
@strawberry.field(permission_classes=[IsAuthenticated])
async def storage_containers(
self, info, storage_section_uid: str
) -> List[types.StorageContainerType]:
return await StorageContainerService().get_all(
storage_section_uid=storage_section_uid
)
@strawberry.field(permission_classes=[IsAuthenticated])
async def storage_container_by_uid(
self, info, uid: str
) -> Optional[types.StorageContainerType]:
return await StorageContainerService().get(uid=uid)