Skip to content

Conversation

@Ephem
Copy link
Collaborator

@Ephem Ephem commented Jun 14, 2020

This is a breakout from #570 and replaces makeServerQueryCache in that PR. More background can be found there.

Before this PR, queries wont ever get cached in a server environment to avoid leaking sensitive information between requests (#70). This PR makes it so any cache that has been manually created via makeQueryCache will cache data, even on the server.

This change wont improve SSR (much) by itself but is a prerequisite. I'm pretty sure this PR is the only breaking change needed and that de/rehydration can be achieved without breaking changes.

This also adds some extra guards for scheduleStale and scheduleGarbage, since I don't believe these should ever be called on the server. Lifetime on the server should be manually managed (usually lifetime should be a single request).

I saw defaultConfig was added to makeQueryCache. I needed an extra frozen-option that I don't think makes sense as a cache config, but rather an option to makeQueryCache itself, so I took the liberty of changing the signature into an options-object instead if that's ok?

I'm not sure if the frozen-option should be documented and public or not and it would also be trivial to add .freeze() and .unfreeze()-methods, but I'm not sure if I see any use-cases for exposing this?

Just a heads up: I'm AFK for about a week from tomorrow, so while I can read and respond, actually fixing comments will take some time. 😄 I'll tackle next steps after that.

Ephem added 2 commits June 14, 2020 22:58
…reated

This change is done so we can improve support for server side rendering in the future.
* Caches created with makeQueryCache on the server now cache data
* Add options object to makeQueryCache and move defaultConfig-option into that
* Add more server guards for scheduleStale and scheduleGarbage
* Add more SSR-tests

BREAKING CHANGE: Caches created with makeQueryCache will now cache data on the server.
@tannerlinsley
Copy link
Member

Alright, the next branch is pretty darn stable. If you could would you mind resolving any conflicts and updating any uses of makeQueryCache in the repo to take it into account?

@tannerlinsley tannerlinsley merged commit f5d039d into TanStack:next Jun 17, 2020
@tannerlinsley
Copy link
Member

NM, I got it merged :)

@tannerlinsley
Copy link
Member

🎉 This PR is included in version 2.0.0-next.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants