2. Project setup
4m

Overview

Let's prepare our dev environment and get to know the project we're building.

We'll need a few things to get started. In this lesson, we will:

  • Verify our account
  • Set up our local code environment
  • Run rover dev with credentials

1) Verify your Apollo GraphOS account

To use connectors, you'll need an account.

Don't have an account yet? Create one now and you're all set! Jump to the next step.

If you already have an existing account within an organization with an Enterprise plan, you must have the role of Graph Admin to be able to create and retrieve graph credentials in Step 3.

Task!

2) Set up your local code environment

Next up, let's clone our starter project, and open it up in our code editor.

git clone https://github.com/apollographql-education/odyssey-connectors-rest-intro

Don't have git installed? Check out the instructions to install it. Alternatively, you can download the ZIP file locally by clicking "Code" and selecting "Download ZIP".

Your project directory will look something like this:

📂 odyssey-connectors-intro-rest
┣ 📂 .vscode
┣ 📄 .gitignore
┣ 📄 apollo.config.yaml
┣ 📄 listings.graphql
┣ 📄 router-config.yaml
┣ 📄 rover-dev.md
┗ 📄 supergraph.yaml
Task!

2b) Install the Apollo VS Code Extension

We recommend using VS Code for this project so we can use the Apollo VS Code extension. It brings many helpful features for working on a project, such as autocompletion, schema information, syntax highlighting and much more!

Alternatively, if you use an IntelliJ-based IDE, you can install our JetBrains plugin. Check out the documentation for IDE Support for more information.

Note: You can still follow along with the course with any code editor, you just won't see tips and in-development errors while you code.

We've already got a few files to start off with: config files as well as a minimal in the listings.graphql file. We'll build onto this throughout the course.

3) Run rover dev with graph credentials

The includes a command called rover dev that will spin up our API, specifically a we can work with locally. We'll learn more about what the router does later on. But to enable connectors, first needs a 's credentials.

  1. Let's head over to in the browser.

  2. If you have a brand new organization, you'll see two choices to start. Select Connect a REST API.

    studio.apollographql.com

    Connect REST API

    If you already have existing , click the arrow beside Create New Graph, then select Create a new connectors supergraph.

    studio.apollographql.com

    Create button

  3. We'll give our a name, keep the defaults, then hit Create and continue.

    studio.apollographql.com

    Setup graph modal

  4. This next page outlines how to set up our local development environment using an example . It's great for getting started quickly, but we've already got our starter code, so we won't need to do all the steps in this process!

    studio.apollographql.com

    Setup graph modal

  5. First, we'll install the latest version of the . Find the command in the installation instructions that fits with your 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

    Note: You can find other installation methods in the Apollo documentation.

  6. If you've already installed before, you'll get a message asking if you'd like to overwrite the existing installation. Type y and hit enter to continue.

  7. Verify that the installation completed successfully:

    rover --version

    To work with connectors, your version should be at least on v0.27.0.

    Task!
  8. On to the next step! We're already starting with a supergraph.yaml file in our project repo, and a schema, so that's the next two steps done.

  9. Scrolling down to the next step, we've got the credentials. Let's copy and paste over the values for APOLLO_KEY and APOLLO_GRAPH_REF into our rover-dev.md file in the code editor, choosing the one that fits your local environment.

    studio.apollographql.com

    Setup graph modal

    Make sure you hit the icon to reveal masked values so that the unmasked value for APOLLO_KEY is copied over.

    studio.apollographql.com

    Setup graph modal

    rover-dev.md
    # sh
    APOLLO_KEY="..." \
    APOLLO_GRAPH_REF="..." \
    APOLLO_ROVER_DEV_ROUTER_VERSION=2.0.0 \
    rover dev --supergraph-config supergraph.yaml --router-config router-config.yaml
    # Powershell
    $env:APOLLO_KEY="..."
    $env:APOLLO_GRAPH_REF="..."
    $env:APOLLO_ROVER_DEV_ROUTER_VERSION="2.0.0"
    rover dev --supergraph-config supergraph.yaml --router-config router-config.yaml

    This rover dev command takes in our credentials and two configuration files (supergraph.yaml and router-config.yaml). You can take a look at them if you're curious.

  10. Copy the command and run it in the terminal.

    We've got a few lines of output and a message that the has started up at port 4000.

  11. We can head over to http://localhost:4000 in the browser , where we've got another handy tool ready for us: Apollo Sandbox, a local playground that lets us explore our API.

    With its Explorer, we can build easily, send requests and debug our connector calls.

Task!

What we're building

That's our setup, but what exactly are we building? Let's meet our course project: Airlock.

Airlock is an intergalactic travel booking app, where we can find a cool place to stay in the wide open universe! You can find the demo project here: https://odyssey-airlock.netlify.app/

https://odyssey-airlock.netlify.app/

Mockup of Airlock

We'll be building the API for Airlock and we've got big plans, but right now, we'll start small.

We have a simple REST API with a few endpoints that let us explore the listings for our travels, giving us detailed information about places we could stay at, their amenities, how many beds and the cost.

You can find the REST API here: https://airlock-listings.demo-api.apollo.dev/

We'll use a few pages of Airlock mockups to guide us; we'll determine what pieces of data from which endpoints of the REST API we'd need to orchestrate.

Key takeaways

  • To get started with , you need an Apollo account.
  • To start up a local for our API, we'll need to provide with our credentials.

Up next

We're all set up, so let's dive into how we use connectors in the schema.

Previous

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.