W
W
Wasya UK2021-07-26 20:01:42
Node.js
Wasya UK, 2021-07-26 20:01:42

How to log errors in ApolloServer?

When I make a request, I make an error, as a result, it comes in the response, but I can’t get it to write it to the log. I'm trying to deal with logging in apollo, I will be glad to all the advice.

RESOLVER

getSomething: () => {
    throw new Error("hello error");
    return service.getAllSomething();
  },

LOGGER
const logger = {
  
 async didEncounterErrors(requestContext) {
    console.log('some error');
  },

  async requestDidStart(requestContext) {
    console.log('Request started! Query:\n' + requestContext.request.query);

    return {
      async didEncounterErrors(requestContext) {
        console.log('some error');
      },

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