from typing import Optional, Type

from ariadne.types import Resolver

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


class MutationField(FieldABC):

    def __init__(
        self,
        name: str,
        require_any_permission: list[Permissions] = None,
        require_any: TRequireAny = None,
        public: bool = False,
        resolver: Resolver = None,
        input_type: Type[InputABC] = None,
        input_key: str = "input",
    ):
        FieldABC.__init__(self, name, require_any_permission, require_any, public)

        self._resolver = resolver
        self._input_type = input_type
        self._input_key = input_key

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

    @property
    def input_type(self) -> Optional[Type[InputABC]]:
        return self._input_type

    @property
    def input_key(self) -> str:
        return self._input_key
