Apollo Federation JVM example implementation using Spring for 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 federatedProducttypereviews-subgraph: A Java GraphQL service that extends theProducttype withreviews
See individual projects READMEs for detailed instructions on how to run them.
-
Start
products-subgraphby running theProductsApplicationSpring Boot app from the IDE or by running./gradlew :products-subgraph:bootRunfrom the root project directory -
Start
reviews-subgraphby running theReviewsApplicationSpring Boot app from the IDE or./gradlew :reviews-subgraph:bootRunfrom the root project directory -
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 devto 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
}
}
}