This repository reimplements Apollo's federation-demo using Scala and Caliban.
Service | Api | Server |
---|---|---|
Accounts | AccountsApi | AccountsServer |
Reviews | ReviewsApi | ReviewsServer |
Products | ProductsApi | ProductsServer |
Inventory | InventoryApi | InventoryServer |
- sbt > 1.x
- recent version of npm and node
- Run all servers by starting the sbt shell:
> sbt
- Inside the sbt shell, run:
... [info] started sbt server sbt:federation-demo-caliban> run AllServers
- In the repository root, run
> npm install
- Then run
> npm run start-gateway
- Navigate to http://localhost:4000 in your preferred browser.
- To observe traces with OpenTelemetry, run Jaeger with:
Then navigate to http://localhost:16686/. Run queries and observe the traces being logged.
docker run -d --name jaeger \ -e COLLECTOR_ZIPKIN_HOST_PORT=:9411 \ -p 5775:5775/udp \ -p 6831:6831/udp \ -p 6832:6832/udp \ -p 5778:5778 \ -p 16686:16686 \ -p 14250:14250 \ -p 14268:14268 \ -p 14269:14269 \ -p 9411:9411 \ jaegertracing/all-in-one:1.29
- Close both gateway and services by hitting
Ctrl-C
.
query ExampleQuery {
me {
id
name
username
reviews {
body
product {
name
}
}
}
topProducts(first: 3) {
upc
name
price
weight
inStock
shippingEstimate
reviews {
body
author {
name
username
}
}
}
}
- AccountsServer uses Play to serve GraphQL Playground and run the GQL interpreter. The other servers use Akka HTTP directly.