Built-In Plugins


Plugins extend Apollo Server's functionality by performing custom operations in response to certain events. These events correspond to individual phases of the GraphQL request lifecycle, and to the lifecycle of Apollo Server itself.

Certain Apollo Server features are provided as built-in plugins that are exported from within the @apollo/server package. Apollo Server installs certain plugins automatically, but you can also install them manually to override their default settings. See each plugin's documentation for details.

You can also create custom plugins .

List of built-in plugins

NameDescriptionLocation
Usage reporting Gathers helpful operation usage data and reports it to GraphOS for visualization, alerting, and more.@apollo/server/plugin/usageReporting
Schema reporting Automatically reports the server's schema to GraphOS on startup to enable schema history and up-to-date metrics.@apollo/server/plugin/schemaReporting
Inline trace Used primarily by federated subgraphs to include operation trace data in responses to the gateway.@apollo/server/plugin/inlineTrace
Cache control Calculates caching behavior for operation responses.@apollo/server/plugin/cacheControl
Landing page (multiple) Handle displaying a default or custom landing page at Apollo Server's base URL.@apollo/server/plugin/landingPage/default
Draining an HTTP server Used to ensure your Node.js servers gracefully shut down.@apollo/server/plugin/drainHttpServer
Enable federated subscriptions Enables your server to handle federated subscription requests from Apollo Router via the callback protocol.@apollo/server/plugin/subscriptionCallback

Installing plugins

You can install a plugin that isn't installed by default (or customize a default plugin) by providing a plugins configuration option to the ApolloServer constructor, like so:

TypeScript
1import { ApolloServer } from "@apollo/server";
2import { ApolloServerPluginUsageReporting } from '@apollo/server/plugin/usageReporting';
3
4const server = new ApolloServer({
5  typeDefs,
6  resolvers,
7  plugins: [
8    // Sets a non-default option on the usage reporting plugin
9    ApolloServerPluginUsageReporting({
10      sendVariableValues: { all: true },
11    }),
12  ],
13});