动手做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.
练习Exercises
筛出 56 个练习(共 148 个) · 第 4 / 5 页。Showing 56 of 148 · page 4 / 5.下面哪一条最准确?
Which of these is most accurate?
batch 函数收到 ids = ['a', 'b', 'c'], 其中 b 在数据库里不存在。下面哪种返回是错的?
The batch function receives ids = ['a', 'b', 'c'], and b does not exist in the database. Which of these return values is wrong?
四个 TODO 全都只写了 return [] 或return null,为什么还有 4 个测试通过?
All four TODOs contain nothing but return [] or return null. So why do 4 tests still pass?
createOrderLoader 调了不存在的orderDataSource.getOrderById(id)。 正确的修法是?
createOrderLoader calls orderDataSource.getOrderById(id), which does not exist. What is the right fix?
拿到 node-subgraph,最合理的动作顺序?
You have just opened node-subgraph. What is the most sensible order to work in?
dataSources.shippingDataSource.getShippingInfo(parent.id) 能让两条测试都通过。为什么还是错的?
dataSources.shippingDataSource.getShippingInfo(parent.id) makes both tests pass. So why is it still wrong?
getOrderById 端点里,orderService.getOrderById(id) 找不到时会抛EntityNotFoundException。 控制器应该怎么写?
In the getOrderById endpoint, orderService.getOrderById(id) throws EntityNotFoundException when it finds nothing. How should the controller be written?
请求是 PATCH /api/orders/7/status, body 是 {"status":"SHIPPED"}。
方法签名是 updateOrderStatus(@PathVariable Long id, @RequestBody Map<String,String> statusUpdate)。id 和 statusUpdate 分别是什么?
The request is PATCH /api/orders/7/status with the body {"status":"SHIPPED"}.
The method signature is updateOrderStatus(@PathVariable Long id, @RequestBody Map<String,String> statusUpdate). What are id and statusUpdate?
POST /api/orders 成功创建了一个订单。 该返回哪个状态码,怎么写?
POST /api/orders created an order successfully. Which status code should it return, and how do you write that?
baseline 状态下六个端点全是 return null, 五个测试却通过了三个。为什么?
At the baseline all six endpoints are just return null, yet three of the five tests pass. Why?
题面给的六行配置里,哪一行能直接导致数据库口令泄漏?
Of the six configuration lines in the question, which one can directly leak the database password?
graphql-federation-practice/QUESTIONS.md客户端查 { user(id:"1") { name orders { id } } }。 Accounts subgraph 要 500ms,Orders subgraph 只要 10ms。 总延迟大约是多少,为什么?
A client asks for { user(id:"1") { name orders { id } } }. The Accounts subgraph takes 500ms, the Orders subgraph only 10ms. Roughly what is the total latency, and why?