from typing import Optional

from ariadne.types import Resolver

from api_graphql.abc.field_abc import FieldABC
from api_graphql.typing import TRequireAny
from service.permission.permissions_enum import Permissions


class ResolverField(FieldABC):

    def __init__(
        self,
        name: str,
        require_any_permission: list[Permissions] = None,
        require_any: TRequireAny = None,
        public: bool = False,
        resolver: Resolver = None,
        direct_result: bool = False,
    ):
        FieldABC.__init__(self, name, require_any_permission, require_any, public)

        self._resolver = resolver
        self._direct_result = direct_result

    @property
    def resolver(self) -> Optional[Resolver]:
        return self._resolver

    @property
    def direct_result(self) -> bool:
        return self._direct_result
