apollo-server-express, express-graphql, and graphql-yoga are all libraries used to build GraphQL servers within the Node.js ecosystem, specifically integrating with the Express web framework.
apollo-server-express is the official Express integration for Apollo Server, offering a robust, feature-rich environment with strong tooling support like Apollo Studio.
express-graphql was the reference implementation for running GraphQL over Express but is now deprecated, having been replaced by more modern, spec-compliant alternatives.
graphql-yoga is a modern, fully-featured GraphQL server maintained by The Guild, focusing on ease of use, strict spec compliance, and flexibility across different runtime environments including serverless.
When building a GraphQL API in Node.js, the server layer is critical. It handles parsing requests, validating queries, executing resolvers, and sending responses. While apollo-server-express, express-graphql, and graphql-yoga all serve this purpose, they differ significantly in maintenance status, architecture, and developer experience. Let's break down the technical realities of each.
The first thing an architect must check is whether a library is safe to use long-term.
express-graphql is deprecated.
// express-graphql: Deprecated usage (Do not use)
const { graphqlHTTP } = require('express-graphql');
app.use('/graphql', graphqlHTTP({ schema }));
apollo-server-express is actively maintained (as part of Apollo Server 4).
// apollo-server-express: Apollo Server 4 usage
const { ApolloServer } = require('@apollo/server');
const { expressMiddleware } = require('@apollo/server/express4');
const server = new ApolloServer({ typeDefs, resolvers });
await server.start();
app.use('/graphql', expressMiddleware(server));
graphql-yoga is actively maintained.
// graphql-yoga: Current usage
import { createYoga } from 'graphql-yoga';
import { createServer } from 'http';
const yoga = createYoga({ schema });
const server = createServer(yoga);
server.listen(4000);
How much code do you need to write to get a server running?
express-graphql was minimal but rigid.
// express-graphql: Manual setup
app.use('/graphql', graphqlHTTP({
schema: mySchema,
graphiql: true, // Built-in IDE but limited
}));
apollo-server-express is feature-heavy.
// apollo-server-express: Plugin configuration
const server = new ApolloServer({
typeDefs,
resolvers,
plugins: [ /* Custom plugins for logging, etc. */ ]
});
graphql-yoga aims for zero-config.
// graphql-yoga: Zero-config features
const yoga = createYoga({
schema,
// GraphiQL is enabled by default in dev
// CORS is handled automatically
});
Where can you deploy your code?
express-graphql is tied to Node.js.
// express-graphql: Node/Express specific
// Requires Express app instance
app.use('/graphql', ...);
apollo-server-express is primarily Node.js focused.
express package specifically targets Node environments.// apollo-server-express: Node specific
// Tightly coupled with Express middleware pipeline
await server.start();
graphql-yoga is runtime agnostic.
whatwg-fetch standards.// graphql-yoga: Agnostic handler
// Works as a standard Web Fetch API handler
export const handler = (req) => yoga.handleRequest(req);
How do you add features like authentication, logging, or subscriptions?
express-graphql has no plugin system.
subscriptions-transport-ws, which is also deprecated).// express-graphql: Custom middleware
app.use('/graphql', (req, res, next) => {
// Manual auth logic
next();
}, graphqlHTTP({ schema }));
apollo-server-express relies on a robust plugin system.
apollo-server-plugin or separate WebSocket handling.// apollo-server-express: Plugin system
const server = new ApolloServer({
typeDefs,
resolvers,
plugins: [
{ async requestDidStart() { /* Logging logic */ } }
]
});
graphql-yoga includes many features out-of-the-box.
// graphql-yoga: Built-in features
const yoga = createYoga({
schema,
// Subscriptions and uploads often work without extra config
// Plugins use the envelop standard
plugins: [ /* envelop plugins */ ]
});
Despite their differences, all three share core GraphQL fundamentals.
// Shared Schema Definition
const typeDefs = `#graphql
type Query {
hello: String
}
`;
// Shared Resolver Pattern
const resolvers = {
Query: {
hello: () => 'world'
}
};
graphql-yoga and apollo-server-express enable this by default in development.// All support GraphiQL
// apollo-server-express: Enabled by default in dev
// graphql-yoga: Enabled by default in dev
// express-graphql: Enabled via `graphiql: true`
context object to resolvers.// Shared Context Pattern
// apollo-server-express
context: ({ req }) => ({ user: req.user })
// graphql-yoga
context: ({ req }) => ({ user: req.user })
// express-graphql
context: { user: req.user }
| Feature | apollo-server-express | express-graphql | graphql-yoga |
|---|---|---|---|
| Status | ✅ Active (v4) | ❌ Deprecated | ✅ Active |
| Runtime | ☁️ Node.js | ☁️ Node.js | 🌍 Node, Edge, Serverless |
| Setup | 🛠️ Moderate (Plugins) | 🛠️ Basic (Manual) | 🚀 Simple (Batteries Included) |
| Subscriptions | 🔌 Plugin Required | ❌ Deprecated/Manual | ✅ Built-in Support |
| Spec Compliance | ✅ High | ⚠️ Low (Outdated) | ✅ Very High |
| Ecosystem | 👥 Apollo Studio | 🕰️ Legacy | 👥 The Guild / Envelop |
express-graphql is a legacy tool.
apollo-server-express is the enterprise choice.
graphql-yoga is the modern standard.
Final Thought: For most new Node.js projects today, graphql-yoga offers the best balance of simplicity and power. However, if your organization relies heavily on Apollo's commercial tooling, apollo-server-express remains a solid, supported choice. Avoid express-graphql entirely.
Choose apollo-server-express if you are already invested in the Apollo ecosystem and need deep integration with Apollo Studio for monitoring, tracing, and schema management. It is suitable for enterprise applications requiring a stable, well-documented solution with extensive plugin support, provided you are using Apollo Server 4 or later.
Do NOT choose express-graphql for new projects. It is officially deprecated and no longer maintained. Existing projects using this package should plan a migration to graphql-http or another modern alternative to ensure security updates and spec compliance.
Choose graphql-yoga if you want a modern, batteries-included server that works seamlessly across Node.js, serverless, and edge runtimes. It is ideal for developers who prefer strict GraphQL spec compliance, built-in features like file uploads and subscriptions without extra plugins, and a simpler setup experience.
This is the Express integration of Apollo Server. Apollo Server is a community-maintained open-source GraphQL server that works with many Node.js HTTP server frameworks. Read the docs. Read the CHANGELOG.
A full example of how to use apollo-server-express can be found in the docs.
Before Apollo Server 3, we officially supported using this package with connect as well. connect is an older framework that express evolved from. For now, we believe that this package is still compatible with connect and we even run tests against connect, but we may choose to break this compatibility at some point without a major version bump. If you rely on the ability to use Apollo Server with connect, you may wish to make your own integration.
GraphQL Server is built with the following principles in mind:
Anyone is welcome to contribute to GraphQL Server, just read CONTRIBUTING.md, take a look at the roadmap and make your first PR!