Apollo Federation JVM example implementation using Spring GraphQL. If you want to discuss the project or just say hi, stop by the Apollo community forums.
The repository contains two separate projects:
products-subgraph
: A Java GraphQL service providing the federatedProduct
typereviews-subgraph
: A Java GraphQL service that extends theProduct
type withreviews
See individual projects READMEs for detailed instructions on how to run them.
-
Start
products-subgraph
by running the Spring Boot app from the IDE or by running./gradlew bootRun
fromproducts-subgraph
project -
Start
reviews-subgraph
by running the Spring Boot app from the IDE or./gradlew bootRun
fromreviews-subgraph
project -
Start Federated Router
- Install rover CLI
- Start router and compose products schema using rover dev command
# start up router and compose products schema rover dev --name products --schema ./products-subgraph/src/main/resources/graphql/schema.graphqls --url http://localhost:8080/graphql
- In another shell run
rover dev
to compose reviews schema
rover dev --name reviews --schema ./reviews-subgraph/src/main/resources/graphql/schema.graphqls --url http://localhost:8081/graphql
-
Open http://localhost:3000 for the query editor
Example federated query
query ExampleQuery {
products {
id
name
description
reviews {
id
text
starRating
}
}
}