Mostly borrowed from the excellent Get Started with Apollo Connectors and GraphOS guide at the Apollo GraphQL website. If there's anything wrong in the current repo's documentation, you should DEFINITELY go to the link above and try running this code from scratch.
Rover: Available here. I used the curl installer, so I cannot vouch for other install methods.
- Clone the repo
- Open a terminal
- Run the commands below: replace [API KEY GOES HERE] with the API key I provided via e-mail.
APOLLO_KEY=service:[API KEY GOES HERE] \
APOLLO_GRAPH_REF=Ecomm-Example-39rb5@main \
APOLLO_ROVER_DEV_ROUTER_VERSION=2.0.0 \
rover dev --supergraph-config supergraph.yamlYou should see output that ends with something like this:
==> Attempting to start router at http://localhost:4000.
==> Health check exposed at http://127.0.0.1:8088/health
WARN: Connector debugging is enabled, this may expose sensitive information.
==> Your supergraph is running! head to http://localhost:4000 to query your supergraph
You should be able to open http://localhost:4000 and see the familiar Apollo Sandbox. Try out some queries!
The products subgraph in products.graphql is running queries against https://ecommerce.demo-api.apollo.dev/products. That URL should bring up a products endpoint and serve several product represenations. You can visit https://ecommerce.demo-api.apollo.dev/products/1, as is typical, to see the details of the product with the ID 1.