您好,我想对包含用户名和电子邮件名的用户进行更新,但是如果我只想更改名称,所有其他字段都将为空,那么在我的代码中(我知道它的假人)。
Mutation: {
createUser: async (parent, { name, email, password }) => {
const user = new Users({ name, email, password });
await user.save();
return user;
},
deleteUser: async (parent, { id }) => {
const user = await Users.findById(id);
await user.deleteOne();
return user;
},
updateUser: async (parent, args ) => {
const user = await Users.findByIdAndUpdate(args.id, { $set: {
name: args.name, email: args.email, password: args.password }});
return user;
}
}