So I want a user to be able to edit his data (in this case the email)in graphql, but i get a "Cannot return null for non-nullable field Mutation.updateUser" error and i cant figure out whats wrong
my defs:
type Mutation{
updateUser(id: ID! email: String!): User!
}
type User{
id: ID!
email: String!
token: String!
createdAt: String!
username: String!
bio: String,
}
code:
module.exports = {
Mutation: {
async updateUser(parent, args) {
return User.findOneAndUpdate({ id: args.id }, { email: args.email }, { new: true })
}
}
}
user schema:
const userSchema = new Schema({
username: String,
password: String,
email: String,
createdAt: String,
bio: String,
});