apollo-errors v1.9.0 is a utility for creating machine-readable custom GraphQL errors for use with Apollo Server. It allows defining typed errors with structured data and internal logging data that can be separated from the client-facing response. The package provides createError() to define error classes, formatError() for server error formatting, and isInstance() for checking error types. It ships TypeScript definitions. The project appears to be in maintenance mode with no recent updates. Compared to alternatives like graphql-errors, it offers explicit data and internalData separation and built-in formatting for Apollo Server.
npm install apollo-errorsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to define a custom error, configure Apollo Server to use formatError, and log internal data.
Use isInstance(err.originalError) instead of isInstance(err) inside formatError.
Consider using ApolloServer's built-in ApolloError from 'apollo-server-errors' or 'graphql-tools' for official support.
Always handle non-ApolloErrors explicitly in your custom formatter.
Use named import: import { createError } from 'apollo-errors'Check isInstance(err.originalError) before calling formatError inside your Apollo Server formatError function
Run npm install apollo-errors