graphql-format-error-context-extension
![license](https://camo.githubusercontent.com/a4426cbe5c21edb002526331c7a8fbfa089e84a550567b02a0d829a98b136ad0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)
- 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,
});