Docs
Launch GraphOS Studio

Built-in plugins


Plugins extend 's functionality by performing custom in response to certain events. These events correspond to individual phases of the 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 reportingGathers helpful operation usage data and reports it to GraphOS for visualization, alerting, and more.@apollo/server/plugin/usageReporting
Schema reportingAutomatically reports the server's schema to GraphOS on startup to enable schema history and up-to-date metrics.@apollo/server/plugin/schemaReporting
Inline traceUsed primarily by federated subgraphs to include operation trace data in responses to the gateway.@apollo/server/plugin/inlineTrace
Cache controlCalculates 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 serverUsed to ensure your Node.js servers gracefully shut down.@apollo/server/plugin/drainHttpServer
Enable federated subscriptionsEnables 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:

import { ApolloServer } from "@apollo/server";
import { ApolloServerPluginUsageReporting } from '@apollo/server/plugin/usageReporting';
const server = new ApolloServer({
typeDefs,
resolvers,
plugins: [
// Sets a non-default option on the usage reporting plugin
ApolloServerPluginUsageReporting({
sendVariableValues: { all: true },
}),
],
});
Previous
expressMiddleware
Next
Usage reporting
Edit on GitHubEditForumsDiscord

© 2024 Apollo Graph Inc.

Privacy Policy

Company