from typing import Type, Optional, Callable

from api_graphql.abc.collection_filter_abc import CollectionFilterABC
from api_graphql.abc.field_abc import FieldABC
from api_graphql.typing import TRequireAny
from core.typing import T
from service.permission.permissions_enum import Permissions


class CollectionField(FieldABC):

    def __init__(
        self,
        name: str,
        require_any_permission: list[Permissions] = None,
        require_any: TRequireAny = None,
        public: bool = False,
        resolver: Callable = None,
        filter_type: Type[CollectionFilterABC] = None,
        sort_type: Type[T] = None,
    ):
        FieldABC.__init__(self, name, require_any_permission, require_any, public)
        self._name = name

        self._public = public
        self._resolver = resolver
        self._filter_type = filter_type
        self._sort_type = sort_type

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

    @property
    def filter_type(
        self,
    ) -> Type[CollectionFilterABC]:
        return self._filter_type

    @property
    def sort_type(self) -> Optional[Type[T]]:
        return self._sort_type
