-
In the docs about request batching it says that the post by id queries will result in one request and one database query. The one request part I understand, but doesn't the one database query assertion depend on whether the server uses a dataloader, or something similar? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hey! Yeah, your backend needs to have a dataloader or similar. If you use Prisma, you get this behaviour out-of-the-box as their For a reference example, you can pull down the next-prisma-starter and comment out these lines trpc/examples/next-prisma-starter/src/pages/index.tsx Lines 12 to 16 in d2e8839 The above will prefetch all the data from the If you run the project in development mode you all the queries made are logged so you can see it for yourself :) |
Beta Was this translation helpful? Give feedback.
Hey!
Yeah, your backend needs to have a dataloader or similar.
If you use Prisma, you get this behaviour out-of-the-box as their
.findUnique()
-etc waits a tick before being called. How that works you can see in their video here: https://www.youtube.com/watch?v=7oMfBGEdwscFor a reference example, you can pull down the next-prisma-starter and comment out these lines
trpc/examples/next-prisma-starter/src/pages/index.tsx
Lines 12 to 16 in d2e8839
The above will prefetch all the data from the
post.byId
-proced…