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

练习Exercises

筛出 50 个练习(共 148 个) · 第 4 / 5 页。Showing 50 of 148 · page 4 / 5.
来自From TODO 2 · Order.shippingInfoTODO 2 · Order.shippingInfo · Federation 考试Federation exam
L1认出来Spot it为什么不能直接调数据源Why you cannot just call the data source

dataSources.shippingDataSource.getShippingInfo(parent.id) 能让两条测试都通过。为什么还是错的?

dataSources.shippingDataSource.getShippingInfo(parent.id) makes both tests pass. So why is it still wrong?

先选一个选项Pick an option first
来自From 先看懂给你的东西:Spring 的几个注解和一条请求链路Understand what you are given: a few Spring annotations and the path one request takes · Federation 考试Federation exam
L1认出来Spot it找不到订单时该怎么处理What to do when the order is not found

getOrderById 端点里,orderService.getOrderById(id) 找不到时会抛EntityNotFoundException。 控制器应该怎么写?

In the getOrderById endpoint, orderService.getOrderById(id) throws EntityNotFoundException when it finds nothing. How should the controller be written?

先选一个选项Pick an option first
来自From 先看懂给你的东西:Spring 的几个注解和一条请求链路Understand what you are given: a few Spring annotations and the path one request takes · Federation 考试Federation exam
L1认出来Spot it这三个参数注解各从哪取值Where each of these parameter annotations reads from

请求是 PATCH /api/orders/7/status, body 是 {"status":"SHIPPED"}
方法签名是 updateOrderStatus(@PathVariable Long id, @RequestBody Map<String,String> statusUpdate)idstatusUpdate 分别是什么?

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?

先选一个选项Pick an option first
来自From 六个端点:状态码就是这道题的全部Six endpoints: the status codes are the whole task · Federation 考试Federation exam
L1认出来Spot itPOST 创建成功该返回什么What a successful POST should return

POST /api/orders 成功创建了一个订单。 该返回哪个状态码,怎么写?

POST /api/orders created an order successfully. Which status code should it return, and how do you write that?

先选一个选项Pick an option first
来自From 六个端点:状态码就是这道题的全部Six endpoints: the status codes are the whole task · Federation 考试Federation exam
L1认出来Spot it为什么 return null 能骗过三个测试Why return null fools three of the tests

baseline 状态下六个端点全是 return null, 五个测试却通过了三个。为什么?

At the baseline all six endpoints are just return null, yet three of the five tests pass. Why?

先选一个选项Pick an option first
来自From 两道书面题:延迟传播与生产配置The two written questions: how delay spreads, and production configuration · Federation 考试Federation exam
L1认出来Spot it哪一行是最严重的安全问题Which line is the most serious security problem

题面给的六行配置里,哪一行能直接导致数据库口令泄漏?

Of the six configuration lines in the question, which one can directly leak the database password?

Properties源项目From source
1server.port=8080
2server.address=0.0.0.0
3spring.datasource.url=jdbc:postgresql://${DB_HOST}:5432/orders
4spring.datasource.username=${DB_USER}
5spring.datasource.password=${DB_PASSWORD}
6management.endpoints.web.exposure.include=*
Source: graphql-federation-practice/QUESTIONS.md
先选一个选项Pick an option first
来自From 两道书面题:延迟传播与生产配置The two written questions: how delay spreads, and production configuration · Federation 考试Federation exam
L1认出来Spot it为什么 User subgraph 慢会拖慢 Orders subgraphWhy a slow User subgraph slows the Orders subgraph down

客户端查 { 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?

先选一个选项Pick an option first
来自From 16 道题逐题对照The 16 problems, compared one by one · 面试八股Interview questions
L1认出来Spot it认出考点:这道题在考什么Name the point: what is this question testingDrillLab 自出Written by DrillLab

面试官出题:「实现一个 Kanban 看板,卡片可以在三列之间移动。」 这道题最核心的考点是哪一个?

The interviewer says: “Build a Kanban board where a card can move between three columns.” Which is the central point this question tests?

先选一个选项Pick an option first
来自From Utility Types:会用,还要会手写Utility types: use them, and write them yourself · 面试八股Interview questions
L1认出来Spot it认出这个 mapped type 在干什么Work out what this mapped type doesDrillLab 自出Written by DrillLab

面试官给出下面这个类型,问它对 T 做了什么。

An interviewer shows you the type below and asks what it does to T.

TypeScriptMystery.ts示意Illustrative
1type Mystery<T> = {
2 [K in keyof T]-?: T[K];
3};
先选一个选项Pick an option first
来自From 泛型与收窄:把 any 赶出代码Generics and narrowing: getting any out of the code · 面试八股Interview questions
L1认出来Spot itunknown 参数该怎么用起来How to actually use an unknown parameterDrillLab 自出Written by DrillLab

这个函数编译不过:'e' is of type 'unknown'.下面哪种改法是对的?

This function does not compile: 'e' is of type 'unknown'. Which fix is the right one?

TypeScriptreport.ts示意Illustrative
1function report(e: unknown) {
2 console.log(e.message);
3 // ^ ✗ 'e' is of type 'unknown'.
4}
先选一个选项Pick an option first
来自From 先读四个测试:它们到底要什么Read the four tests first: what exactly they ask for · Cab BookingCab Booking
L1认出来Spot it哪个断言决定了「分组顺序」不能自己定?Which assertion makes the group order fixed?
测试 2 里有一行让「Sedan / SUV / Luxury 的顺序」变成硬要求。是哪一行?One line in test 2 turns the order of Sedan / SUV / Luxury into a hard requirement. Which line?
先选一个选项Pick an option first
来自From 按类型分组渲染六张卡Rendering the six cards grouped by type · Cab BookingCab Booking
L1认出来Spot it哪个 key 在历史列表里会出问题?Which key goes wrong in the history list?
用户连订了两次同一辆 Ford Fusion(id: 1)。 历史列表用下面哪个 key 会报「重复 key」警告?The user books the same Ford Fusion (id: 1) twice in a row. Which of these keys makes the history list warn about duplicate keys?
先选一个选项Pick an option first