bthe0
bthe0

Reputation: 1424

node graphql format error

I am trying to do a custom error format on graphql without using express-graphql. What I tried to do is:

import { graphql } from 'graphql';

graphql.formatError = err => ...;

Sadly, it doesn't work. It would be great if you guys could help me out.

Upvotes: 0

Views: 388

Answers (1)

rogerdossantos
rogerdossantos

Reputation: 191

Looking in the docs and the source code, I did'nt found anything about formatError in graphql module, only in 'express-graphql':

const express = require('express');
const graphqlHTTP = require('express-graphql');

const app = express();

app.use('/graphql', graphqlHTTP({
  schema: MyGraphQLSchema,
  graphiql: true,
  formatError: (error) => {}
}));

Upvotes: 1

Related Questions