Skip to content

Default makeQueryCache server behaviour does not match Readme #706

@Ephem

Description

@Ephem

Describe the bug

This is either a bug or an error in the Readme.

To Reproduce

Readme says:

If you create a queryCache manually with makeQueryCache, queries will be cached during SSR. Make sure you create a separate cache per request to avoid leaking data.

This is not true however, you have to explicitly call makeQueryCache({ frozen: false }) to enable caching on the server.

Expected behavior

One of:

  • Update Readme to match actual behaviour
  • Update default behaviour to match Readme

Additional context

Release notes says:

  • makeQueryCache now accepts an optional configuration object. The defaultConfig object is used to override the default query configuration config to use inside of this cache. The frozen option if set to true will simulate React Query being run on the server, where no queries are cached for privacy and safety concerns. This is the default when using React Query on the server and is optional. You can also set it to true on the server and have it work as it would on the client. More information on this coming soon!

I'm guessing this behaviour was changed between #584 being merged and the release, but the info in the Readme was unintentionally not updated?

I don't have any strong feelings on this and would be happy to fix it either way, but I'd argue that creating a cache manually on the server only makes sense if you intend to use it for caching, making unfrozen a good default (but not for the global cache of course). I also don't see a security risk in this, since the developer is intentionally creating the cache.

Changing the default behaviour would kind of be a small breaking change though (intended for v2), but could also be considered a fix to match the Readme, depending. It would not affect people using { frozen: true/false } explicitly, so should be fine.

I'd be happy to just update the Readme as well of course. 😄

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions