def mutate(self, info, action="PUT", options=None): if action == "PUT": StoreProxy.store().Entity.put(options) elif action == "DELETE": StoreProxy.store().Entity.delete(options["id"]) else: raise Exception("Unsupported mutation action") entity = Entity(**options) return EntityMutation(entity=entity)
def mutate(self, info, action="PUT", options=None): if action == "PUT": StoreProxy.store().Bot.put(options) elif action == "DELETE": StoreProxy.store().Bot.delete(options["id"]) else: raise Exception("Unsupported mutation action") bot = Bot(**options) return BotMutation(bot=bot)
def mutate(self, info, action="PUT", options=None): if action == "PUT": StoreProxy.store().Rule.put(options) elif action == "DELETE": StoreProxy.store().Rule.delete(options["id"]) else: raise Exception("Unsupported mutation action") rule = Rule(**options) return RuleMutation(rule=rule)
def mutate(self, info, action="PUT", options=None): if action == "PUT": StoreProxy.store().Intent.put(options) elif action == "DELETE": StoreProxy.store().Intent.delete(options["id"]) else: raise Exception("Unsupported mutation action") intent = Intent(**options) return IntentMutation(intent=intent)
def resolve_bot(self, info, id): try: bot = StoreProxy.store().Bot.findById(id=id) return Bot(**bot) except Exception, e: print "e = ", e return Bot(**{})
def resolve_entities(self, *args, **kwargs): return [ Entity(**e) for e in StoreProxy.store().Bot.get_bot_entities(id=self.id) ]
def resolve_intents(self, *args, **kwargs): return [ Intent(**i) for i in StoreProxy.store().Bot.get_bot_intents(id=self.id) ]
def resolve_variables(self, *args, **kwargs): variables = [ Variable(**v) for v in StoreProxy.store().Entity.get_entity_variables(id=self.id) ] return variables
def resolve_rules(self, *args, **kwargs): return [ Rule(**v) for v in StoreProxy.store().Intent.get_intent_rules(id=self.id) ]
def store(cls, store=None): return StoreProxy.store()
def resolve_rules(self, info, intentid, offset=None, limit=None): return [Rule(**r) for r in StoreProxy.store().Rule.findByParent(parentid=intentid)]
def resolve_variables(self, info, entityid, offset=None, limit=None): return [Variable(**v) for v in StoreProxy.store().Variable.findByParent(parentid=entityid)]
def resolve_intent(self, *args, **kwargs): return Intent(**StoreProxy.store().Intent.findById(id=kwargs["id"]))
def resolve_entity(self, *args, **kwargs): return Entity(**StoreProxy.store().Entity.findById(id=kwargs["id"]))
return [Variable(**v) for v in StoreProxy.store().Variable.findByParent(parentid=entityid)] def resolve_rules(self, info, intentid, offset=None, limit=None): return [Rule(**r) for r in StoreProxy.store().Rule.findByParent(parentid=intentid)] def resolve_rule(self, *args, **kwargs): return Rule(**Query.store().Rule.findById(id=kwargs["id"])) def resolve_bots(self, info, offset=0, size=10): return [Bot(**b) for b in Query.store().Bot.list(offset=offset, size=size)] if __name__ == "__main__": from server.databot.model.models import Models StoreProxy.store(Models) schema = graphene.Schema(query=Query) r = schema.execute(""" { rules(intentid:"qnxarmz") { parent, id, name, description, replacements } } """) print r.errors print r.data
def resolve_bot(self): return Bot(**StoreProxy.store().Bot.findById(id=self.parent))