GraphQL Errors
When an error occurs when processing GraphQL queries, graphql-js sends the complete error message to the client with the response. In most cases, sending error messages to the client without supervision is not recommended. The graphql-errors
module fixes this issue by masking error messages sent to the client. This module intercepts GraphQL error messages and replaces them with "internal error"
.
var express = ;var graphql = ;var graphqlHTTP = ;var maskErrors = maskErrors;var schema =query:name: 'RootQueryType'fields:test:type: graphqlGraphQLString{throw 'secret error message';};// mask error messages;var app = ;app;app;
To make error debugging easier, it logs the error on the server with the stack. The module can be activated on a schema using its processSchema
function.