动手做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
筛出 10 个练习(共 148 个)。Showing 10 of 148.点某一行的 Edit 按钮,浏览器标签页转圈,控制台刷出大量警告。 请判断类型并定位。
Press the Edit button on any row. The browser tab spins and the console fills up with warnings. Classify the error, then locate it.
点 Edit,输入框正常回填,按钮变成 Update。 改完内容点 Update —— 列表一点变化都没有, 表单也没清空。控制台干净。
Click Edit and the inputs prefill correctly, and the button becomes Update. Change the content and click Update — the list does not change at all, and the form does not clear either. The console is clean.
快速点两个用户,界面最后显示的是先点的那个。 慢一点点就没问题。控制台干净。
Click two users quickly and the screen ends up showing the one you clicked first. Click a little slower and it is fine. The console is clean.
给深层评论加回复,console.log 打出来的树里 新回复确实在,但界面没变化。控制台干净。
You add a reply to a deep comment. The tree printed by console.log really does contain the new reply, but the screen does not change. The console is clean.
这一题不告诉你是哪一类。控制台干净,console.log 显示数据是对的。 自己分诊。
This one does not tell you which category it is. The console is clean, and console.log shows the data is correct. Sort it yourself.
Mutation.createOrder 的测试挂了。 报错说在读一个 undefined 的属性。自己分诊。
The Mutation.createOrder test fails. The error says something read a property of undefined. Diagnose it yourself.
代码跑得通,没有异常。但测试说错误码不对。 这是三处埋雷里最值得理解的一处。
The code runs and raises no exception, but the test says the error code is wrong. Of the three planted bugs, this is the one most worth understanding.
五个测试全过。但手动 curl 一个不存在的 id, 得到 200 和一个空 body。期望是 404 加一段 JSON。
All five tests pass. But curl an id that does not exist by hand and you get a 200 with an empty body. It should be a 404 with a piece of JSON.
你确信写了 shippingInfo 的实现, 测试也不报错,但查询返回的 shippingInfo 是null。控制台里连你加的 log 都没打印。
You are sure you wrote an implementation for shippingInfo, and no test reports anything, but the query returns shippingInfo as null. Not even the log line you added prints on the console.
查两个订单的物流,返回的数据对上了错的订单。 没有任何报错。这是 DataLoader 最阴险的一类误用。
You query the shipping info for two orders and the data comes back attached to the wrong order. Nothing reports an error. This is the hardest kind of DataLoader misuse to notice.