DrillLab
后端 · 考试Course

GraphQL Federation CapstoneGraphQL Federation Capstone

对应 graphql-federation-practice 这个真实项目:一个 Apollo Federation subgraph(Node.js)加一个 Spring Boot REST 微服务,再加两道书面题。从「GraphQL 是什么」讲到能在空目录里重建整个 subgraph。Built on the real project graphql-federation-practice: one Apollo Federation subgraph (Node.js), one Spring Boot REST microservice, and two written questions. It starts at what GraphQL is and ends with rebuilding the whole subgraph in an empty directory.

Apollo Server 4@apollo/subgraph 2.7GraphQL 16DataLoaderNode ESM + JestJava 17Spring Boot 3.3Maven
这门考试到底考什么What this exam actually tests

Task 1 考 GraphQL 与 Federation 的基本功:schema 的可空性怎么决定 resolver 的兜底、parent 从哪来、entity 与 @key、DataLoader 防 N+1、结构化错误与 correlation id。Task 2 考 REST 语义:状态码选对没有、异常该谁处理。两道书面题考的是「有没有在真实系统里想过延迟传播和生产配置」。贯穿全题的隐性考点是「能不能核对而不是猜」—— starter 里有三处人为埋雷。Task 1 covers the basics of GraphQL and Federation: how a nullable field in the schema decides what the resolver returns as a fallback, where parent comes from, entity and @key, using DataLoader to avoid N+1, and structured errors with a correlation id. Task 2 covers what the REST rules require: whether the status codes are right, and who should handle the exceptions. The two written questions ask whether you have thought about how delay spreads and how a service is configured in production. One point runs through the whole exam: can you check instead of guess — the starter has three bugs planted on purpose.

内容来源 · 你本机上的真实项目Where the content comes from · the real project on your machine
源项目Source project1 项 · 1 个可以展开看原文1 items · 1 can be opened
graphql-federation-practice参考项目。本机实测基线:subgraph 6 failed / 4 passed,Java 5 run / 2 failuresReference project. Measured baseline: subgraph 6 failed / 4 passed, Java 5 run / 2 failures
Textgraphql-federation-practice/ · tree源项目From source
1graphql-federation-practice/
2├── java-service/
3│ ├── src/
4│ │ ├── main/
5│ │ │ ├── java/
6│ │ │ │ └── com/
7│ │ │ │ └── techflow/
8│ │ │ │ └── orders/
9│ │ │ │ ├── config/
10│ │ │ │ │ ├── CorrelationIdFilter.java
11│ │ │ │ │ └── MetricsConfig.java
12│ │ │ │ ├── controller/
13│ │ │ │ │ └── OrderController.java
14│ │ │ │ ├── dto/
15│ │ │ │ │ ├── CreateOrderRequest.java
16│ │ │ │ │ └── OrderItemRequest.java
17│ │ │ │ ├── exception/
18│ │ │ │ │ ├── EntityNotFoundException.java
19│ │ │ │ │ └── GlobalExceptionHandler.java
20│ │ │ │ ├── model/
21│ │ │ │ │ ├── Order.java
22│ │ │ │ │ ├── OrderItem.java
23│ │ │ │ │ └── OrderStatus.java
24│ │ │ │ ├── repository/
25│ │ │ │ │ ├── InMemoryOrderRepository.java
26│ │ │ │ │ └── OrderRepository.java
27│ │ │ │ ├── service/
28│ │ │ │ │ └── OrderService.java
29│ │ │ │ └── OrderServiceApplication.java
30│ │ │ └── resources/
31│ │ │ └── application.properties
32│ │ └── test/
33│ │ └── java/
34│ │ └── com/
35│ │ └── techflow/
36│ │ └── orders/
37│ │ └── OrderControllerTest.java
38│ ├── orders.db
39│ └── pom.xml
40├── node-subgraph/
41│ ├── __tests__/
42│ │ └── resolvers.test.js
43│ ├── src/
44│ │ ├── dataSources/
45│ │ │ └── orderDataSource.js
46│ │ ├── resolvers/
47│ │ │ └── orderResolvers.js
48│ │ ├── index.js
49│ │ └── schema.graphql
50│ ├── package-lock.json
51│ └── package.json
52├── QUESTIONS.md
53└── README.md
Source: graphql-federation-practice
先修Prerequisite

建议先过一遍Work through 地基 · 项目与语言。如果你已经会 npm、会读 package.json,可以直接开始这一门。 first. If you already know npm and can read a package.json, start here directly.

