5. Exercise: Develop with the Apollo Router
10m

TODO: Provide a bit more guidance on what they're supposed to do and what they

Exercise: Develop with the Apollo Router

🎯 Goal: Get to know how to develop with the Apollo to integrate with your platform APIs

For this exercise, we're going to see how we can develop with the Apollo and begin to configure it for our platform APIs.

Prerequisites

You will need to download the Apollo Router and rover CLI.

Connecting the Apollo Router to GraphOS locally

The Apollo is a binary that we can run locally and connect to the in . Let's first get familiar with running the router binary locally with GraphOS. After downloading the router, simply running ./router --help prints out the help. If the APOLLO_KEY and APOLLO_GRAPH_REF environment variables are set, the will automatically configure with for things like usage reporting and .

The also has a development mode that enables

Running router binary locally in dev mode

Using rover for easy-mode

Sometimes you need to test out a new thing with your existing and the rover cli makes that easy. It automatically configures the in development mode and let's you configure whatever you need.

Using rover

Configuring the Apollo Router

One of the most common configurations for the is safelisting - docs - and it's something we recommend incorporating into your security strategy. The concept requires that consumers of your APIs pre-register the they want to run in production.

You'll need to create a router.yaml file in the same directory as the binary and add the configuration for safelisting Hint, you can check the previous docs link for the configuration or see an example configuration:

persisted_queries:
enabled: true
log_unknown: true
safelist:
enabled: true
require_id: false
apq:
enabled: false # APQ must be turned off
Configuration

Solutions

Make sure to keep your running at the end of the exercise! We'll use it for a quick demonstration.

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.