#Hello folks ๐Ÿ‘‹ , I have just created this rep...

1 messages ยท Page 1 of 1 (latest)

stark ginkgoBOT
#

Thread automatically created, you can use it to discuss about the content!

old slate
#

YES THIS

#

I was planning to investigate those functions just today

#

so you do manage to reuse the cache between different call for same request? eg "getPosts" and "getPostsWithAuthors" is able to have the right caching behaviour for "Posts" (adding authors to the cached Posts if you call getPosts before getPostsWithAuthors for instance)?

#

anyway I think your approach is, currently, the right one, and will stay the right one until next.js implements an abstraction to enhance the request context

inner dome
#

Hey @old slate ! Glad that you found this useful. Yes, that was my intention and i was able to cache all the queries that happen under the same request with this method.

About the repo, I somehow forgot to make it public, my mistake there! It is public now :)

old slate
#

I've shared the article on tRPC discord as they are working on this, I've read the code very very quickly but it's great!

#

I think Apollo has a helper, or had in the past, that would let you extract the queries directly from useQueries hook in the React tree

#

but no idea if it would tolerate Server Components

#

this could be an alternative to manually triggering the data you want to be warmed up during SSR

inner dome
#

Thank you! I've actually taken the inspiration from tRPC's next-13 starter repo as well.

I think once you pass ssrMode:true to Apollo client that's exactly how it works, bundles up all the queries in the react tree and executes them. Although, I think that's not really working properly with Next 13 because of the nested layouts. That's why we may need this kind of a caching solution. Still, I'm sure this is not the optimal solution but hey, it does the job to an extent! ๐Ÿ˜…

old slate
#

ha to be fair, I strongly dislike getDataFromTree, having used it in the early days and later

#

in most scenarios, hand-picked SSR in next.js style is waaay more appropriate

#

so your solution is I think optimal, it's just there is also this other pattern that some people use