0
votes

this is my typedef:

type Mutation {
    login(email: String!, password: String!): String
  }

and , this is my auth resolver

module.exports = {
  Mutation: {
    async login(parent, { email, password }) {
      const user = await User.findOne({ email });
      const match = await bcrypt.compare(password, user.password);
      const payload = {
        user: {
          id: user.id,
        },
      };

      jwt.sign(
        payload,
        "123456",
        {
          expiresIn: 36000,
        },
        (err, token) => {
          if (err) throw err;
          console.log(token);
          
          return token;
        }
      );
    },
  },
};

On my mutation query it is returning null (the token is being shown on console log)

mutation{
  login(email: "user2@gmail.com", password: "1234567") 
}