graphql-yoga: throw from resolver should not be logged

@steida commented on Mon Feb 26 2018

Maybe I am wrong, but

const throwError = (error /*: ServerError */) => {
  throw new Error(JSON.stringify(error));
};

const throwNotAuthorizedError = () => throwError({ type: 'notAuthorized' });

Seems to be a recommended way how to stop resolver, but then probably this should not be logged.

screen shot 2018-02-26 at 02 03 45

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 21 (2 by maintainers)

Most upvoted comments

@marktani if you still facing this problem you need to add debug: false in start options

const options = {
  port: 8080,
  endpoint: "/graphql",
  subscriptions: "/subscriptions",
  playground: "/playground",
  formatError(err: any): any {
    return err.message;
  },
  debug: false // this would prevent logs
};

server.start(options, () => {
  console.log("server started!");
});

@timsuchanek @divyenduz can you describe a couple of approaches here?