2. Project setup
4m

Overview

You're excited to start making changes, but let's make sure we actually have a to make changes to. In this lesson, we will:

  • Deploy the recipes using Railway
  • Change a 's routing URL
  • Set up and authenticate the

Deploying your copy of the recipes subgraph server

This course is all about making changes to your , which involves making changes to its ! In the "GraphOS: Basics" course, we used an existing deployed version of the Poetic Plates API (which became our first called recipes). Now, let's make sure you have your own copy to make changes to.

We'll be using Railway to deploy our , but feel free to use any other hosting platform you're familiar with.

To get started, click the button below ⬇️

Deploy on Railway

Then, walk through the deploy setup steps in Railway.

Deploy successful on Railway? Great! Last thing: we want to our server at a public URL on the internet. To do this, we'll need to generate a domain.

Go to your app's Settings tab, and click the Generate Domain button under the Domains header.

https://railway.app

Deployment success

This will automatically create our production URL. After a few minutes, you should see a page showing that your server is ready to .

https://railway.app

Deployment success

Task!

Cloning the repo

Next, let's clone the repo and make sure we're set up for local development.

To find the repo, head over to your Railway app's Settings, scroll down to Service and find the Source repo link.

https://railway.app

Railway app Settings, Service tab, showing where to find the Source repo

Click the link to find your copy of the GitHub repo.

  1. Clone the repo to your local environment.

  2. Open it up in your code editor.

  3. Run npm install in a terminal.

  4. Run npm run dev. This starts up the server in development mode, which means changes you make in your files will automatically restart the server. If all goes well, when you open up http://localhost:4001, you should see Explorer with the schema ready to .

  5. Run the test below and confirm that you get data back!

    query GetRandomRecipe {
    randomRecipe {
    id
    name
    }
    }
Task!

Supergraph setup

Our subgraph is ready to be used, so next, let's get our cloud set up!

If you've already completed the previous course, then you should already have an existing cloud ! Currently, it's using the Apollo-hosted though. We'll want to fix that to point to your own deploy URL hosted on Railway from the previous step.

Edit the recipes subgraph routing URL

  1. Navigate to Apollo Studio and open up your 's homepage.

  2. Head over to the Subgraphs page.

  3. You should already see the recipes in the list, with the routing URL pointing to https://poetic-plates-recipes-api.herokuapp.com/. We need to change this to your Railway URL.

  4. Click the three dots beside the recipes and click Edit routing url.

    https://studio.apollographql.com/

    Studio Subgraphs page, click three dots and select edit routing URL

  5. Paste in the URL you generated from Railway, then hit Update.

    https://studio.apollographql.com/

    Studio Subgraphs page, update routing URL

    It'll take a few moments for the changes to land and deploy to our !

Check your supergraph

In Studio, navigate to the Explorer page and paste this .

query GetRandomRecipe {
randomRecipe {
id
name
readyTime
servings
ingredients {
text
}
}
}

You should get some data back!

Task!

Rover setup

is Apollo's command line interface (CLI) tool that helps developers work with and interact with . It's a handy and versatile tool that can be used for both local development and CI/CD. We can use it to run checks, publish schemas to the schema registry, and much more.

Installing Rover

  1. Open up a terminal and run the install command that suits your computer's environment:

    For Linux / Mac OS:

    curl -sSL https://rover.apollo.dev/nix/latest | sh

    For Windows PowerShell installer

    iwr 'https://rover.apollo.dev/win/latest' | iex
  2. Verify that the installation completed successfully by running rover anywhere in the terminal.

  3. If it outputs a list of options and subcommands for using , great! The CLI is installed and ready to go.

Authenticating Rover

We need an API key to authenticate ! Since we're starting out working locally, we'll use a personal API key. (There's another type of API key called API keys that are used for CI/CD environments, which we'll take a look at later on!)

  1. In Studio, click on your profile picture on the top right side, then Personal Settings.

  2. Click API Keys.

  3. Click Create new key.

    https://github.com

    Personal API Key generated in Studio

  4. Give it a name, like "Local Dev".

  5. Copy your key—you won't be able to see it again!

  6. In a terminal, run:

    rover config auth

    Then paste in your API key.

  7. To check if it worked, run:

    rover config whoami

    And you should see your profile information displayed. You're all set!

Task!

Key takeaways

  • To create a , you need your API endpoint. This becomes the first of the supergraph.
  • You can change the routing URL of a through the Studio Subgraphs page.
  • When working on your local development machine, you can authenticate using a personal API key.

Up next

We're all set up with our , , and the , whew! All the pieces we need. This is great, and everything works fine, but we're here to learn what to do to make changes to our supergraph safely and confidently. Let's dive in.

Previous

Share your questions and comments about this lesson

This course is currently in

beta
. 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.