apollo – Graphql-Shield hijacks errors

In the resolver throw new createError.BadRequest("bad input") error is hijacked by Graphql-shield and shown as

{
    "errors": [
        {
            "message": "Not Authorised!",
            "locations": [
                {
                    "line": 2,
                    "column": 3
                }
            ],
            "path": [
                "myMutation"
            ],
            "extensions": {
                "code": "INTERNAL_SERVER_ERROR",
                "exception": {
                    "stacktrace": [
                        "Error: Not Authorised!",

This is the Apollo Server setup

    const schema = buildSubgraphSchema([
      { typeDefs: await typeDefs(), resolvers },
    ]);
    const apolloServer = new ApolloServer({
      schema: applyMiddleware(schema, permissions),
      context: async ({ req, res }) => new AuthenticatedContext(req, res)
    });

How do I return the actual error occuring?

Read more here: Source link