def mutate(cls, self, info, **kwargs): kwargs = input_to_dictionary(kwargs) data = kwargs.get("input") print(data) user = User.query.get(kwargs.get("id")) user.username = data.get("username") user.email = data.get("email") user.phone = data.get("phone") user.ccode = data.get("ccode") db.session.add(user) db.session.commit() user = User.query.get(user.id) return cls(output=user, ok=True, message="update")
def mutate(cls, self, info, **kwargs): kwargs = input_to_dictionary(kwargs) data = kwargs.get("input") print(data) user = User.query.get(kwargs.get("id")) user.name = data.get("name", "defautltname") user.password = data.get("password") for _id in data.get("roles"): rid = from_global_id(_id)[1] user.roles = [Role.query.get(rid) for i in data.get("roles")] db.session.add(user) db.session.commit() user = User.query.get(user.id) return cls(output=user, ok=True, message="操作成功")