question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add `createSSGHelpers().setQueryData()`

See original GitHub issue

Thank 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:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
KATTcommented, May 16, 2021

You can access queryClient now if you upgrade to 6.2.0

1reaction
KATTcommented, May 16, 2021

@all-contributors add @kripod for ideas

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add setQueryData to QueryResult · Discussion #3304 - GitHub
It's a non-optimistic update on a combined detail/edit page. const thingQ = useQuery(['thing', id], () => getThing(id)); const updateThingMutation = useMutation ...
Read more >
setQueryData not updating the cache with React-Query
This data is available when destructuring the useQuery hook or is available with the onSuccess callback. It can be usefull to manually update ......
Read more >
Async data made simple with React Query - Hey! I'm Tyler
A library of custom hooks that solves async data fetching and caching within React apps. We added react-query to a simple blog post...
Read more >
The trpc from trpc - Giter VIP
Possible to bulk-add input schema (like .queries() ... The createSSGHelpers method of @trpc/react can be used for both SSG and SSR, and the...
Read more >
useQuery() - tRPC
useQuery(). The hooks provided by @trpc/react are a thin wrapper around React Query. For in-depth information about options and usage patterns, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found