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

[((317, 321), 'graphene.ID', 'ID', ([], {}), '()\n', (319, 321), False, 'from graphene import ObjectType, String, Field, ID, List, DateTime, Mutation, Boolean, Int\n'), ((333, 341), 'graphene.String', 'String', ([], {}), '()\n', (339, 341), False, 'from graphene import ObjectType, String, Field, ID, List, DateTime, Mutation, Boolean, Int\n'), ((360, 370), 'graphene.DateTime', 'DateTime', ([], {}), '()\n', (368, 370), False, 'from graphene import ObjectType, String, Field, ID, List, DateTime, Mutation, Boolean, Int\n'), ((388, 396), 'graphene.String', 'String', ([], {}), '()\n', (394, 396), False, 'from graphene import ObjectType, String, Field, ID, List, DateTime, Mutation, Boolean, Int\n'), ((410, 444), 'graphene.List', 'List', (['"""graphqltypes.User.UserType"""'], {}), "('graphqltypes.User.UserType')\n", (414, 444), False, 'from graphene import ObjectType, String, Field, ID, List, DateTime, Mutation, Boolean, Int\n'), ((633, 669), 'graphene.List', 'List', (['"""graphqltypes.Group.GroupType"""'], {}), "('graphqltypes.Group.GroupType')\n", (637, 669), False, 'from graphene import ObjectType, String, Field, ID, List, DateTime, Mutation, Boolean, Int\n'), ((858, 892), 'graphene.List', 'List', (['"""graphqltypes.Room.RoomType"""'], {}), "('graphqltypes.Room.RoomType')\n", (862, 892), False, 'from graphene import ObjectType, String, Field, ID, List, DateTime, Mutation, Boolean, Int\n'), ((500, 520), 'graphqltypes.Utils.extractSession', 'extractSession', (['info'], {}), '(info)\n', (514, 520), False, 'from graphqltypes.Utils import extractSession\n'), ((725, 745), 'graphqltypes.Utils.extractSession', 'extractSession', (['info'], {}), '(info)\n', (739, 745), False, 'from graphqltypes.Utils import extractSession\n'), ((948, 968), 'graphqltypes.Utils.extractSession', 'extractSession', (['info'], {}), '(info)\n', (962, 968), False, 'from graphqltypes.Utils import extractSession\n')]