DrillLab
练习Practice

动手做Get your hands on it

练习跟着课文走 —— 每节课尾都有本课的练习。这一页是全部练习的总库,想集中刷题的时候来。 每个练习都写清了它来自哪一节,卡住了就回去看那一节。Practice follows the lessons — every lesson ends with the exercises for that lesson. This page is the whole library, for when you want to drill in one sitting. Each exercise names the lesson it came from, so you can go back when you stall.

0 / 148个做对过you got right
筛一下Filter theseFederation 考试Federation exam排顺序Order it
难度LevelL1 → L4 和上面四档同一个意思:给你的东西越来越少L1 → L4: the same idea as the four tiers above — less is handed to you全部难度All levelsL1L1L2L2L3L3L4L4

已筛到你正在学的《Federation 考试》。想看全部就点上面的「全部」。Filtered to Federation exam — the course you are on. Use “All” above to see everything.

练习Exercises

筛出 2 个练习(共 148 个)。Showing 2 of 148.
来自From resolver 的四个参数The four arguments of a resolver · Federation 考试Federation exam
L1排顺序Order it把 resolver 的调用顺序排对Put the resolver calls in the right order

客户端发 { orders(userId:"123") { id shippingInfo { status } } }, 数据源里 user 123 有两个订单。把服务端的动作排序。

The client sends { orders(userId:"123") { id shippingInfo { status } } }, and in the data source user 123 has two orders. Put the server's steps in order.

1对每个 order 分别调 Order.shippingInfo(共 2 次)Call Order.shippingInfo once per order (2 calls in total)
2用 schema 校验查询:字段存不存在、userId 类型对不对Validate the query against the schema: do the fields exist, is the type of userId right
3DataLoader 把 2 次 load 合并成 1 次批量请求DataLoader merges the 2 load calls into 1 batched request
4调 Query.orders,拿到 [order-456, order-457]Call Query.orders and get back [order-456, order-457]
5按查询形状组装 JSON 返回Assemble the JSON response in the shape of the query
来自From 先读题:四个 TODO、三处埋雷、十个测试Read the task first: four TODOs, three planted bugs, ten tests · Federation 考试Federation exam
L1排顺序Order it把 Task 1 的推进顺序排对Put the steps of Task 1 in the right order

拿到 node-subgraph,最合理的动作顺序?

You have just opened node-subgraph. What is the most sensible order to work in?

1逐个实现四个 TODOImplement the four TODOs one by one
2读 schema.graphql,记下四个返回类型的可空性Read schema.graphql and note the nullability of the four return types
3npm install,然后 npm test 拿到 6 failed / 4 passed 的基线npm install, then npm test to get the 6 failed / 4 passed baseline
4npm test 转绿,再写个 verify 脚本查 _service 和 _entitiesOnce npm test is green, write a verify script that checks _service and _entities
5读 index.js 和 dataSources,抄下 context 键名与方法名Read index.js and the dataSources, and copy out the context keys and method names
6修三处埋雷Fix the three planted bugs