mutations.py 文件源码

python
阅读 40 收藏 0 点赞 0 评论 0

项目:crm 作者: Incubaid 项目源码 文件源码
def mutate(cls, root, context, **kwargs):
        """
        Mutation logic is handled here
        """
        # 'before_insert' hooks won't work with db.session.bulk_save_objects
        # we need to find a way to get hooks to work with bulk_save_objects @todo

        objs = []

        for data in kwargs.get('records', []):
            c = Contact.get_object_from_graphql_input(data)
            db.session.add(c)
            objs.append(c)
        try:
            db.session.commit()
            return cls(ok=True, ids=[obj.id for obj in objs])
        except Exception as e:
            raise GraphQLError(e.args)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号