Closed dcramer closed 5 months ago
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 78.08%. Comparing base (
d27b869
) to head (14bba97
).
:white_check_mark: All tests successful. No failed tests found.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
actually, we need to run dehydrate on it, which isnt awesome..
maybe theres a way to just hack this in...
Ok so high level here's the issue:
Today I've managed to get it so the same query can be used server and client side. Subsequent navigations on the client can re-use the same cache. Generally speaking, its a good spot to be in.
(Caveat, the cache might not be busting between server-routing due to the singleton, and that is not a desirable default)
The challenge:
I cant see how to achieve the above using the existing hydration helpers. To do that we'd need - at the root level - to implement a shared dehydration boundary. That's ok, except the way loaders work they are component specific. That means while even though we can pass dehydratedState in every single clientLoader through our abstraction, we wont be able to actually rehydrate it.
Found a workaround for hydration of state but now it makes the implementation far more tightly constrained. Realistically we'd need a context processor for clientLoader to avoid this.
export function shouldRevalidate() {
return false;
}
Appears to fix the root loader happening every single navigation entry. Not sure if its going to cause any other issues..
This migrates away from direct tRPC bindings in loaders, and instead injects a query client. It does this to ensure the cache is utilized as best as possible.
The DX is intended to be lower-boilerplate:
What this does under the hood is the following:
json()
call in the loader - this behavior is ignored if a Response-type is the return value.