Add `createSSGHelpers().setQueryData()`
See original GitHub issueThank you for bringing this project to life – it has been a joy to use from the very start!
While experimenting with SSG helpers, I realized that the only React Query methods available are fetchQuery
and prefetchQuery
. The latter could be used with a custom initializer method, but unfortunately, tRPC doesn’t support that approach at this time.
When prefetching more queries during SSR/SSG, executing DB queries as a single transaction to obtain all the data required could outperform parallel queries ran via Promise.all([ssg.fetchData(…), ssg.fetchData(…), …])
.
For instance, Prisma’s $transaction
API makes it possible to execute the related queries at once, without having to wait for hops between the DB and the app server multiple times. However, the results have to be primed manually into the QueryClient
returned by createSSGHelpers
. Exposing setQueryData
could bring great performance improvements for end-users.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:9 (8 by maintainers)
Top GitHub Comments
You can access
queryClient
now if you upgrade to6.2.0
@all-contributors add @kripod for ideas