import graphene
from graphql_relay import to_global_id


class HiddenForMixin:
    hidden_for = graphene.List('users.schema.SchoolClassNode')

    @staticmethod
    def resolve_hidden_for(parent, info, **kwargs):
        return parent.hidden_for.all()


class VisibleForMixin:
    visible_for = graphene.List('users.schema.SchoolClassNode')

    @staticmethod
    def resolve_visible_for(parent, info, **kwargs):
        return parent.visible_for.all()

class HiddenAndVisibleForMixin(HiddenForMixin, VisibleForMixin):
    pass


class GraphqlNodeMixin:
    def default_node_name(self):
        return f'{self.__class__.__name__}Node'

    @property
    def graphql_id(self):
        return to_global_id(self.default_node_name(), self.id)
