# Apollo Server — Production GraphQL Server for Node.js > Apollo Server is an open-source, spec-compliant GraphQL server that works with any Node.js HTTP framework. It provides schema-first development, built-in caching, federation support for microservices, and integrations with Express, Fastify, Koa, and serverless platforms. ## Install Save in your project root: # Apollo Server — Production GraphQL Server for Node.js ## Quick Use ```bash npm install @apollo/server graphql ``` ```js import { ApolloServer } from '@apollo/server'; import { startStandaloneServer } from '@apollo/server/standalone'; const server = new ApolloServer({ typeDefs, resolvers }); const { url } = await startStandaloneServer(server, { listen: { port: 4000 } }); ``` ## Introduction Apollo Server is a community-driven, open-source GraphQL server for Node.js. It simplifies building a production-ready GraphQL API by providing schema definition, resolver wiring, error handling, and performance monitoring out of the box. It works as a standalone server or as middleware in existing HTTP frameworks. ## What Apollo Server Does - Serves a GraphQL API from type definitions and resolver functions - Supports incremental adoption via Express, Fastify, Koa, and Lambda integrations - Implements Apollo Federation for composing multiple GraphQL services into one graph - Provides automatic persisted queries and response caching plugins - Includes built-in landing page with Apollo Sandbox for testing queries ## Architecture Overview Apollo Server parses your SDL schema and resolver map at startup, building an executable schema using graphql-js. Incoming HTTP requests are parsed, validated against the schema, and executed through the resolver tree. A plugin system hooks into the request lifecycle for logging, caching, tracing, and error formatting. In federated setups, Apollo Router sits in front and delegates subqueries to individual Apollo Server subgraph instances. ## Self-Hosting & Configuration - Install via npm or yarn alongside the graphql peer dependency - Use `startStandaloneServer` for quick setup or integrate as middleware with `expressMiddleware` - Configure CORS, body parser limits, and request batching in server options - Add plugins for cache control, usage reporting, and inline tracing - Deploy on any Node.js host, container, or serverless platform like AWS Lambda ## Key Features - Full GraphQL spec compliance including subscriptions via WebSocket - Plugin architecture for lifecycle hooks: request parsing, validation, execution, response - Built-in Apollo Sandbox as an in-browser IDE for exploring the API - First-class TypeScript support with type-safe context and resolver signatures - Federation-ready with support for @key, @requires, and @external directives ## Comparison with Similar Tools - **Express GraphQL** — Minimal middleware; Apollo Server adds caching, federation, and plugins - **Mercurius** — Fastify-native GraphQL server; lighter but fewer ecosystem integrations - **Yoga** — Envelop-based server from The Guild; more modular plugin system - **Hasura** — Auto-generates GraphQL from Postgres; Apollo Server requires hand-written resolvers - **PostGraphile** — Database-driven GraphQL; Apollo Server is framework-agnostic ## FAQ **Q: Does Apollo Server require Apollo Studio?** A: No. Apollo Server is fully open source and works standalone. Apollo Studio is an optional paid service for schema registry and metrics. **Q: Can I use Apollo Server with TypeScript?** A: Yes. Apollo Server 4 is written in TypeScript and provides full type safety for resolvers and context. **Q: How does federation work?** A: Each service defines a subgraph schema. Apollo Router composes them into a supergraph and routes incoming queries to the appropriate subgraphs at runtime. **Q: Is Apollo Server suitable for serverless?** A: Yes. Apollo Server 4 supports AWS Lambda, Google Cloud Functions, and Azure Functions via lightweight integrations. ## Sources - https://github.com/apollographql/apollo-server - https://www.apollographql.com/docs/apollo-server/ --- Source: https://tokrepo.com/en/workflows/asset-8b5c8fb0 Author: AI Open Source