graphql-format-error-context-extension

0.2.15 • Public • Published

graphql-format-error-context-extension

NPM version build status Test coverage David deps Known Vulnerabilities npm download license

Usage

  • This package needs graphql-extensions to be installed: npm i graphql-extensions --save
  • Install the npm package as a dependency npm i graphql-format-error-context-extension --save
  • Add this extension and use context on formatError like this:
const { ApolloServer } = require('apollo-server-koa');
const { FormatErrorWithContextExtension } = require('graphql-format-error-context-extension');
 
const formatError = (err, context) => {
  // can use `err` and `context`
  return err;
};
 
const server = new ApolloServer({
    typeDefs,
    resolvers,
    extensions: [() => new FormatErrorWithContextExtension(formatError)],
    context: ({ ctx }) => ctx,
});

Package Sidebar

Install

npm i graphql-format-error-context-extension

Weekly Downloads

365

Version

0.2.15

License

MIT

Unpacked Size

584 kB

Total Files

7

Last publish

Collaborators

  • jiangzemin