@as-integrations/express5
Apollo Server integration middleware for Express v5
Repository Health
Technical Analysis
@as-integrations/express5 provides expressMiddleware(), a small adapter function that turns an already-started Apollo Server instance into a standard express.RequestHandler, purpose-built for Express v5’s updated body-parsing and routing internals. It handles translating Express’s request/response objects into Apollo Server’s HTTPGraphQLRequest format, including header normalization, error responses for missing body-parser middleware, and context construction from the request/response pair.
The package is one of several framework-specific integrations published under the @as-integrations scope by the Apollo Server integrations organization, each targeting a single web framework (Express 4, Express 5, Koa, Fastify, etc.) rather than trying to abstract over all of them, so consumers only depend on the adapter matching their actual server framework.
What You Get
expressMiddleware()returning a ready-to-mountexpress.RequestHandler- Automatic translation of Express request/response objects into Apollo Server’s
HTTPGraphQLRequest/response shape - Typed context function support (
ExpressContextFunctionArgument) for injecting request-scoped GraphQL context - Built-in validation that body-parser middleware ran before the GraphQL handler, with a clear error message if not
- Express v5-specific compatibility (updated body-parser defaults, routing changes) not present in the Express v4 integration
Common Use Cases
- Mounting a GraphQL API built with Apollo Server onto an existing Express v5 application
- Migrating an Express v4 + Apollo Server app to Express v5 without switching GraphQL server implementations
- Adding request-scoped context (auth user, request ID) to Apollo Server resolvers from Express middleware state
- Running GraphQL alongside existing REST routes in the same Express v5 server instance
Under The Hood
Architecture - the entire package is a single 117-line src/index.ts module exporting one function, expressMiddleware(), which asserts the Apollo Server instance has started, builds a context function (defaulting to an empty object context), and returns an async Express handler that validates body-parser ran, converts the Express req/res into Apollo Server’s HTTPGraphQLRequest via HeaderMap, calls server.executeHTTPGraphQLRequest(), and writes the resulting headers/status/body back onto the Express response. Tech Stack - TypeScript with dual ESM/CJS build outputs (tsc --build), depending on @apollo/server and @apollo/utils.withrequired as peer-ish dependencies, packaged with changesets for versioning and Renovate for dependency updates. Code Quality - src/__tests__/integration.test.ts and expressSpecific.test.ts cover both generic Apollo Server integration behavior and Express-5-specific edge cases (body-parser detection, header handling), run under Jest with ESLint/Prettier/cspell enforced in CI. API Design - the API is deliberately minimal: one overloaded function whose TypeScript signatures force a context option only when the context type isn’t BaseContext, so integrating GraphQL into an Express app requires a single app.use('/graphql', expressMiddleware(server)) call.
Used by 3 apps in this directory
AFFiNE
Productivity · Project Management · Note Taking
Write, draw, and plan in one infinite canvas — the open-source alternative to Notion and Miro that keeps your data yours.
Hoppscotch
Developer Tools
A lightweight, offline-capable API development ecosystem for testing HTTP, GraphQL, WebSocket, MQTT, and SSE endpoints across web, desktop, and CLI.
Parse Server
Developer Tools · Databases
Self-hosted Backend-as-a-Service for Node.js with REST, GraphQL, real-time Live Query, cloud code, and pluggable adapters for any infrastructure.