9. Task API & Querying Features
The Task model exists, the database has a tasks table, we can't access them via our API yet.
This chapter builds the task API and introduces relational queries, query-parameter filters, and eager loading.
- Building Task Endpoints: A new router for tasks, mirroring the project router but with the relationship to
Projectin play. - Relational Queries & Filtering:
where,join, andselectinload(the fix for N+1 queries when a response includes related data). - Database Fixtures with Pytest: The in-memory SQLite +
StaticPoolpattern, plus the fixture chain that builds sample data per test. - Exercise: Implement filtering in
list_tasksand write two endpoint tests.