Production readiness checklist
We recommend that you complete this checklist before your supergraph begins handling production traffic from clients.
In Apollo Studio
- Ensure that you've created multiple variants to represent the different environments where your supergraph runs (production, staging, and so on).
- Optionally, protect your production variant to avoid accidental changes while working in Apollo Studio.
- Ensure that your clients identify themselves by name and version.
- If you're using an Apollo Client library, you can add a client name and version to the constructor.
- For example, the React client uses the
name
andversion
attributes in the constructor options.
- For example, the React client uses the
- If you're using a third-party GraphQL client, set the
apollographql-client-name
andapollographql-client-version
HTTP headers for each request to identify your client. - For an example of enforcing client identification in your gateway, see this technote for Client ID enforcement.
- If you're using an Apollo Client library, you can add a client name and version to the constructor.
Server-side
- For security, disable introspection for all production GraphQL servers.
- You can continue to view and fetch your GraphQL schemas from Apollo Studio.
- Ensure that you've correctly configured managed federation.
- Ensure that you've integrated
rover subgraph check
androver subgraph publish
into your CI/CD pipeline. - If your subgraph servers are listed as compatible with
ftv1
, ensure that you've enabled federated traces, and that you can view operation metrics as expected in Apollo Studio.- Enable fractional trace sampling via
fieldLevelInstrumentation
to reduce performance hits due to tracing.
- Enable fractional trace sampling via
- Consider adding caching layers.
- Apollo Server and the Apollo Router both support automatic persisted queries (APQ) out of the box.
- If you're using an Apollo Client library, make sure to enable APQ support.
- If using Apollo Server, ensure that you use a distributed caching system for APQ in production to avoid cache inconsistency across server instances.
- Optionally use the
@cacheControl
directive to enable your CDN to cache APQ GET requests using theCache-Control
header. - Additionally, you can configure your gateway can send APQ requests to your subgraphs.
- Optionally add full response caching to improve performance.
- Apollo Server and the Apollo Router both support automatic persisted queries (APQ) out of the box.
- Ensure that you've load-tested your graph.
- Test loads should be representative of your current traffic (both in terms of volume and in terms of the actual operations you execute in the test).
- To investigate performance issues, use Apollo Studio to identify which operations are performing slowly.
- Look at resolver execution times to identify slow areas of execution.
- Whenever possible, avoid making multiple calls to data sources within a single resolver.
- Understand query plan execution to help understand slow operations and optimize your supergraph to avoid them.
Apollo Gateway APQ example
This example uses both the buildService
option and the RemoteGraphQLDataSource
class to enable APQ to each subgraph.
import {ApolloServer} from '@apollo/server';import {startStandaloneServer} from '@apollo/server/standalone';import {ApolloGateway, RemoteGraphQLDataSource} from '@apollo/gateway';import {readFileSync} from 'fs';const gateway = new ApolloGateway({supergraphSdl: readFileSync('./supergraph.graphql').toString(),buildService: ({url}) => {return new RemoteGraphQLDataSource({url, apq: true});}});const server = new ApolloServer({gateway});// Note the top-level await!const {url} = await startStandaloneServer(server);console.log(`🚀 Server ready at ${url}`);