TanStackT
TanStack16mo ago
3 replies
brilliant-lime

Trigger refetch/rerender after setDefaultOptions

  useEffect(() => {
    client.setDefaultOptions({
      queries: {
        meta: {
          workspace,
        },
      },
      mutations: {
        meta: {
          workspace,
        },
      },
    });

    client.refetchQueries();
  }, [workspace]);


I would like to trigger a refetch of all queries when the workpace variable changes. Workspace is being passed in most api's as a custom header and fed into the api via react-queries
meta
object.
The problem is that refetchQueries() does not have the updated
meta
object when refetching.
Was this page helpful?