rover dev
rover dev
do? (Select all that apply)rover dev
need to run? (Select all that apply)Follow-along: Setting up rover dev
Exploring files
Open up the workshop project repo. Subgraphs are split up into two folders:
subgraph-listings
andsubgraph-reviews
.Open up the config file for the router:
router-config.yaml
router-config.yamlsupergraph:listen: 127.0.0.1:4000include_subgraph_errors:all: truetelemetry:instrumentation:spans:mode: spec_compliantOpen up the config file for the supergraph:
supergraph.yaml
supergraph.yamlfederation_version: =2.7.0subgraphs:listings:routing_url: http://localhost:4001/schema:file: ./subgraph-listings/listings.graphqlreviews:routing_url: http://localhost:4002/schema:file: ./subgraph-reviews/reviews.graphql
Run rover dev
First, we'll get our subgraph servers running. Then, we'll run rover dev
. We'll have three terminal windows: one for each subgraph server process, and another for the rover dev process.
We recommend renaming each terminal window to better represent what process it's running.
Terminal window #1: subgraph-listings
In terminal window #1, navigate to the
subgraph-listings
directory.If you haven't already, install dependencies.
npm installRun
npm run dev
. It will reload the server every time we save our changes.npm run dev
Terminal window #2: subgraph-reviews
In terminal window #2, navigate to the
subgraph-reviews
directory.If you haven't already, install dependencies with
npm install
.npm installRun
npm run dev
. It will reload the server every time we save our changes.npm run dev
Terminal window #3: rover dev
In terminal window #3, navigate to the root of your project repo.
Run the command below to start up
rover dev
:rover dev --supergraph-config supergraph.yaml --router-config router-config.yamlWe'll see some output in the terminal, with a successful message and the endpoint to get to our router in http://localhost:4000.
supergraph config loaded successfully==> Watching router-config.yaml for changeswarning: 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 changesstarting a session with the 'reviews' subgraphcomposing supergraph with Federation v2.7.0==> your supergraph is running! head to http://localhost:4000 to query your supergraphsuccessfully composed after adding the 'reviews' subgraph==> Watching ./subgraph-reviews/reviews.graphql for changes
Sending a query with Apollo Sandbox
Apollo Sandbox lets us interact with our GraphQL API. With Explorer, we can build queries easily and send them to our GraphQL API.
Open up http://localhost:4000 where the router is running.
Run the example query pre-filled in the Explorer. Examine the response of IDs.
query ExampleQuery {featuredListings {id}recentReviews {id}}Build a query with more fields by clicking on the + button beside each field. Run the query.
query ExampleQuery {featuredListings {idtitledescriptioncostPerNight}recentReviews {idtextrating}}Examine the response in table view.
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.