import graphene
from graphene import relay
from graphene_django import DjangoObjectType

from notes.models import Note, ContentBlockBookmark, ModuleBookmark, ChapterBookmark, InstrumentBookmark


class NoteNode(DjangoObjectType):
    pk = graphene.Int()

    class Meta:
        model = Note
        interfaces = (relay.Node,)

    def resolve_pk(self, *args, **kwargs):
        return self.id


class ContentBlockBookmarkNode(DjangoObjectType):
    uuid = graphene.UUID()
    note = graphene.Field(NoteNode)

    class Meta:
        model = ContentBlockBookmark
        filter_fields = []
        interfaces = (relay.Node,)


class ModuleBookmarkNode(DjangoObjectType):
    note = graphene.Field(NoteNode)

    class Meta:
        model = ModuleBookmark


class ChapterBookmarkNode(DjangoObjectType):
    note = graphene.Field(NoteNode)

    class Meta:
        model = ChapterBookmark
        filter_fields = []
        interfaces = (relay.Node,)


class InstrumentBookmarkNode(DjangoObjectType):
    uuid = graphene.UUID()
    note = graphene.Field(NoteNode)

    class Meta:
        model = InstrumentBookmark
        filter_fields = []
        interfaces = (relay.Node,)
