Odyssey

Lift-off V: Production & the Schema Registry
deprecated

Overview & SetupWhat is the schema registry?Registering our schemaDeploying Apollo ServerDeploying Apollo ClientField deprecationSchema changes in the registryMonitoring and scaling our API
3. Registering our schema
2m

📝 Let's register our schema!

The first step of getting our app into production is registering our schema with Apollo.

Let's go to Apollo Studio in the browser. You'll need an Apollo account set up with an organization.

In previous courses, we've tested our locally running graph using Sandbox. This helped us easily prototype and iterate on our schema changes. To register a schema deployed in production, we need to create a deployed graph, which integrates with the schema registry. A deployed graph is visible to all members of your organization.

Graphs!
Sandbox is a 
 
 environment where we can explore and test a GraphQL schema. To register a 
 
schema and track our changes over time, we can create a
 
 in Apollo Studio, which is visible to
 
.

Drag items from this box to the blanks above

  • the whole organization

  • production

  • development

  • destructible graph

  • deployed graph

  • the whole world

To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.

📈 Creating a graph

Note: Depending on when you created your account and what plan you're on, your Studio account might look a bit different than what we're showing in the video or lesson instructions.


Before continuing with the lesson, expand the section below to find your specific steps on how to create a graph.


First things first, do you have an GraphOS account?

First, you'll need to create an account. Visit the following link: http://studio.apollographql.com/signup.

After creating your account, you'll see something that looks like this:

The Studio homepage showing the Graphs tab and a 'Welcome to GraphOS Studio message'

Click the "Coming from Apollo Odyssey..." link.

The Studio homepage showing the Graphs tab and a 'Welcome to GraphOS Studio message', with an arrow pointing to the text link saying 'Coming from Apollo Odyssey...'

You'll see a modal pop up to create a classic graph.

The New Classic Graph Creation modal

Then, skip the next two questions. Jump back into this lesson's instructions and follow along.


If you do have an account already and you're logged in to Studio, what do you see on the top right of the homepage's navigation bar?

The Studio homepage's navigation bar

You'll need to upgrade your plan to the serverless (free) plan.

Click "Convert to Serverless (Free)" on the top right.

The Studio homepage's navigation bar, with the 'Convert to Serverless (Free)' button highlighted

A modal will pop up explaining the plan's features.

A modal explaining the serverless (free) plan features

Click "Yes, convert my account".

Next, what do you see on the Studio homepage? Expand another collapsible section below that best matches what you see.

Click "Create New Graph".

The Studio homepage with the 'New Graph' button highlighted.

You'll see a modal pop up to create a graph.

A Graph Creation modal

Skip the next question, jump back into this lesson's instructions and follow along.


If you chose 1A) and finished converting your account, what do you see on the Studio homepage?

Your page looks like this:

The Studio homepage showing the Graphs tab and a 'Welcome to GraphOS Studio message'

Click the "Coming from Apollo Odyssey..." link.

The Studio homepage showing the graphs tab and a 'Welcome to GraphOS Studio message', with an arrow pointing to the text link saying 'Coming from Apollo Odyssey...'

You'll see a modal pop up to create a classic graph.

The New Classic Graph Creation modal

Then, jump back into this lesson's instructions and follow along.

Your page looks like this:

The Studio homepage on the Graphs tab with a 'Create New Graph' button with no dropdown arrow beside it

Scroll down to find a notice on the bottom right corner of the screen. Click "Head over to our classic graph flow".

The Studio homepage under the Graphs tab, a notice on the bottom right corner of the screen is highlighted.

You'll see a modal pop up to create a classic graph.

The New Classic Graph Creation modal

Jump back into this lesson's instructions and follow along.

Your page looks like this:

The Studio homepage on the Graphs tab with a 'Create New Graph' button with no dropdown arrow beside it

Click the arrow beside "Create New Graph", then click "New Classic Graph".

The Studio homepage clicking the arrow and 'New Classic Graph' selected

You'll see a modal pop up to create a classic graph.

