from typing_extensions import Required

#from sqlalchemy.sql.sqltypes import Boolean
from graphene import ObjectType, String, Field, ID, List, DateTime, Mutation, Boolean, Int

from models.EventsRelated.EventModel import EventModel
from graphqltypes.Utils import extractSession

class EventType(ObjectType):
    id = ID()
    name = String()

    lastchange = DateTime()
    externalId = String()

    users = List('graphqltypes.User.UserType')
    def resolve_users(parent, info):
        session = extractSession(info)
        dbRecord = session.query(EventModel).get(parent.id)
        return dbRecord.users
        
    groups = List('graphqltypes.Group.GroupType')
    def resolve_users(parent, info):
        session = extractSession(info)
        dbRecord = session.query(EventModel).get(parent.id)
        return dbRecord.groups
        
    rooms = List('graphqltypes.Room.RoomType')
    def resolve_rooms(parent, info):
        session = extractSession(info)
        dbRecord = session.query(EventModel).get(parent.id)
        return dbRecord.rooms

[(10, 'graphene.ID', 'ID', False, 'from graphene import ObjectType, String, Field, ID, List, DateTime, Mutation, Boolean, Int\n'), (11, 'graphene.String', 'String', False, 'from graphene import ObjectType, String, Field, ID, List, DateTime, Mutation, Boolean, Int\n'), (13, 'graphene.DateTime', 'DateTime', False, 'from graphene import ObjectType, String, Field, ID, List, DateTime, Mutation, Boolean, Int\n'), (14, 'graphene.String', 'String', False, 'from graphene import ObjectType, String, Field, ID, List, DateTime, Mutation, Boolean, Int\n'), (16, 'graphene.List', 'List', False, 'from graphene import ObjectType, String, Field, ID, List, DateTime, Mutation, Boolean, Int\n'), (22, 'graphene.List', 'List', False, 'from graphene import ObjectType, String, Field, ID, List, DateTime, Mutation, Boolean, Int\n'), (28, 'graphene.List', 'List', False, 'from graphene import ObjectType, String, Field, ID, List, DateTime, Mutation, Boolean, Int\n'), (18, 'graphqltypes.Utils.extractSession', 'extractSession', False, 'from graphqltypes.Utils import extractSession\n'), (24, 'graphqltypes.Utils.extractSession', 'extractSession', False, 'from graphqltypes.Utils import extractSession\n'), (30, 'graphqltypes.Utils.extractSession', 'extractSession', False, 'from graphqltypes.Utils import extractSession\n')]