This is a little demo project to show the GraphQL Federation backend support in SmallRye GraphQL.
-
product
GraphQL backendwar
: serves the name and the description. -
price
GraphQL backendwar
: extends the product by a price. -
order
GraphQL backendwar
: uses products for the order items. -
gateway
GraphQL Federation server: combines the three backends (subgraphs) into One API (supergraph). -
printer
Quarkus GraphQL CLI client: calls the gateway to print an order with all details.
Just run mvn verify
.
But you can deploy the three war
files to any Jakarta EE 10 server with MicroProfile GraphQL support, e.g. WildFly with the GraphQL Feature Pack. We use my WildFly Docker Image rdohna/wildfly:latest
via JEE Testcontainers.
The gateway
uses Wundergraph. To start it, run:
./gateway/router
Then the UI runs on http://localhost:3002 and you can execute, e.g.:
query order1 {
order(id:"1") {
customerNumber
customerName
orderDate
orderItems {
position
amount
product {
name
description
price
}
}
}
}
If you change the schema, you’ll have to regenerate the config.json
. You’ll need wgc
for that:
npm install -g wgc@latest
Then run (while the three services are running):
wgc router compose -i compose.yaml -o config.json