The New Classic Graph Creation modal

Jump back into this lesson's instructions and follow along.

Give it a title. Select Monolith as the graph architecture, then click Next.

https://studio.apollographql.com
Screenshot of the modal for creating a new graph with the correct inputs

From here, we have a few ways to register our schema, but we'll focus on the first option: Apollo Server. This method uses a protocol called schema reporting, where our GraphQL server automatically registers its latest schema every time it starts up! To enable this, we need to set up the three environment variables shown on the page:

APOLLO_KEY=service:xxxxx
APOLLO_GRAPH_REF=xxxxxx
APOLLO_SCHEMA_REPORTING=true

Note: We used to have separate variables for APOLLO_GRAPH_ID and APOLLO_GRAPH_VARIANT, but those have now been combined into a single environment variable: APOLLO_GRAPH_REF. (Under the hood, the structure of the graph reference variable is really <APOLLO_GRAPH_ID>@<APOLLO_GRAPH_VARIANT>.)

How does Apollo Server automatically register its schema in production?

We'll use these environment variables when we get our GraphQL server into production!

Previous
Next

Share your questions and comments about this lesson

Your feedback helps us improve! If you're stuck or confused, let us know and we'll help you out. All comments are public and must follow the Apollo Code of Conduct. Note that comments that have been resolved or addressed may be removed.

You'll need a GitHub account to post below. Don't have one? Post in our Odyssey forum instead.

              graph

              A schema-based data model representing how different data elements interconnect and can be accessed.

              graph

              A schema-based data model representing how different data elements interconnect and can be accessed.

              GraphOS

              A platform for building and managing a supergraph. It provides a management plane to test and ship changes and runtime capabilities to secure and monitor the graph.

              classic graph

              A graph that operates on a standalone GraphQL server, which receives queries directly from client applications without a router.

              serverless

              A legacy Apollo plan with both free and paid versions that lets you run a cloud router on shared infrastructure. Intended for developers and teams evaluating GraphOS.

              graph

              A schema-based data model representing how different data elements interconnect and can be accessed.

              classic graph

              A graph that operates on a standalone GraphQL server, which receives queries directly from client applications without a router.

              classic graph

              A graph that operates on a standalone GraphQL server, which receives queries directly from client applications without a router.

              classic graph

              A graph that operates on a standalone GraphQL server, which receives queries directly from client applications without a router.

              graph

              A schema-based data model representing how different data elements interconnect and can be accessed.

              Apollo Server

              An open-source library for server-side GraphQL operation handling. It can be used as a monolithic GraphQL server or a subgraph server within a supergraph.

              GraphQL server

              A server that contains a GraphQL schema and can resolve client-requested operations that are executed against that schema.

              variables

              A placeholder for dynamic values in an operation allowing parameterization and reusability in requests. Variables can be used to fill arguments or passed to directives.

              query GetUser($userId: ID!) {
              user(id: $userId) {
              firstName
              }
              }

              In the query above, userId is a variable. The variable and its type are declared in the operation signature, signified by a $. The type of variable is a non-nullable ID. A variable's type must match the type of any argument it's used for.

              graph ref

              A unique identifier for a particular variant of a particular graph in GraphOS. Made up of a graph's unique ID and variant name with the following format: graph-id@variant-name.

              variable

              A placeholder for dynamic values in an operation allowing parameterization and reusability in requests. Variables can be used to fill arguments or passed to directives.

              query GetUser($userId: ID!) {
              user(id: $userId) {
              firstName
              }
              }

              In the query above, userId is a variable. The variable and its type are declared in the operation signature, signified by a $. The type of variable is a non-nullable ID. A variable's type must match the type of any argument it's used for.

              GraphQL server

              A server that contains a GraphQL schema and can resolve client-requested operations that are executed against that schema.

              NEW COURSE ALERT

              Introducing Apollo Connectors

              Connectors are the new and easy way to get started with GraphQL, using existing REST APIs.

              Say goodbye to GraphQL servers and resolvers—now, everything happens in the schema!

              Take the course