Update User Mutation Implemented and working
This commit is contained in:
1 parent
423b0c763d
commit
97a80db21e
2 files changed
+67
No files matched your search
@@ -0,0 +1,36 @@
|
||||
mutation {
|
||||
addUser (alias: "aaa", firstName:"fff", lastName: "lll", roleId: "1", isTrader: 1, isDeveloper: 0) {
|
||||
alias
|
||||
isTrader
|
||||
isDeveloper
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mutation {
|
||||
updateUser (
|
||||
id: "5b8d152f6f4d5b3db44ee103" ,
|
||||
alias: "luis",
|
||||
firstName:"Luis",
|
||||
lastName: "Molina",
|
||||
isDeveloper: 1,
|
||||
isTrader: 1,
|
||||
isDataAnalyst: 1,
|
||||
roleId: "2"
|
||||
) {
|
||||
alias
|
||||
}
|
||||
}
|
||||
|
||||
query {
|
||||
|
||||
users{
|
||||
alias
|
||||
firstName
|
||||
isDeveloper
|
||||
role{
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,6 +119,37 @@ const Mutation = new GraphQLObjectType({
|
||||
});
|
||||
return user.save();
|
||||
}
|
||||
},
|
||||
updateUser:{
|
||||
type: UserType,
|
||||
args: {
|
||||
id: {type: new GraphQLNonNull(GraphQLID)},
|
||||
alias: {type: new GraphQLNonNull(GraphQLString)},
|
||||
firstName: {type: GraphQLString},
|
||||
lastName: {type: GraphQLString},
|
||||
isDeveloper: {type: GraphQLInt},
|
||||
isTrader: {type: GraphQLInt},
|
||||
isDataAnalyst: {type: GraphQLInt},
|
||||
roleId: {type: new GraphQLNonNull(GraphQLString)}
|
||||
},
|
||||
resolve(parent, args) {
|
||||
|
||||
let key = {
|
||||
_id: args.id
|
||||
};
|
||||
|
||||
let updatedUser = {
|
||||
alias: args.alias,
|
||||
firstName: args.firstName,
|
||||
lastName: args.lastName,
|
||||
isDeveloper: args.isDeveloper,
|
||||
isTrader: args.isTrader,
|
||||
isDataAnalyst: args.isDataAnalyst,
|
||||
roleId: args.roleId
|
||||
};
|
||||
|
||||
return User.update(key, updatedUser);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user