GraphQL Federation 考试准备GraphQL Federation Assessment
自己搭一个 Apollo Federation subgraph 并让十个测试全过,再通过一套换了场景的模拟考。Build an Apollo Federation subgraph yourself with all ten tests passing, then pass a mock in a new scenario.
要考 GraphQL Federation:schema、resolver、entity、DataLoader,外加一个 Spring Boot 服务。Facing a Federation assessment: schema, resolvers, entities, DataLoader, plus a Spring Boot service.
这条计划的全程The whole route
前置Prereq
前置:地基Prerequisites: Foundations
你在这You are heresubgraph 是一个 Node 项目:要装依赖、要跑 script、要读 ESM 的报错。这一档就是这些。A subgraph is a Node project: dependencies to install, scripts to run, ESM errors to read. That is what this course covers.
- Node.js、npm、node_modules 和 lockfileNode.js, npm, node_modules and the lockfile
- package.json 逐字段读一遍package.json, field by field
- npm scripts:命令到底跑了什么npm scripts: what the command actually runs
看这一档全部 9 条View all 9 items
- Node.js、npm、node_modules 和 lockfileNode.js, npm, node_modules and the lockfile
- package.json 逐字段读一遍package.json, field by field
- npm scripts:命令到底跑了什么npm scripts: what the command actually runs
- 两个考试项目的目录,逐个说明The directory layout of both exam projects
- 数组与对象:不可变更新三件套Arrays and objects: three ways to update without changing the original
- 异步:Promise、await、all 和 allSettledAsync: Promise, await, all and allSettled
- ESM:import / export 与那些莫名其妙的报错ESM: import / export, and the errors that look strange at first
- 类型、type 与 interfaceTypes, type and interface
- 泛型参数,以及怎么读 tsc 的报错Generic parameters, and how to read a tsc error
学Learn
学:Federation 课文Learn: the Federation lessons
17 节。第 3 部分把 Task 1 的四个 TODO 和三处埋雷逐项拆开,第 4 部分是 Spring 的六个端点。17 lessons. Part 3 takes Task 1's four TODOs and three planted defects apart one by one; Part 4 is the six Spring endpoints.
- GraphQL 是什么:一份 schema 加一堆 resolverWhat GraphQL is: one schema plus a set of resolvers
- resolver 的四个参数The four arguments of a resolver
- 非空、列表,和那个没有 price 的 inputNon-null, lists, and the input that has no price
- 为什么会有 FederationWhy Federation exists
- subgraph 是怎么跑起来的How a subgraph starts up
- entity、@key 与 __resolveReferenceentity, @key and __resolveReference
- N+1 问题与 DataLoaderThe N+1 problem and DataLoader
- 先读题:四个 TODO、三处埋雷、十个测试Read the task first: four TODOs, three planted bugs, ten tests
- TODO 1 · User.ordersTODO 1 · User.orders
- TODO 2 · Order.shippingInfoTODO 2 · Order.shippingInfo
- TODO 3 & 4 · Query.order 与 Query.ordersTODO 3 & 4 · Query.order and Query.orders
- 三处埋雷:怎么系统地找出来The three planted bugs: how to find them systematically
- 先看懂给你的东西:Spring 的几个注解和一条请求链路Understand what you are given: a few Spring annotations and the path one request takes
- 六个端点:状态码就是这道题的全部Six endpoints: the status codes are the whole task
- 两道书面题:延迟传播与生产配置The two written questions: how delay spreads, and production configuration
- Debug Lab · Federation 十种典型故障Debug Lab · ten common Federation failures
- 从零重写:空目录到 10 个测试全过Rewrite it: from an empty directory to all 10 tests passing
背Review
背:Node、数据库、网络与安全Review: Node, databases, networking and security
题库里没有 GraphQL 这个方向,但这 12 道正好是 subgraph 和 Spring 服务真正会被追问的东西 —— 事件循环、连接、状态码。The bank has no GraphQL track, but these 12 are exactly what a subgraph and a Spring service get asked about: the event loop, connections, status codes.
过过一遍 0 / 12 · 其中标了「会」的 0 道。自评过一次就算过了这一档 —— 不用把每道都标成「会」才往下走。0 / 12 reviewed, 0 of them marked confident. One rating is enough to clear this stage — you do not have to reach confident on every question first.
覆盖方向:Topics covered: Node / ExpressNode / Express数据库Databases网络与安全Web & security
- Node.js 的事件循环是怎么工作的How does the event loop work in Node.js
- 请求 - 响应周期是怎样的Explain the request & response cycle
- 查询参数 vs 路径参数Query parameters vs Path parameters
- 什么是 CRUDWhat is CRUD
- 关系型数据库 vs 非关系型数据库Relational database vs Non-relational database
- 主键 vs 外键Primary key vs Foreign key
- 什么是 CORS,怎么解决 CORS 错误What is CORS and how to solve the CORS error
- HTTPS vs HTTPHTTPS vs HTTP
- 什么是 JWTWhat is JWT
- session vs cookiesessions vs cookies
- 常见的 HTTP 状态码Give some HTTP response status codes
- 测试有哪几种What are the different kinds of tests
练Practice
练:Federation 的课内练习Practice: the Federation exercises
写Code
写:subgraph 与 Spring 控制器Code: the subgraph and the Spring controller
这两道浏览器里跑不了 —— 一道要真起一个服务进程,一道要 JVM 和 Maven。页面给的是本机命令和期望输出,不给假编辑器。Neither runs in a browser: one needs a real server process, the other a JVM and Maven. The pages hand you local commands and the expected output, not a fake editor.
空手做Rebuild
空手做:从零重写两道Rebuild: both tasks from an empty folder
自己写 schema、自己接 DataLoader、自己配 Spring 骨架。基线是 6 failed / 4 passed,而那 4 个通过里有 3 个是「空实现恰好满足断言」。Write the schema yourself, wire DataLoader yourself, set up the Spring skeleton yourself. The baseline is 6 failed / 4 passed, and three of those four passes are empty implementations that happen to satisfy the assertion.
模拟考Assess
模拟考:Book Reviews SubgraphAssess: Book Reviews Subgraph
换了业务场景的 subgraph 加 entity 缝合,考点和 Task 1 一致。参考解法实测 14 / 14。A subgraph stitched with an entity in a different business setting, testing the same things as Task 1. The reference solution measures 14 / 14.
正在读这台浏览器里的进度…Reading your progress from this browser…
计划里每一格的完成状态都是已有进度的一个视图 —— 以前自己刷过的八股、做过的练习一条都不会白做,跟着计划做完的 也照样在 课程 里打勾。 换计划、不跟计划都不动任何记录。Every square here is a view of progress you already have. Questions you rated and exercises you solved before picking a plan all count, and anything you finish inside a plan is still ticked in the courses. Changing plans or stopping never touches a record.