Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

graphql-errors

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-errors

Better error handling for GraphQL

  • 2.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1K
decreased by-47.41%
Maintainers
1
Weekly downloads
 
Created
Source

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 = require('express');
var graphql = require('graphql');
var graphqlHTTP = require('express-graphql');
var maskErrors = require('graphql-errors').maskErrors;

var schema = new graphql.GraphQLSchema({
  query: new graphql.GraphQLObjectType({
    name: 'RootQueryType',
    fields: {
      test: {
        type: graphql.GraphQLString,
        resolve() {
          throw new Error('secret error message');
        },
      },
    },
  }),
});

// mask error messages
maskErrors(schema);

var app = express();
app.use('/', graphqlHTTP({schema: schema}));
app.listen(3000);

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.

Keywords

FAQs

Package last updated on 11 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc