Exercise 1: A Default and Maximum Page Size — Possible Solution ================================================================= const DEFAULT_TAKE = 50; const MAX_TAKE = 100; export const pageLimits = Prisma.defineExtension({ name: "pageLimits", query: { post: { async findMany({ args, query }) { if (args.take === undefined) { args.take = DEFAULT_TAKE; } else if (Math.abs(args.take) > MAX_TAKE) { args.take = Math.sign(args.take) * MAX_TAKE; // keep the direction } return query(args); }, }, }, }); const prisma = base.$extends(pageLimits); await prisma.post.findMany(); // at most 50 rows await prisma.post.findMany({ take: 10 }); // 10 rows await prisma.post.findMany({ take: 5000 }); // capped to 100 await prisma.post.findMany({ take: -500 }); // capped to -100 (last 100) WHY THIS WORKS AS AN ANSWER ------------------------------ The extension only changes take, which doesn't alter the result's type, so it's allowed in a query extension. It treats "not provided" and "too large" separately, and handles a negative take (which Prisma uses to page backwards) by capping its size while keeping its sign. Because it's written with defineExtension, it can be tested and reused on its own. Note it applies only to top-level post.findMany — posts loaded through include on another model aren't limited.