Untitled

 avatar
unknown
plain_text
6 months ago
937 B
3
Indexable
from datetime import datetime
from typing import Optional

from strawberry import ID, Parent, field, type

from app.graphql.schema import Info
from app.models import User

from .relay_types import Connection, Edge, PageInfo, paginate


@type(name="User")
class UserType:
    id: ID
    login: str
    user_app_status: str
    first_name: str
    last_name: str
    email: str
    grp_typ_cd: str
    active: str
    created_date: datetime
    created_by_id: str
    updated_date: datetime
    updated_by_id: str

    @field
    @staticmethod
    async def created_by(info: Info, parent: Parent["User"]) -> Optional["UserType"]:
        return await info.context.load_user_by_login.load(parent.created_by_id)

    @field
    @staticmethod
    async def updated_by(info: Info, parent: Parent["User"]) -> Optional["UserType"]:
        return await info.context.load_user_by_login.load(parent.updated_by_id)
Editor is loading...
Leave a Comment