4. Follow-along: rover dev
1m

rover dev

Which of the following does rover dev do? (Select all that apply)
Which of the following information about a subgraph does rover dev need to run? (Select all that apply)

Follow-along: Setting up rover dev

Exploring files

  1. Open up the workshop project repo. are split up into two folders: subgraph-listings and subgraph-reviews.

  2. Open up the config file for the : router-config.yaml

    router-config.yaml
    supergraph:
    listen: 127.0.0.1:4000
    include_subgraph_errors:
    all: true
    telemetry:
    instrumentation:
    spans:
    mode: spec_compliant
  3. Open up the config file for the : supergraph.yaml

    supergraph.yaml
    federation_version: =2.7.0
    subgraphs:
    listings:
    routing_url: http://localhost:4001/
    schema:
    file: ./subgraph-listings/listings.graphql
    reviews:
    routing_url: http://localhost:4002/
    schema:
    file: ./subgraph-reviews/reviews.graphql

Run rover dev

First, we'll get our running. Then, we'll run rover dev. We'll have three terminal windows: one for each process, and another for the dev process.

We recommend renaming each terminal window to better represent what process it's running.

Terminal window #1: subgraph-listings

  1. In terminal window #1, navigate to the subgraph-listings directory.

  2. If you haven't already, install dependencies.

    npm install
  3. Run npm run dev. It will reload the server every time we save our changes.

    npm run dev

Terminal window #2: subgraph-reviews

  1. In terminal window #2, navigate to the subgraph-reviews directory.

  2. If you haven't already, install dependencies with npm install.

    npm install
  3. Run npm run dev. It will reload the server every time we save our changes.

    npm run dev

Terminal window #3: rover dev

  1. In terminal window #3, navigate to the root of your project repo.

  2. Run the command below to start up rover dev:

    rover dev --supergraph-config supergraph.yaml --router-config router-config.yaml
  3. We'll see some output in the terminal, with a successful message and the endpoint to get to our in http://localhost:4000.

    supergraph config loaded successfully
    ==> Watching router-config.yaml for changes
    warning: Do not run this command in production! It is intended for local development only.
    starting a session with the 'listings' subgraph
    ==> Watching ./subgraph-listings/listings.graphql for changes
    starting a session with the 'reviews' subgraph
    composing supergraph with Federation v2.7.0
    ==> your supergraph is running! head to http://localhost:4000 to query your supergraph
    successfully composed after adding the 'reviews' subgraph
    ==> Watching ./subgraph-reviews/reviews.graphql for changes

Sending a query with Apollo Sandbox

lets us interact with our API. With Explorer, we can build queries easily and send them to our GraphQL API.

  1. Open up http://localhost:4000 where the is running.

  2. Run the example pre-filled in the Explorer. Examine the response of IDs.

    query ExampleQuery {
    featuredListings {
    id
    }
    recentReviews {
    id
    }
    }
  3. Build a with more by clicking on the + button beside each field. Run the query.

    query ExampleQuery {
    featuredListings {
    id
    title
    description
    costPerNight
    }
    recentReviews {
    id
    text
    rating
    }
    }
  4. Examine the response in table view.

Task!
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.