GraphQL with Spring Boot: What the Server Pays

26 September 2026 graphqlspring-bootjavan-plus-oneapi-design
PDF The design sheet The full architecture and the verified references. Free, no email.
Thumbnail for GraphQL with Spring Boot: What the Server Pays 27:08
Watch on YouTube, or read on below.
Run this yourself → Clone the repo, docker compose up, and watch it happen

Twenty one REST calls became one GraphQL request. Same screen, one round trip. Then I counted the database queries behind that one request: eighty.

The client’s simplicity was real. So was the server’s work. Everything below was run on 26 September 2026 on Spring Boot 4.1.1, Spring for GraphQL 2.0.5 and Postgres 17, and every result is reproduced by one script in the repository.

What was measured

QuestionResult
The order list screenREST 21 requests and 2,410 bytes; GraphQL 1 request and 1,608 bytes
Nested fields with @SchemaMapping20 customer, 20 order line and 40 product selects for one request
The same request with @BatchMapping1, 1 and 1
An exception nobody mapsINTERNAL_ERROR, message hidden; an exception resolver makes it NOT_FOUND
The same broken query, two response types200 under application/json, 400 under application/graphql-response+json
@PreAuthorize on one fieldanonymous UNAUTHORIZED, clerk FORBIDDEN, admin sees it, the name always arrives
60 aliases at depth twoa depth limit let them through and 60 selects ran; a complexity limit rejected them at 120 over 100
A schema field nobody resolvesnull with no error; the startup schema inspection report names it
A deprecated field, then removedstill answers; then a 400 validation error

From Spring MVC, annotation by annotation

JobSpring MVCSpring for GraphQL
Read@GetMapping on a URL@QueryMapping on a field
Write@PostMapping@MutationMapping
Streamserver sent events or WebSocket by hand@SubscriptionMapping returning a Flux
A nested fieldanother endpoint@SchemaMapping, or @BatchMapping for one query per field
Map an exception@ExceptionHandlera DataFetcherExceptionResolver

The full code, the interview questions and a production checklist are in the free design sheet above.


Watch next

New videos land on Code with Sam - subscribe there if this was useful.

Get the interview pack

A free, practical pack for engineers preparing for senior backend interviews - the questions that actually get asked, and how to answer them like someone who has done the work.

New articles and videos when they land. No spam, and one click to leave.