I am using the mongdb database with graphql. But, graphql mutation createUser is returning null
{
 "data": {
    "createUser": null
  }
}
here is my mutation resolver code:
createUser: async args => {
        try {
          const existingUser = await User.findOne({ email: args.userInput.email });
          if (existingUser) {
            throw new Error('User exists already.');
          }
          const hashedPassword = await bcrypt.hash(args.userInput.password, 12);
          const user = new User({
            email: args.userInput.email,
            password: hashedPassword,
            username:args.userInput.username
          });
          const result = await user.save();
          return { ...result._doc, password: null, _id: result.id ,username:result.username};
        } catch (err) {
          throw err;
        }
    }
};
Please help. Everything seems right to me. Thanks in advance.
 
    