真实任务覆盖清单Coverage of the real tasks
真实项目里的任务Task in the real projectDrillLab 讲到哪Where DrillLab covers it有测试Tested
Task 1 · User.orders完整讲解 + entity 数据流图 + 填空 + L3 自写 + 从零重写Yes
Task 1 · Order.shippingInfo(要求用 DataLoader)N+1 与 DataLoader 专章 + 填空 + Debug LabYes
Task 1 · Query.orders与 Query.order 对比讲解 + 填空 + L3 自写Yes
Task 1 · Query.order(README 没提、也没有测试)专门指出并完整实现,用上了给好的 ORDER_NOT_FOUNDNo
埋雷 1 · createOrderLoader 调了不存在的 getOrderByIdDataLoader 那节点出 + 独立 Debug LabYes
埋雷 2 · createOrder 用了不存在的 orderAPI、签名错、缺 price埋雷专章逐条拆解 + Debug LabYes
埋雷 3 · catch 把 INVALID_INPUT 吞成 SERVICE_ERROR贯穿四个 resolver 的模式讲解 + 独立 Debug LabYes
Task 2 · 六个 Spring 端点(含 201 / 204 / 400 / 404)Spring 基础 + 逐端点讲解 + 填空 + L3 自写 + 从零重写Yes
Task 2 · 六个端点全 return null 也能过 3/5 测试实测数据 + 手动 curl 自检清单 + Debug LabYes
书面题 1 · User subgraph 高延迟的影响与缓存策略传导路径分析 + 完整参考答案 + 答题结构模板No
书面题 2 · application.properties 的生产隐患六面排查清单 + 六个问题的完整参考答案 + L3 练习No
课程Lessons
Federation · 第 1 部分Federation · Part 1
3 节3 lessons
GraphQL 基础GraphQL basics

schema、type、field、query、resolver、非空与列表。全部用 node-subgraph 的真实 schema.graphql 当例子 —— 这份 schema 的每个细节后面都会变成考点。schema, type, field, query, resolver, non-null and lists. Every example is the real schema.graphql from node-subgraph, and every detail in that schema turns into an exam point later.

Federation · 第 2 部分Federation · Part 2
4 节4 lessons
Federation 心智模型A mental model for Federation

为什么要拆、subgraph 是什么、entity 和 @key 在解决什么问题、Router 怎么把碎片缝起来、DataLoader 为什么必须出现。Why one schema gets split up, what a subgraph is, what problem entity and @key solve, how the Router joins the pieces back into a single schema, and why DataLoader is needed.

Federation · 第 3 部分Federation · Part 3
5 节5 lessons
Task 1 · subgraph resolver 逐项拆解Task 1 · the subgraph resolvers, one at a time

四个 TODO 加三处埋雷。每个 TODO 都走同一套流程:读题 → 考什么 → 先想再写 → 分步实现 → 完整答案 → 为什么成立 → 常见错法 → 迁移。Four TODOs plus three planted bugs. Every TODO follows the same steps: read the task, see what it tests, think before writing, build it step by step, read the full answer, understand why it works, look at the common mistakes, then reuse the pattern elsewhere.

Federation · 第 4 部分Federation · Part 4
2 节2 lessons
Task 2 · Spring Boot REST 控制器Task 2 · the Spring Boot REST controller

六个端点,业务逻辑全都给好了。真正考的是「HTTP 状态码选对了吗」和「异常该谁处理」—— 而这两点恰好是那五个测试只抓住一半的地方。Six endpoints, with all the business logic already written for you. What is really tested is whether you picked the right HTTP status code and who should handle the exceptions — and those are exactly the two things the five tests only check partly.

Federation · 第 5 部分Federation · Part 5
1 节1 lessons
书面题The written questions

QUESTIONS.md 里的两道题。它们不考代码,考的是「你有没有在真实系统里想过这些问题」。这一节给出思考框架和一份可以照着写的参考答案。The two questions in QUESTIONS.md. They do not test code. They test whether you have thought about these problems in a real system. This module gives a structure for thinking them through, plus one reference answer you can follow.

Federation · 第 6 部分Federation · Part 6
2 节2 lessons
综合 Debug 与从零重写Mixed debugging, and rewriting from an empty directory

把 GraphQL 和 Spring 两边的典型故障集中练一遍,然后在没有答案的情况下从空目录重建整个 subgraph 和整个控制器。Practice the common failures on both the GraphQL side and the Spring side in one place, then rebuild the whole subgraph and the whole controller from an empty directory, with no answer to look at.

模拟考 · 换了场景,考点一致Mock exams · different scenario, same skills
M
模拟考 B · Book Reviews Subgraph

图书评论 subgraph。它既不拥有 Author 也不拥有 Book —— 两者都由 Catalog subgraph 提供,本服务只往它们身上挂 reviews 和 averageRating。Book 用的是复合 key(isbn + edition),这是真实项目里很常见、但比单字段 key 更容易写错的情况。

DrillLab 自出Written by DrillLab建议 90 分钟~90 min6 个任务6 tasks
未开始Not started