Skip to content

Add meta to hydrated queries and mutations #5202

Answered by TkDodo
JanStevens asked this question in Ideas
Discussion options

You must be logged in to vote

while it looks like a good idea, the problem is that meta is an option, and not part of the state. We don't persist options, only state :) meta can also easily contain non-serializable things like functions.

What you can do though is provide defaultOptions to the hydration process:

const defaultOptions = {
  queries: {
      // Set cacheTime to 24h for persisted Cache
      cacheTime: 1000 * 60 * 60 * 24,
      refetchOnWindowFocus: false,
      retry: 2,
      meta: {
        // By default we don't want to store queries in local storage
        localStorage: false,
      },
  }
}

const queryClient = new QueryClient({
  queryCache,
  defaultOptions,
});

const PersistOptions: PersistQuer…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@TkDodo
Comment options

@JanStevens
Comment options

Answer selected by JanStevens
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants