A GraphQL server extension (v0.2.15) that enables access to the request context inside the formatError function in Apollo Server (2.x). It bridges the gap between Apollo's formatError and the request context by injecting the context object as a second argument. Last release appears stable but uses deprecated graphql-extensions; no recent updates. Alternatives may use other approaches to pass context to error formatting.
npm install graphql-format-error-context-extensionNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates how to create an Apollo Server 2.x instance using the extension to access context in formatError.
Upgrade to Apollo Server 3+ and use built-in formatError with context via plugin (e.g., use 'willSendResponse' plugin) or switch to a compatible plugin.
For Apollo Server 2.18+, consider using the plugin API instead of extensions.
Always wrap the extension creation in a function: extensions: [() => new FormatErrorWithContextExtension(formatError)].
Ensure you are using require to import the package and wrap the instantiation in a function: const { FormatErrorWithContextExtension } = require('graphql-format-error-context-extension'); extensions: [() => new FormatErrorWithContextExtension(yourFormatErrorFn)];Ensure you are using the exported class, not the graphql-extensions module directly. Check your import statement.