S
S
Shmebilock2019-12-02 22:12:01
Node.js
Shmebilock, 2019-12-02 22:12:01

How to send a bug report from apollo-server?

in apollo-react I use hooks useMutation.
apollo-react

const [addTodo, { loading, error, data }] = useMutation(gql);

Mutation: {
    signUp: async (_, formSignUp, { models: { User }, res }) => {
      try {
        const user = new User(formSignUp);
        await user.save();
        const token = await user.generateAuthToken();
        res.cookie("darkAmasia", token, {
          httpOnly: true
        });
        return "string";
      } catch (error) {
        ?????????
      }
    }
  }

What should I write in catch ? to send message {status: 400,error: true} to useMutation in error. I heard that throw new ApolloError is used for this purpose. But I don't know how to do it.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question