The Apollo schema registry powers nearly every feature of Apollo Studio, along with helpful developer tools like our VS Code extension.
To register your schema, first obtain a graph API key for your graph:
API keys are secret credentials. Never share them outside your organization or commit them to version control. Delete and replace API keys that you believe are compromised.
If a "Publish your Schema" dialog appears, copy the protected value that appears after APOLLO_KEY= in the example code block (it begins with service:), and you're all set.
Otherwise, proceed to the next step.
Open your graph's Settings page and select the API Keys tab. Click Create New Key. Give your key a name, such as Production. This helps you keep track of each API key's use.
If you don't see the API Keys tab, you don't have sufficient permissions for your graph. Only organization members with the Org Admin or Graph Admin role can manage graph API keys. Learn more about member roles.
Copy the key's value. For security, you cannot view an API key's value in Studio after creating it.
After you obtain your API key, select the registration method that corresponds to your graph's architecture:
Apollo Server supports a feature called schema reporting that enables it to register its schema automatically on startup.
Set your graph API key as the value of the APOLLO_KEY environment variable in your server's environment, and set the APOLLO_SCHEMA_REPORTING environment variable to true.
If you're using the dotenv library, you can add these definitions to the .env file in your project's root directory, like so:
.env
1
APOLLO_KEY=YOUR_KEY_HERE
2
APOLLO_SCHEMA_REPORTING=true
3
APOLLO_GRAPH_ID=your-graph-id
Important: If you use a .env file, do not commit it to version control. Always use .gitignore or a similar method to omit files that include secret credentials.
You can alternatively provide these values to Apollo Server via the apollo constructor option, but again, do not add secret credentials to your application source.
Now whenever your server starts up, it automatically registers its schema with the Apollo schema registry and begins pushing metrics to Apollo Studio!
We would love for other GraphQL servers to support schema reporting too! If you're interested in implementing support, the protocol is documented here.
As shown, the first positional argument you provide rover graph publish is a graph ref, a string that specifies a particular variant of a particular graph in Studio.
Then, do the following for each of your subgraphs:
Obtain the following values, which are required for the rover subgraph publish command:
The name that uniquely identifies the subgraph within your graph (e.g., products).
If you've already registered a particular subgraph at least once, you can get its name from your graph's Schema > SDL tab in Apollo Studio, or by running rover subgraph list.
Otherwise, you set the subgraph's name the first time you register it. Make sure the name is unique within your graph.
The URL that your gateway will use to communicate with the subgraph (e.g., http://products-graphql.svc.cluster.local:4001/).
The service's schema. The Rover CLI can either:
Use a .gql or .graphql file saved on your local machine, or
Perform an introspection query on the running service to fetch the schema
Run the rover subgraph publish command, providing your schema in one of the ways shown:
As you register your subgraph schemas, the schema registry attempts to compose their latest versions into a single supergraph schema. Whenever composition succeeds, your gateway can fetch the latest supergraph schema from the registry.
You can also fetch your latest supergraph schema with the rover supergraph fetch command, and it's available in Apollo Studio from your graph's Schema > SDL tab.
After you register your schema, select your graph in Apollo Studio and open its Fields tab. You'll see a list of all of your schema's types and fields.
Now that your schema's registered, you're ready to try out one of Studio's most powerful features: the Explorer. This tool provides visibility into your entire schema and helps you build and run queries against it.
From Apollo Studio, select your graph and open its Explorer tab. Complete its Getting Started steps to see what it can do!
Studio can connect to your Slack workspace to send a notification whenever your registered schema is updated. If you configure metrics reporting, Studio can also send you a daily metrics report.
Your schema is now registered with Studio, and your server is pushing operation metrics!
However, to get the most out of Studio, you need to re-register your server's schema every time it changes. The easiest way to do this is to make schema registration part of every deployment in your application's continuous delivery flow.
If you set up schema reporting in Step 3 (the first schema registration option), Apollo Server automatically registers your schema every time it starts up, and no additional setup is required.
The best way to fully familiarize yourself with Studio is to use it! Visit studio.apollographql.com and check out the all the various views and what they provide.
The docs also have plenty of information on the features available for plans of all types, including: