# graphql-errors

> Better error handling for GraphQL

Latest version **2.1.0** (published 2016-05-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install graphql-errors
pnpm add graphql-errors
yarn add graphql-errors
bun add graphql-errors
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2016-05-11 |
| First published | 2015-12-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/graphql-errors) |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 250 |
| Author | Kadira Inc. |
| Maintainers | mnmtanish |
| Keywords | graphql |

## Links

- npm: https://www.npmjs.com/package/graphql-errors
- Repository: https://github.com/kadirahq/graphql-errors
- Homepage: https://github.com/kadirahq/graphql-errors#readme
- Issues: https://github.com/kadirahq/graphql-errors/issues
- npm.io page: https://npm.io/package/graphql-errors

## Dependencies (2)

- [uuid](https://npm.io/package/uuid.md) ^2.0.2
- [babel-runtime](https://npm.io/package/babel-runtime.md) ^6.6.1

## Alternatives

- [apollo-link-http-common](https://npm.io/package/apollo-link-http-common.md) — 879.0K weekly downloads
- [react-relay](https://npm.io/package/react-relay.md) — 336.8K weekly downloads
- [relay-test-utils](https://npm.io/package/relay-test-utils.md) — 181.6K weekly downloads
- [@vendure/core](https://npm.io/package/@vendure/core.md) — 14.8K weekly downloads
- [@pnpm/deps.graph-sequencer](https://npm.io/package/@pnpm/deps.graph-sequencer.md) — 13.4K weekly downloads

## Recent versions

- 2.1.0 (latest) — 2016-05-11
- 2.0.2 — 2016-01-04
- 2.0.1 — 2016-01-04
- 2.0.0 — 2016-01-04
- 1.1.2 — 2015-12-31
- 1.1.1 — 2015-12-31
- 1.1.0 — 2015-12-31
- 1.0.1 — 2015-12-30

## README

# GraphQL Errors

When an error occurs when processing GraphQL queries, [graphql-js](https://github.com/graphql/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"`.

``` javascript
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.

---
_Source: https://npm.io/package/graphql-errors · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
