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, 9, 10, 13), 'graphene.ID', 'ID', ({}, {}), '()', False, 'from graphene import ObjectType, String, Field, ID, List, DateTime, Mutation, Boolean, Int\n'), ((11, 11, 11, 19), 'graphene.String', 'String', ({}, {}), '()', False, 'from graphene import ObjectType, String, Field, ID, List, DateTime, Mutation, Boolean, Int\n'), ((13, 17, 13, 27), 'graphene.DateTime', 'DateTime', ({}, {}), '()', False, 'from graphene import ObjectType, String, Field, ID, List, DateTime, Mutation, Boolean, Int\n'), ((14, 17, 14, 25), 'graphene.String', 'String', ({}, {}), '()', False, 'from graphene import ObjectType, String, Field, ID, List, DateTime, Mutation, Boolean, Int\n'), ((16, 12, 16, 46), 'graphene.List', 'List', ({(16, 17, 16, 45): '"""graphqltypes.User.UserType"""'}, {}), "('graphqltypes.User.UserType')", False, 'from graphene import ObjectType, String, Field, ID, List, DateTime, Mutation, Boolean, Int\n'), ((22, 13, 22, 49), 'graphene.List', 'List', ({(22, 18, 22, 48): '"""graphqltypes.Group.GroupType"""'}, {}), "('graphqltypes.Group.GroupType')", False, 'from graphene import ObjectType, String, Field, ID, List, DateTime, Mutation, Boolean, Int\n'), ((28, 12, 28, 46), 'graphene.List', 'List', ({(28, 17, 28, 45): '"""graphqltypes.Room.RoomType"""'}, {}), "('graphqltypes.Room.RoomType')", False, 'from graphene import ObjectType, String, Field, ID, List, DateTime, Mutation, Boolean, Int\n'), ((18, 18, 18, 38), 'graphqltypes.Utils.extractSession', 'extractSession', ({(18, 33, 18, 37): 'info'}, {}), '(info)', False, 'from graphqltypes.Utils import extractSession\n'), ((24, 18, 24, 38), 'graphqltypes.Utils.extractSession', 'extractSession', ({(24, 33, 24, 37): 'info'}, {}), '(info)', False, 'from graphqltypes.Utils import extractSession\n'), ((30, 18, 30, 38), 'graphqltypes.Utils.extractSession', 'extractSession', ({(30, 33, 30, 37): 'info'}, {}), '(info)', False, 'from graphqltypes.Utils import extractSession\n')]