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 个) · 第 3 / 5 页。Showing 50 of 148 · page 3 / 5.
来自From 非空、列表,和那个没有 price 的 inputNon-null, lists, and the input that has no price · Federation 考试Federation exam
L1认出来Spot it这个 resolver 找不到数据时该返回什么What should this resolver return when it finds nothing

schema 写的是 orders(userId: ID!): [Order!]!。 user 999 没有任何订单。resolver 该返回什么?

The schema says orders(userId: ID!): [Order!]!. User 999 has no orders at all. What should the resolver return?

先选一个选项Pick an option first
来自From 非空、列表,和那个没有 price 的 inputNon-null, lists, and the input that has no price · Federation 考试Federation exam
L1认出来Spot itcreateOrder 为什么必须查价格Why createOrder has to look up the price

客户端调 createOrder(userId: "789", items: [{ productId: "prod-789", quantity: 2 }])。 如果 resolver 把 items 原样交给orderDataSource.createOrder,会怎样?

The client calls createOrder(userId: "789", items: [{ productId: "prod-789", quantity: 2 }]). What happens if the resolver hands items straight to orderDataSource.createOrder?

先选一个选项Pick an option first
来自From 为什么会有 FederationWhy Federation exists · Federation 考试Federation exam
L1认出来Spot itFederation 主要解决的是什么问题What problem does Federation mainly solve

下面哪一条最准确地描述了 Federation 要解决的核心问题?

Which of these describes most accurately the core problem Federation sets out to solve?

先选一个选项Pick an option first
来自From 为什么会有 FederationWhy Federation exists · Federation 考试Federation exam
L1认出来Spot it哪些东西不在这个仓库里What is not in this repository

下面哪些是这个 assessment 仓库里没有的?(多选)

Which of these are not in this exam repository? (Select all that apply.)

这题是多选。More than one answer is correct.

先选一个选项Pick an option first
来自From subgraph 是怎么跑起来的How a subgraph starts up · Federation 考试Federation exam
L1认出来Spot it_entities 这个字段是谁加的Who adds the _entities field

schema.graphql 里从头到尾没有出现_entities,但 Router 能查它。它从哪来?

_entities appears nowhere in schema.graphql, yet the Router can query it. Where does it come from?

先选一个选项Pick an option first
来自From subgraph 是怎么跑起来的How a subgraph starts up · Federation 考试Federation exam
L1认出来Spot it本地怎么验证 federation 部分How to check the Federation part locally

仓库里没有 Router。你想确认自己的 User.orders在 federation 链路里能被正确调用。最直接的办法?

There is no Router in the repository. You want to confirm your User.orders is called correctly along the federation path. What is the most direct way?

先选一个选项Pick an option first
来自From entity、@key 与 __resolveReferenceentity, @key and __resolveReference · Federation 考试Federation exam
L1认出来Spot it@key 在声明什么What @key declares

type User @key(fields: "id") 最准确的含义是?

What does type User @key(fields: "id") mean, most precisely?

先选一个选项Pick an option first
来自From entity、@key 与 __resolveReferenceentity, @key and __resolveReference · Federation 考试Federation exam
L1认出来Spot itUser.orders 里的 user 参数上有什么What the user argument of User.orders carries

__resolveReference 返回 { id: user.id }。 那么 User.orders(user, ...) 里的 user上有哪些属性?

__resolveReference returns { id: user.id }. So which properties does user have inside User.orders(user, ...)?

先选一个选项Pick an option first
来自From N+1 问题与 DataLoaderThe N+1 problem and DataLoader · Federation 考试Federation exam
L1认出来Spot itDataLoader 靠什么把 N 次合并成 1 次How DataLoader turns N calls into 1

下面哪一条最准确?

Which of these is most accurate?

先选一个选项Pick an option first
来自From N+1 问题与 DataLoaderThe N+1 problem and DataLoader · Federation 考试Federation exam
L1认出来Spot itbatch 函数里哪种写法是错的Which return value from a batch function is wrong

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?

先选一个选项Pick an option first
来自From 先读题:四个 TODO、三处埋雷、十个测试Read the task first: four TODOs, three planted bugs, ten tests · Federation 考试Federation exam
L1认出来Spot it为什么基线里有 4 个测试是通过的Why 4 tests already pass at the baseline

四个 TODO 全都只写了 return []return null,为什么还有 4 个测试通过?

All four TODOs contain nothing but return [] or return null. So why do 4 tests still pass?

先选一个选项Pick an option first
来自From 先读题:四个 TODO、三处埋雷、十个测试Read the task first: four TODOs, three planted bugs, ten tests · Federation 考试Federation exam
L1认出来Spot it埋雷 1 该在哪个文件修Which file should planted bug 1 be fixed in

createOrderLoader 调了不存在的orderDataSource.getOrderById(id)。 正确的修法是?

createOrderLoader calls orderDataSource.getOrderById(id), which does not exist. What is the right fix?

先选一个选项Pick an option first