Tente resolver a tarefa antes de consultar os critérios. Compare o resultado e explique o que mudou no seu raciocínio.
Task, 15 minutes: a DataLoader batch receives keys ["u3", "u1", "u2"]. The database returns u2 and u1 in that order. u3 does not exist, and this lookup contract represents missing users with null. Write the mapping from requested keys to returned values before implementing the batch function. Then batch orders for a list of users, count database calls, and explain how two requests with different permissions stay isolated.
Check your work:
- The returned array is
[null, user1, user2]for a nullable lookup contract. Returning database order assigns data to the wrong key. - For a list of users and their orders, count database calls. One users query plus one batched orders query should replace a per-user orders query in this fixture.
- Two requests with different permissions get separate loader instances. The underlying query still enforces authorization.
Follow-up: explain why batching does not limit an arbitrarily deep or expensive query. Add a separate query-cost or depth policy.
Source: DataLoader batch contract.
No app, a tarefa fica visível e você pode revelar os critérios depois da tentativa. Use as notas para registrar sua solução.
Praticar este exercício no app