Menu

GraphQL Federation with Java subgraphs, without the N+1
📰

GraphQL Federation with Java subgraphs, without the N+1

DEV Community: microservices·Ayush Soni·10 days ago
#Xf5ryF1D
Reading 0:00
15s threshold

When I worked on GraphQL APIs that sat in front of several backend services, the hard part was never the query language. It was the joins: one screen needs a product from one service, its reviews from another and each reviewer's name from a third. Do that in a single GraphQL server and you get a "god schema" that every team must change. Do it naively across services and you get a storm of small requests.

Apollo Federation is one answer: each team owns a subgraph for its own types, and a router composes them into one supergraph . I built graphql-federation-playground to understand the patterns you hit in production, with Java subgraphs instead of the usual Node examples.

The setup

Service Port Owns Extends

user-subgraph 8081 User —

product-subgraph 8082 Product User with products

review-subgraph 8083 Review Product with reviews , averageRating , reviewCount ; User with reviews

Apollo Router 4000 the supergraph —

Each subgraph is a Spring Boot 3 app using the Netflix DGS framework .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.