from api_graphql.abc.db_model_query_abc import DbModelQueryABC
from data.schemas.administration.user_dao import userDao
from data.schemas.permission.role_user_dao import roleUserDao


class UserQuery(DbModelQueryABC):
    def __init__(self):
        DbModelQueryABC.__init__(self, "User", userDao, with_history=True)

        self.set_field("keycloakId", lambda x, *_: x.keycloak_id)
        self.set_field("username", lambda x, *_: x.username)
        self.set_field("email", lambda x, *_: x.email)
        self.set_field("roles", lambda x, *_: x.roles)

        self.set_history_reference_dao(roleUserDao, "userid")
