Skip to content
Source
Sign inSign up
TanStack/query

fix(experimental_createQueryPersister): return more utilities, rename persister #8062

MergedDamianOsipiuk(GitHub profile, opens in a new tab)merged 5 commits intomain fromrefs/pull/8062/headmerged by DamianOsipiuk(GitHub profile, opens in a new tab) View on GitHub

Restructure plugin to expose more utilities useful in user-land.

Returned utilities:

  • persisterFn - main persister function that can be passed to useQuery
  • persistQueryByKey - persist query to persister storage. Ex call it just after setQueryData
  • retrieveQuery - retrieve one query from persister storage
  • persisterGc - gc pass for the persister storage to clean up unusable entries
  • persisterRestoreAll - restore are persisted queries from storage

TODO:

  • tests
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: query-persist-client-core

    2. View your CI Pipeline Execution ↗ for commit ec6573e5c0f85e5c10c10d6ef72d6e0a83373bcc.

      CommandStatusDurationResult
      nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded2m 45sView ↗
      nx run-many --target=build --exclude=examples/*...✅ Succeeded55sView ↗

      ☁️ Nx Cloud last updated this comment at 2025-05-13 21:37:54 UTC

    3. More templates

      @tanstack/angular-query-devtools-experimental

      npm i https://pkg.pr.new/@tanstack/angular-query-devtools-experimental@8062

      @tanstack/angular-query-experimental

      npm i https://pkg.pr.new/@tanstack/angular-query-experimental@8062

      @tanstack/eslint-plugin-query

      npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@8062

      @tanstack/query-async-storage-persister

      npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@8062

      @tanstack/query-broadcast-client-experimental

      npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@8062

      @tanstack/query-core

      npm i https://pkg.pr.new/@tanstack/query-core@8062

      @tanstack/query-devtools

      npm i https://pkg.pr.new/@tanstack/query-devtools@8062

      @tanstack/query-persist-client-core

      npm i https://pkg.pr.new/@tanstack/query-persist-client-core@8062

      @tanstack/query-sync-storage-persister

      npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@8062

      @tanstack/react-query

      npm i https://pkg.pr.new/@tanstack/react-query@8062

      @tanstack/react-query-devtools

      npm i https://pkg.pr.new/@tanstack/react-query-devtools@8062

      @tanstack/react-query-next-experimental

      npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@8062

      @tanstack/react-query-persist-client

      npm i https://pkg.pr.new/@tanstack/react-query-persist-client@8062

      @tanstack/solid-query

      npm i https://pkg.pr.new/@tanstack/solid-query@8062

      @tanstack/solid-query-devtools

      npm i https://pkg.pr.new/@tanstack/solid-query-devtools@8062

      @tanstack/solid-query-persist-client

      npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@8062

      @tanstack/svelte-query

      npm i https://pkg.pr.new/@tanstack/svelte-query@8062

      @tanstack/svelte-query-devtools

      npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@8062

      @tanstack/svelte-query-persist-client

      npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@8062

      @tanstack/vue-query

      npm i https://pkg.pr.new/@tanstack/vue-query@8062

      @tanstack/vue-query-devtools

      npm i https://pkg.pr.new/@tanstack/vue-query-devtools@8062

      commit: ec6573e

    4. github-actions[bot](GitHub profile, opens in a new tab) added labelsdocumentation

    5. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: react-query

    6. Codecov Report

      Attention: Patch coverage is 92.53731% with 5 lines in your changes missing coverage. Please review.

      Project coverage is 80.83%. Comparing base (c89c6a0) to head (ec6573e). Report is 2 commits behind head on main.

      Additional details and impacted files

      Impacted file tree graph

      @@             Coverage Diff             @@
      ##             main    #8062       +/-   ##
      ===========================================
      + Coverage   44.40%   80.83%   +36.42%     
      ===========================================
        Files         206       36      -170     
        Lines        8174      668     -7506     
        Branches     1822      182     -1640     
      ===========================================
      - Hits         3630      540     -3090     
      + Misses       4100      111     -3989     
      + Partials      444       17      -427     
      ComponentsCoverage Δ
      @tanstack/angular-query-devtools-experimental∅ <ø> (∅)
      @tanstack/angular-query-experimental∅ <ø> (∅)
      @tanstack/eslint-plugin-query∅ <ø> (∅)
      @tanstack/query-async-storage-persister43.85% <ø> (ø)
      @tanstack/query-broadcast-client-experimental∅ <ø> (∅)
      @tanstack/query-codemods∅ <ø> (∅)
      @tanstack/query-core∅ <ø> (∅)
      @tanstack/query-devtools∅ <ø> (∅)
      @tanstack/query-persist-client-core78.32% <92.53%> (+4.85%):arrow_up:
      @tanstack/query-sync-storage-persister84.61% <ø> (ø)
      @tanstack/query-test-utils∅ <ø> (∅)
      @tanstack/react-query95.34% <ø> (ø)
      @tanstack/react-query-devtools10.00% <ø> (ø)
      @tanstack/react-query-next-experimental∅ <ø> (∅)
      @tanstack/react-query-persist-client100.00% <ø> (ø)
      @tanstack/solid-query∅ <ø> (∅)
      @tanstack/solid-query-devtools∅ <ø> (∅)
      @tanstack/solid-query-persist-client100.00% <ø> (ø)
      @tanstack/svelte-query∅ <ø> (∅)
      @tanstack/svelte-query-devtools∅ <ø> (∅)
      @tanstack/svelte-query-persist-client100.00% <ø> (ø)
      @tanstack/vue-query∅ <ø> (∅)
      @tanstack/vue-query-devtools∅ <ø> (∅)
      :rocket: New features to boost your workflow:
      • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
      • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
  • Sizes for commit ec6573e5c0f85e5c10c10d6ef72d6e0a83373bcc:

    BranchBundle Size
    Main
    This PR
  • @DamianOsipiuk thank you very much for this!

  • does this close any of the open issues around createPersister ?

  • does this close any of the open issues around createPersister ?

    This should close https://github.com/TanStack/query/issues/6310. It exposes utilities to do persistence on demand in user-land. And if i recall correctly we decided that we do not want to put more code to make that work out-of-the-box into the core.

  • yeah if we want more utilities, they should come from the persister package

  • Sign in to join this conversation.