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 only worked with development graphs, which are graphs that are only visible to you. 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!

In Apollo,
 
are graphs that help prototype schema changes quickly, and are visible to
 
. On the other hand,
 
are visible to
 
, and are used for schemas deployed in production.

Drag items from the box to the blanks above

destructible graphs
development graphs
deployed graphs
the whole world
only you
the whole organization

📈 Creating a deployed graph

Let's click on New Graph. Give it a title and select Deployed as the graph type. 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 4 variables: APOLLO_KEY, APOLLO_GRAPH_ID, APOLLO_GRAPH_VARIANT and APOLLO_SCHEMA_REPORTING.
We now use 3: APOLLO_KEY, APOLLO_GRAPH_REF and APOLLO_SCHEMA_REPORTING, as ID and VARIANT have been merged into APOLLO_GRAPH_REF (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