@suspensive/react-query-4 3.15.1 → 3.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ClientOnly-P5h-7PhS.mjs → ClientOnly-BdmzVYnI.mjs} +1 -1
- package/dist/{ClientOnly-P5h-7PhS.mjs.map → ClientOnly-BdmzVYnI.mjs.map} +1 -1
- package/dist/{IsFetching-DWmZ80q2.mjs → IsFetching-94upYqWP.mjs} +1 -1
- package/dist/{IsFetching-DWmZ80q2.mjs.map → IsFetching-94upYqWP.mjs.map} +1 -1
- package/dist/{IsFetching-3KG146_K.d.mts → IsFetching-BLwpeMoH.d.mts} +3 -3
- package/dist/{IsFetching-DZvSjDTq.d.cts.map → IsFetching-BLwpeMoH.d.mts.map} +1 -1
- package/dist/{IsFetching-DZvSjDTq.d.cts → IsFetching-KHFEg_eS.d.cts} +3 -3
- package/dist/{IsFetching-3KG146_K.d.mts.map → IsFetching-KHFEg_eS.d.cts.map} +1 -1
- package/dist/IsFetching.d.cts +1 -1
- package/dist/IsFetching.d.mts +1 -1
- package/dist/IsFetching.mjs +1 -1
- package/dist/{Mutation-CR3oXQ6p.d.mts → Mutation-CGpbCg54.d.mts} +1 -1
- package/dist/{Mutation-CR3oXQ6p.d.mts.map → Mutation-CGpbCg54.d.mts.map} +1 -1
- package/dist/{Mutation-CkHa5_Af.mjs → Mutation-Dh5n54P8.mjs} +2 -2
- package/dist/{Mutation-CkHa5_Af.mjs.map → Mutation-Dh5n54P8.mjs.map} +1 -1
- package/dist/{Mutation-DClZyxmF.d.cts → Mutation-Dt5kUsd8.d.cts} +1 -1
- package/dist/{Mutation-DClZyxmF.d.cts.map → Mutation-Dt5kUsd8.d.cts.map} +1 -1
- package/dist/Mutation.d.cts +1 -1
- package/dist/Mutation.d.mts +1 -1
- package/dist/Mutation.mjs +2 -2
- package/dist/{PrefetchInfiniteQuery-DtZ7itiY.d.mts → PrefetchInfiniteQuery-BewcG5rR.d.cts} +3 -3
- package/dist/{PrefetchInfiniteQuery-B9hGVsbw.d.cts.map → PrefetchInfiniteQuery-BewcG5rR.d.cts.map} +1 -1
- package/dist/{PrefetchInfiniteQuery-B9hGVsbw.d.cts → PrefetchInfiniteQuery-Dkd2ChpC.d.mts} +3 -3
- package/dist/{PrefetchInfiniteQuery-DtZ7itiY.d.mts.map → PrefetchInfiniteQuery-Dkd2ChpC.d.mts.map} +1 -1
- package/dist/{PrefetchInfiniteQuery-C0eOVFlg.mjs → PrefetchInfiniteQuery-RS3Qz-7B.mjs} +2 -2
- package/dist/{PrefetchInfiniteQuery-C0eOVFlg.mjs.map → PrefetchInfiniteQuery-RS3Qz-7B.mjs.map} +1 -1
- package/dist/PrefetchInfiniteQuery.d.cts +1 -1
- package/dist/PrefetchInfiniteQuery.d.mts +1 -1
- package/dist/PrefetchInfiniteQuery.mjs +2 -2
- package/dist/{PrefetchQuery-PoJ8NbtL.d.mts → PrefetchQuery-BfNg0tKA.d.cts} +3 -3
- package/dist/{PrefetchQuery-DJQ3O6jL.d.cts.map → PrefetchQuery-BfNg0tKA.d.cts.map} +1 -1
- package/dist/{PrefetchQuery-DJQ3O6jL.d.cts → PrefetchQuery-CoxqaDzh.d.mts} +2 -2
- package/dist/{PrefetchQuery-PoJ8NbtL.d.mts.map → PrefetchQuery-CoxqaDzh.d.mts.map} +1 -1
- package/dist/{PrefetchQuery-7QYRCNcB.mjs → PrefetchQuery-uh4idoXK.mjs} +2 -2
- package/dist/{PrefetchQuery-7QYRCNcB.mjs.map → PrefetchQuery-uh4idoXK.mjs.map} +1 -1
- package/dist/PrefetchQuery.d.cts +1 -1
- package/dist/PrefetchQuery.d.mts +1 -1
- package/dist/PrefetchQuery.mjs +2 -2
- package/dist/{QueriesHydration-COAxA2eo.d.cts → QueriesHydration-BCGsQdvj.d.cts} +1 -1
- package/dist/{QueriesHydration-COAxA2eo.d.cts.map → QueriesHydration-BCGsQdvj.d.cts.map} +1 -1
- package/dist/{QueriesHydration-CdvYxMoD.d.mts → QueriesHydration-Bna6eo52.d.mts} +3 -3
- package/dist/{QueriesHydration-CdvYxMoD.d.mts.map → QueriesHydration-Bna6eo52.d.mts.map} +1 -1
- package/dist/{QueriesHydration-CJDH1B_7.cjs → QueriesHydration-CQ5Lct-O.cjs} +3 -68
- package/dist/{QueriesHydration-CJDH1B_7.cjs.map → QueriesHydration-CQ5Lct-O.cjs.map} +1 -1
- package/dist/{QueriesHydration-C8w5Rm3q.mjs → QueriesHydration-D-iXKM2g.mjs} +4 -69
- package/dist/{QueriesHydration-C8w5Rm3q.mjs.map → QueriesHydration-D-iXKM2g.mjs.map} +1 -1
- package/dist/QueriesHydration.cjs +2 -1
- package/dist/QueriesHydration.d.cts +1 -1
- package/dist/QueriesHydration.d.mts +1 -1
- package/dist/QueriesHydration.mjs +4 -3
- package/dist/{QueryClientConsumer-BXcUnpLu.d.mts → QueryClientConsumer-DNur-77Z.d.mts} +3 -3
- package/dist/{QueryClientConsumer-BXcUnpLu.d.mts.map → QueryClientConsumer-DNur-77Z.d.mts.map} +1 -1
- package/dist/{QueryClientConsumer-DspevCdg.mjs → QueryClientConsumer-e7PyaFF3.mjs} +1 -1
- package/dist/{QueryClientConsumer-DspevCdg.mjs.map → QueryClientConsumer-e7PyaFF3.mjs.map} +1 -1
- package/dist/{QueryClientConsumer-DjbiW3QY.cjs → QueryClientConsumer-mF0OUwkq.cjs} +1 -1
- package/dist/{QueryClientConsumer-DjbiW3QY.cjs.map → QueryClientConsumer-mF0OUwkq.cjs.map} +1 -1
- package/dist/{QueryClientConsumer-BrLhJAim.d.cts → QueryClientConsumer-pihgMOoA.d.cts} +1 -1
- package/dist/{QueryClientConsumer-BrLhJAim.d.cts.map → QueryClientConsumer-pihgMOoA.d.cts.map} +1 -1
- package/dist/QueryClientConsumer.cjs +1 -1
- package/dist/QueryClientConsumer.d.cts +1 -1
- package/dist/QueryClientConsumer.d.mts +1 -1
- package/dist/QueryClientConsumer.mjs +1 -1
- package/dist/{SuspenseInfiniteQuery-BDTZAWs7.d.cts → SuspenseInfiniteQuery-BwSKmJgm.d.cts} +2 -2
- package/dist/{SuspenseInfiniteQuery-BDTZAWs7.d.cts.map → SuspenseInfiniteQuery-BwSKmJgm.d.cts.map} +1 -1
- package/dist/{SuspenseInfiniteQuery-Dm9U1IPG.d.mts → SuspenseInfiniteQuery-CDKieP3L.d.mts} +4 -4
- package/dist/{SuspenseInfiniteQuery-Dm9U1IPG.d.mts.map → SuspenseInfiniteQuery-CDKieP3L.d.mts.map} +1 -1
- package/dist/{SuspenseInfiniteQuery-CTap1GdP.mjs → SuspenseInfiniteQuery-CZ73eUHy.mjs} +2 -2
- package/dist/{SuspenseInfiniteQuery-CTap1GdP.mjs.map → SuspenseInfiniteQuery-CZ73eUHy.mjs.map} +1 -1
- package/dist/{SuspenseInfiniteQuery-BZCYAjw-.cjs → SuspenseInfiniteQuery-DOYHl2Cu.cjs} +1 -1
- package/dist/{SuspenseInfiniteQuery-BZCYAjw-.cjs.map → SuspenseInfiniteQuery-DOYHl2Cu.cjs.map} +1 -1
- package/dist/SuspenseInfiniteQuery.cjs +1 -1
- package/dist/SuspenseInfiniteQuery.d.cts +2 -2
- package/dist/SuspenseInfiniteQuery.d.mts +2 -2
- package/dist/SuspenseInfiniteQuery.mjs +2 -2
- package/dist/{SuspenseQueries-Bij_jBgE.cjs → SuspenseQueries-Brk6gtMw.cjs} +1 -1
- package/dist/{SuspenseQueries-Bij_jBgE.cjs.map → SuspenseQueries-Brk6gtMw.cjs.map} +1 -1
- package/dist/{SuspenseQueries-dN78EqbL.mjs → SuspenseQueries-C0mF_XD_.mjs} +1 -1
- package/dist/{SuspenseQueries-dN78EqbL.mjs.map → SuspenseQueries-C0mF_XD_.mjs.map} +1 -1
- package/dist/{SuspenseQueries-DAXTYR9M.d.mts → SuspenseQueries-CfsA2n8v.d.mts} +1 -1
- package/dist/{SuspenseQueries-DAXTYR9M.d.mts.map → SuspenseQueries-CfsA2n8v.d.mts.map} +1 -1
- package/dist/{SuspenseQueries-GYiP7qAa.d.cts → SuspenseQueries-wO-fCk30.d.cts} +3 -3
- package/dist/{SuspenseQueries-GYiP7qAa.d.cts.map → SuspenseQueries-wO-fCk30.d.cts.map} +1 -1
- package/dist/SuspenseQueries.cjs +1 -1
- package/dist/SuspenseQueries.d.cts +1 -1
- package/dist/SuspenseQueries.d.mts +1 -1
- package/dist/SuspenseQueries.mjs +1 -1
- package/dist/{SuspenseQuery-7Zbz551V.cjs → SuspenseQuery-B-SvR9l0.cjs} +1 -1
- package/dist/{SuspenseQuery-7Zbz551V.cjs.map → SuspenseQuery-B-SvR9l0.cjs.map} +1 -1
- package/dist/{SuspenseQuery-Bg3h1Es3.d.cts → SuspenseQuery-C4Og1-Xi.d.mts} +3 -3
- package/dist/{SuspenseQuery-Bg3h1Es3.d.cts.map → SuspenseQuery-C4Og1-Xi.d.mts.map} +1 -1
- package/dist/{SuspenseQuery-COzwc2gl.mjs → SuspenseQuery-C8eBAEnT.mjs} +2 -2
- package/dist/{SuspenseQuery-COzwc2gl.mjs.map → SuspenseQuery-C8eBAEnT.mjs.map} +1 -1
- package/dist/{SuspenseQuery-CjQ3EBKI.d.mts → SuspenseQuery-D4IZU_Co.d.cts} +3 -3
- package/dist/{SuspenseQuery-CjQ3EBKI.d.mts.map → SuspenseQuery-D4IZU_Co.d.cts.map} +1 -1
- package/dist/SuspenseQuery.cjs +1 -1
- package/dist/SuspenseQuery.d.cts +1 -1
- package/dist/SuspenseQuery.d.mts +1 -1
- package/dist/SuspenseQuery.mjs +2 -2
- package/dist/components/ClientOnly.d.cts +2 -2
- package/dist/components/ClientOnly.d.mts +2 -2
- package/dist/components/ClientOnly.mjs +1 -1
- package/dist/createGetQueryClient-CNRrumkK.cjs +68 -0
- package/dist/createGetQueryClient-CNRrumkK.cjs.map +1 -0
- package/dist/createGetQueryClient-DTKVVwpJ.d.mts +54 -0
- package/dist/createGetQueryClient-DTKVVwpJ.d.mts.map +1 -0
- package/dist/createGetQueryClient-DwJ6i2aT.mjs +63 -0
- package/dist/createGetQueryClient-DwJ6i2aT.mjs.map +1 -0
- package/dist/createGetQueryClient-iXoXO7so.d.cts +54 -0
- package/dist/createGetQueryClient-iXoXO7so.d.cts.map +1 -0
- package/dist/createGetQueryClient.cjs +4 -0
- package/dist/createGetQueryClient.d.cts +2 -0
- package/dist/createGetQueryClient.d.mts +2 -0
- package/dist/createGetQueryClient.mjs +4 -0
- package/dist/index.cjs +14 -11
- package/dist/index.d.cts +19 -18
- package/dist/index.d.mts +19 -18
- package/dist/index.mjs +22 -20
- package/dist/{infiniteQueryOptions-C27u8Ixn.mjs → infiniteQueryOptions-2KFmTqEY.mjs} +1 -1
- package/dist/{infiniteQueryOptions-C27u8Ixn.mjs.map → infiniteQueryOptions-2KFmTqEY.mjs.map} +1 -1
- package/dist/{infiniteQueryOptions-1njTxHGL.cjs → infiniteQueryOptions-BVac5B-c.cjs} +1 -1
- package/dist/{infiniteQueryOptions-1njTxHGL.cjs.map → infiniteQueryOptions-BVac5B-c.cjs.map} +1 -1
- package/dist/{infiniteQueryOptions-B8E274sw.d.mts → infiniteQueryOptions-Be7VYTUR.d.cts} +1 -1
- package/dist/{infiniteQueryOptions-B8E274sw.d.mts.map → infiniteQueryOptions-Be7VYTUR.d.cts.map} +1 -1
- package/dist/{infiniteQueryOptions-DlBYY8gQ.d.cts → infiniteQueryOptions-Bpz4mFYH.d.mts} +1 -1
- package/dist/{infiniteQueryOptions-DlBYY8gQ.d.cts.map → infiniteQueryOptions-Bpz4mFYH.d.mts.map} +1 -1
- package/dist/infiniteQueryOptions.cjs +1 -1
- package/dist/infiniteQueryOptions.d.cts +1 -1
- package/dist/infiniteQueryOptions.d.mts +1 -1
- package/dist/infiniteQueryOptions.mjs +1 -1
- package/dist/{mutationOptions-CPRFk8op.cjs → mutationOptions-BIOn3zne.cjs} +1 -1
- package/dist/{mutationOptions-CPRFk8op.cjs.map → mutationOptions-BIOn3zne.cjs.map} +1 -1
- package/dist/{mutationOptions-Clj_vPii.d.cts → mutationOptions-BZS10WEJ.d.mts} +1 -1
- package/dist/{mutationOptions-C9u4Q4VU.d.mts.map → mutationOptions-BZS10WEJ.d.mts.map} +1 -1
- package/dist/{mutationOptions-VOkWleB4.mjs → mutationOptions-C4emetVL.mjs} +1 -1
- package/dist/{mutationOptions-VOkWleB4.mjs.map → mutationOptions-C4emetVL.mjs.map} +1 -1
- package/dist/{mutationOptions-C9u4Q4VU.d.mts → mutationOptions-Eid3aM1W.d.cts} +1 -1
- package/dist/{mutationOptions-Clj_vPii.d.cts.map → mutationOptions-Eid3aM1W.d.cts.map} +1 -1
- package/dist/mutationOptions.cjs +1 -1
- package/dist/mutationOptions.d.cts +1 -1
- package/dist/mutationOptions.d.mts +1 -1
- package/dist/mutationOptions.mjs +1 -1
- package/dist/objectSpread2-BHq2muQo.mjs +67 -0
- package/dist/objectSpread2-CGqp5tYf.cjs +73 -0
- package/dist/{queryOptions-DOVbAJjO.cjs → queryOptions-92vSd4eV.cjs} +1 -1
- package/dist/{queryOptions-DOVbAJjO.cjs.map → queryOptions-92vSd4eV.cjs.map} +1 -1
- package/dist/{queryOptions-D42SP_vE.d.mts → queryOptions-DILe-4vk.d.mts} +1 -1
- package/dist/{queryOptions-D42SP_vE.d.mts.map → queryOptions-DILe-4vk.d.mts.map} +1 -1
- package/dist/{queryOptions-Z6iEA5XS.d.cts → queryOptions-DNGHeGX5.d.cts} +1 -1
- package/dist/{queryOptions-Z6iEA5XS.d.cts.map → queryOptions-DNGHeGX5.d.cts.map} +1 -1
- package/dist/{queryOptions-WyeTyhoy.mjs → queryOptions-Dnf4-wlk.mjs} +1 -1
- package/dist/{queryOptions-WyeTyhoy.mjs.map → queryOptions-Dnf4-wlk.mjs.map} +1 -1
- package/dist/queryOptions.cjs +1 -1
- package/dist/queryOptions.d.cts +1 -1
- package/dist/queryOptions.d.mts +1 -1
- package/dist/queryOptions.mjs +1 -1
- package/dist/{usePrefetchInfiniteQuery-xFsVE7gF.d.mts → usePrefetchInfiniteQuery-B0_Ladyp.d.mts} +1 -1
- package/dist/{usePrefetchInfiniteQuery-Db5oZ2b_.d.cts.map → usePrefetchInfiniteQuery-B0_Ladyp.d.mts.map} +1 -1
- package/dist/{usePrefetchInfiniteQuery-DZiSAbIS.mjs → usePrefetchInfiniteQuery-CQSN-P9m.mjs} +1 -1
- package/dist/{usePrefetchInfiniteQuery-DZiSAbIS.mjs.map → usePrefetchInfiniteQuery-CQSN-P9m.mjs.map} +1 -1
- package/dist/{usePrefetchInfiniteQuery-Db5oZ2b_.d.cts → usePrefetchInfiniteQuery-CRwRctQH.d.cts} +1 -1
- package/dist/{usePrefetchInfiniteQuery-xFsVE7gF.d.mts.map → usePrefetchInfiniteQuery-CRwRctQH.d.cts.map} +1 -1
- package/dist/usePrefetchInfiniteQuery.d.cts +1 -1
- package/dist/usePrefetchInfiniteQuery.d.mts +1 -1
- package/dist/usePrefetchInfiniteQuery.mjs +1 -1
- package/dist/{usePrefetchQuery-CIIwQHYI.d.mts → usePrefetchQuery-38O319FT.d.mts} +1 -1
- package/dist/{usePrefetchQuery-CIIwQHYI.d.mts.map → usePrefetchQuery-38O319FT.d.mts.map} +1 -1
- package/dist/{usePrefetchQuery-DoUOJZwe.d.cts → usePrefetchQuery-93Pltnzl.d.cts} +1 -1
- package/dist/{usePrefetchQuery-DoUOJZwe.d.cts.map → usePrefetchQuery-93Pltnzl.d.cts.map} +1 -1
- package/dist/{usePrefetchQuery-RuK6ZS1I.mjs → usePrefetchQuery-CtrJciA6.mjs} +1 -1
- package/dist/{usePrefetchQuery-RuK6ZS1I.mjs.map → usePrefetchQuery-CtrJciA6.mjs.map} +1 -1
- package/dist/usePrefetchQuery.d.cts +1 -1
- package/dist/usePrefetchQuery.d.mts +1 -1
- package/dist/usePrefetchQuery.mjs +1 -1
- package/dist/{useSuspenseInfiniteQuery-CMhbiMDc.d.cts → useSuspenseInfiniteQuery-Bh0nh8Kc.d.mts} +1 -1
- package/dist/{useSuspenseInfiniteQuery-CMhbiMDc.d.cts.map → useSuspenseInfiniteQuery-Bh0nh8Kc.d.mts.map} +1 -1
- package/dist/{useSuspenseInfiniteQuery-CbW_Lnv4.cjs → useSuspenseInfiniteQuery-CA0jmgbX.cjs} +1 -1
- package/dist/{useSuspenseInfiniteQuery-CbW_Lnv4.cjs.map → useSuspenseInfiniteQuery-CA0jmgbX.cjs.map} +1 -1
- package/dist/{useSuspenseInfiniteQuery-BVmSR5yZ.mjs → useSuspenseInfiniteQuery-DUxKOkCo.mjs} +1 -1
- package/dist/{useSuspenseInfiniteQuery-BVmSR5yZ.mjs.map → useSuspenseInfiniteQuery-DUxKOkCo.mjs.map} +1 -1
- package/dist/{useSuspenseInfiniteQuery-Dvy7bTQq.d.mts → useSuspenseInfiniteQuery-xXu-A7cX.d.cts} +1 -1
- package/dist/{useSuspenseInfiniteQuery-Dvy7bTQq.d.mts.map → useSuspenseInfiniteQuery-xXu-A7cX.d.cts.map} +1 -1
- package/dist/useSuspenseInfiniteQuery.cjs +1 -1
- package/dist/useSuspenseInfiniteQuery.d.cts +1 -1
- package/dist/useSuspenseInfiniteQuery.d.mts +1 -1
- package/dist/useSuspenseInfiniteQuery.mjs +1 -1
- package/dist/{useSuspenseQueries-DqT8AKu2.mjs → useSuspenseQueries-Bf0lSTWB.mjs} +1 -1
- package/dist/{useSuspenseQueries-DqT8AKu2.mjs.map → useSuspenseQueries-Bf0lSTWB.mjs.map} +1 -1
- package/dist/{useSuspenseQueries-DFtL_xO-.d.mts → useSuspenseQueries-CHPLAyeb.d.cts} +1 -1
- package/dist/{useSuspenseQueries-DFtL_xO-.d.mts.map → useSuspenseQueries-CHPLAyeb.d.cts.map} +1 -1
- package/dist/{useSuspenseQueries-DE-hB5GR.cjs → useSuspenseQueries-DqBaOI3L.cjs} +1 -1
- package/dist/{useSuspenseQueries-DE-hB5GR.cjs.map → useSuspenseQueries-DqBaOI3L.cjs.map} +1 -1
- package/dist/{useSuspenseQueries-DNZH-duj.d.cts → useSuspenseQueries-pfI8hFSM.d.mts} +1 -1
- package/dist/{useSuspenseQueries-DNZH-duj.d.cts.map → useSuspenseQueries-pfI8hFSM.d.mts.map} +1 -1
- package/dist/useSuspenseQueries.cjs +1 -1
- package/dist/useSuspenseQueries.d.cts +1 -1
- package/dist/useSuspenseQueries.d.mts +1 -1
- package/dist/useSuspenseQueries.mjs +1 -1
- package/dist/{useSuspenseQuery-B7HJXyZL.cjs → useSuspenseQuery-41ONxa6i.cjs} +1 -1
- package/dist/{useSuspenseQuery-B7HJXyZL.cjs.map → useSuspenseQuery-41ONxa6i.cjs.map} +1 -1
- package/dist/{useSuspenseQuery-BvMsQ1Ho.mjs → useSuspenseQuery-CVWQeHhd.mjs} +1 -1
- package/dist/{useSuspenseQuery-BvMsQ1Ho.mjs.map → useSuspenseQuery-CVWQeHhd.mjs.map} +1 -1
- package/dist/{useSuspenseQuery-07kIGch-.d.cts → useSuspenseQuery-DG0Jz1Da.d.mts} +1 -1
- package/dist/{useSuspenseQuery-07kIGch-.d.cts.map → useSuspenseQuery-DG0Jz1Da.d.mts.map} +1 -1
- package/dist/{useSuspenseQuery-CMEH7kZ8.d.mts → useSuspenseQuery-DiNomNWA.d.cts} +1 -1
- package/dist/{useSuspenseQuery-CMEH7kZ8.d.mts.map → useSuspenseQuery-DiNomNWA.d.cts.map} +1 -1
- package/dist/useSuspenseQuery.cjs +1 -1
- package/dist/useSuspenseQuery.d.cts +1 -1
- package/dist/useSuspenseQuery.d.mts +1 -1
- package/dist/useSuspenseQuery.mjs +1 -1
- package/package.json +3 -3
- package/src/QueriesHydration.spec.tsx +257 -0
- package/src/QueriesHydration.test-d.tsx +76 -0
- package/src/createGetQueryClient.spec.tsx +118 -0
- package/src/createGetQueryClient.test-d.tsx +14 -0
- package/src/createGetQueryClient.ts +78 -0
- package/src/index.ts +1 -0
- /package/dist/{objectWithoutProperties-VHBPpeSg.mjs → objectWithoutProperties-MpQDFxYs.mjs} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSuspenseQuery-
|
|
1
|
+
{"version":3,"file":"useSuspenseQuery-CVWQeHhd.mjs","names":["useSuspenseQuery","original_useSuspenseQuery"],"sources":["../src/useSuspenseQuery.ts"],"sourcesContent":["'use client'\n\nimport {\n type UseSuspenseQueryOptions as original_UseSuspenseQueryOptions,\n type UseSuspenseQueryResult as original_UseSuspenseQueryResult,\n useSuspenseQuery as original_useSuspenseQuery,\n} from '@tanstack/react-query'\n\n/**\n * This feature is officially supported in \\@tanstack/react-query@^4.40.0, You can proceed with the migration.\n * @deprecated Use `UseSuspenseQueryOptions` from \\@tanstack/react-query@^4.40.0\n * @example\n * ```diff\n * - import type { UseSuspenseQueryOptions } from '@suspensive/react-query'\n * + import type { UseSuspenseQueryOptions } from '@tanstack/react-query'\n * ```\n */\nexport type UseSuspenseQueryOptions = original_UseSuspenseQueryOptions\n\n/**\n * This feature is officially supported in \\@tanstack/react-query@^4.40.0, You can proceed with the migration.\n * @deprecated Use `UseSuspenseQueryResult` from \\@tanstack/react-query@^4.40.0\n * @example\n * ```diff\n * - import type { UseSuspenseQueryResult } from '@suspensive/react-query'\n * + import type { UseSuspenseQueryResult } from '@tanstack/react-query'\n * ```\n */\nexport type UseSuspenseQueryResult = original_UseSuspenseQueryResult\n\n/**\n * This feature is officially supported in \\@tanstack/react-query@^4.40.0, You can proceed with the migration.\n * @deprecated Use `useSuspenseQuery` from \\@tanstack/react-query@^4.40.0\n * @example\n * ```diff\n * - import { useSuspenseQuery } from '@suspensive/react-query'\n * + import { useSuspenseQuery } from '@tanstack/react-query'\n * ```\n */\nexport const useSuspenseQuery = original_useSuspenseQuery\n"],"mappings":";;;;;;;;;;;;AAuCA,MAAaA,qBAAmBC"}
|
|
@@ -34,4 +34,4 @@ type UseSuspenseQueryResult$1 = UseSuspenseQueryResult;
|
|
|
34
34
|
declare const useSuspenseQuery$1: typeof useSuspenseQuery;
|
|
35
35
|
//#endregion
|
|
36
36
|
export { UseSuspenseQueryResult$1 as n, useSuspenseQuery$1 as r, UseSuspenseQueryOptions$1 as t };
|
|
37
|
-
//# sourceMappingURL=useSuspenseQuery-
|
|
37
|
+
//# sourceMappingURL=useSuspenseQuery-DG0Jz1Da.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSuspenseQuery-
|
|
1
|
+
{"version":3,"file":"useSuspenseQuery-DG0Jz1Da.d.mts","names":[],"sources":["../src/useSuspenseQuery.ts"],"sourcesContent":[],"mappings":";;;;;;AAiBA;AAWA;AAWA;;;;;KAtBY,yBAAA,GAA0B;;;;;;;;;;KAW1B,wBAAA,GAAyB;;;;;;;;;;cAWxB,2BAAgB"}
|
|
@@ -34,4 +34,4 @@ type UseSuspenseQueryResult$1 = UseSuspenseQueryResult;
|
|
|
34
34
|
declare const useSuspenseQuery$1: typeof useSuspenseQuery;
|
|
35
35
|
//#endregion
|
|
36
36
|
export { UseSuspenseQueryResult$1 as n, useSuspenseQuery$1 as r, UseSuspenseQueryOptions$1 as t };
|
|
37
|
-
//# sourceMappingURL=useSuspenseQuery-
|
|
37
|
+
//# sourceMappingURL=useSuspenseQuery-DiNomNWA.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSuspenseQuery-
|
|
1
|
+
{"version":3,"file":"useSuspenseQuery-DiNomNWA.d.cts","names":[],"sources":["../src/useSuspenseQuery.ts"],"sourcesContent":[],"mappings":";;;;;;AAiBA;AAWA;AAWA;;;;;KAtBY,yBAAA,GAA0B;;;;;;;;;;KAW1B,wBAAA,GAAyB;;;;;;;;;;cAWxB,2BAAgB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as UseSuspenseQueryResult, r as useSuspenseQuery, t as UseSuspenseQueryOptions } from "./useSuspenseQuery-
|
|
1
|
+
import { n as UseSuspenseQueryResult, r as useSuspenseQuery, t as UseSuspenseQueryOptions } from "./useSuspenseQuery-DiNomNWA.cjs";
|
|
2
2
|
export { UseSuspenseQueryOptions, UseSuspenseQueryResult, useSuspenseQuery };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as UseSuspenseQueryResult, r as useSuspenseQuery, t as UseSuspenseQueryOptions } from "./useSuspenseQuery-
|
|
1
|
+
import { n as UseSuspenseQueryResult, r as useSuspenseQuery, t as UseSuspenseQueryOptions } from "./useSuspenseQuery-DG0Jz1Da.mjs";
|
|
2
2
|
export { UseSuspenseQueryOptions, UseSuspenseQueryResult, useSuspenseQuery };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suspensive/react-query-4",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.17.0",
|
|
4
4
|
"description": "Suspensive interfaces for @tanstack/react-query@4",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"suspensive",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
],
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@tanstack/react-query": "4.42.0",
|
|
43
|
-
"@types/react": "^19.
|
|
44
|
-
"react": "^19.
|
|
43
|
+
"@types/react": "^19.2.5",
|
|
44
|
+
"react": "^19.2.0",
|
|
45
45
|
"@suspensive/eslint-config": "0.0.1",
|
|
46
46
|
"@suspensive/tsconfig": "0.0.0-development",
|
|
47
47
|
"@suspensive/tsdown": "0.0.0"
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { QueryClient, dehydrate } from '@tanstack/react-query'
|
|
2
|
+
import { render, screen } from '@testing-library/react'
|
|
3
|
+
import type { ComponentProps, ReactNode } from 'react'
|
|
4
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
5
|
+
import { QueriesHydration } from './QueriesHydration'
|
|
6
|
+
|
|
7
|
+
// Mock the ClientOnly component
|
|
8
|
+
vi.mock('./components/ClientOnly', () => ({
|
|
9
|
+
ClientOnly: ({ children, fallback }: { children: ReactNode; fallback?: ReactNode }) => (
|
|
10
|
+
<div data-testid="client-only">{fallback || children}</div>
|
|
11
|
+
),
|
|
12
|
+
}))
|
|
13
|
+
|
|
14
|
+
describe('<QueriesHydration/>', () => {
|
|
15
|
+
it('should fetch queries and hydrate them successfully', async () => {
|
|
16
|
+
const queryClient = new QueryClient()
|
|
17
|
+
const mockQueryFn = vi.fn().mockResolvedValue({ data: 'test-data' })
|
|
18
|
+
|
|
19
|
+
const queries = [
|
|
20
|
+
{
|
|
21
|
+
queryKey: ['test-query'],
|
|
22
|
+
queryFn: mockQueryFn,
|
|
23
|
+
},
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
const result = await QueriesHydration({
|
|
27
|
+
queries,
|
|
28
|
+
queryClient,
|
|
29
|
+
children: <div>Test Children</div>,
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
expect(mockQueryFn).toHaveBeenCalledTimes(1)
|
|
33
|
+
expect(result).toBeDefined()
|
|
34
|
+
expect(result.type).toBeDefined()
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
it('should handle multiple queries', async () => {
|
|
38
|
+
const queryClient = new QueryClient()
|
|
39
|
+
const mockQueryFn1 = vi.fn().mockResolvedValue({ data: 'data-1' })
|
|
40
|
+
const mockQueryFn2 = vi.fn().mockResolvedValue({ data: 'data-2' })
|
|
41
|
+
|
|
42
|
+
const queries = [
|
|
43
|
+
{
|
|
44
|
+
queryKey: ['query-1'],
|
|
45
|
+
queryFn: mockQueryFn1,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
queryKey: ['query-2'],
|
|
49
|
+
queryFn: mockQueryFn2,
|
|
50
|
+
},
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
const result = await QueriesHydration({
|
|
54
|
+
queries,
|
|
55
|
+
queryClient,
|
|
56
|
+
children: <div>Test Children</div>,
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
expect(mockQueryFn1).toHaveBeenCalledTimes(1)
|
|
60
|
+
expect(mockQueryFn2).toHaveBeenCalledTimes(1)
|
|
61
|
+
expect(result).toBeDefined()
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it('should skip SSR and render ClientOnly when query fails and skipSsrOnError is true (default)', async () => {
|
|
65
|
+
const queryClient = new QueryClient()
|
|
66
|
+
const mockQueryFn = vi.fn().mockRejectedValue(new Error('Query failed'))
|
|
67
|
+
|
|
68
|
+
const queries = [
|
|
69
|
+
{
|
|
70
|
+
queryKey: ['failing-query'],
|
|
71
|
+
queryFn: mockQueryFn,
|
|
72
|
+
},
|
|
73
|
+
]
|
|
74
|
+
|
|
75
|
+
const result = await QueriesHydration({
|
|
76
|
+
queries,
|
|
77
|
+
queryClient,
|
|
78
|
+
children: <div>Test Children</div>,
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
expect(mockQueryFn).toHaveBeenCalledTimes(1)
|
|
82
|
+
|
|
83
|
+
// Render the result to verify it's ClientOnly
|
|
84
|
+
render(result as React.ReactElement)
|
|
85
|
+
expect(screen.getByTestId('client-only')).toBeInTheDocument()
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
it('should skip SSR and render ClientOnly when query fails and skipSsrOnError is explicitly true', async () => {
|
|
89
|
+
const queryClient = new QueryClient()
|
|
90
|
+
const mockQueryFn = vi.fn().mockRejectedValue(new Error('Query failed'))
|
|
91
|
+
|
|
92
|
+
const queries = [
|
|
93
|
+
{
|
|
94
|
+
queryKey: ['failing-query'],
|
|
95
|
+
queryFn: mockQueryFn,
|
|
96
|
+
},
|
|
97
|
+
]
|
|
98
|
+
|
|
99
|
+
const result = await QueriesHydration({
|
|
100
|
+
queries,
|
|
101
|
+
queryClient,
|
|
102
|
+
skipSsrOnError: true,
|
|
103
|
+
children: <div>Test Children</div>,
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
expect(mockQueryFn).toHaveBeenCalledTimes(1)
|
|
107
|
+
|
|
108
|
+
render(result as React.ReactElement)
|
|
109
|
+
expect(screen.getByTestId('client-only')).toBeInTheDocument()
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
it('should show custom fallback when query fails and skipSsrOnError has fallback', async () => {
|
|
113
|
+
const queryClient = new QueryClient()
|
|
114
|
+
const mockQueryFn = vi.fn().mockRejectedValue(new Error('Query failed'))
|
|
115
|
+
|
|
116
|
+
const queries = [
|
|
117
|
+
{
|
|
118
|
+
queryKey: ['failing-query'],
|
|
119
|
+
queryFn: mockQueryFn,
|
|
120
|
+
},
|
|
121
|
+
]
|
|
122
|
+
|
|
123
|
+
const customFallback = <div>Custom Fallback</div>
|
|
124
|
+
|
|
125
|
+
const result = await QueriesHydration({
|
|
126
|
+
queries,
|
|
127
|
+
queryClient,
|
|
128
|
+
skipSsrOnError: { fallback: customFallback },
|
|
129
|
+
children: <div>Test Children</div>,
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
expect(mockQueryFn).toHaveBeenCalledTimes(1)
|
|
133
|
+
|
|
134
|
+
render(result as React.ReactElement)
|
|
135
|
+
expect(screen.getByTestId('client-only')).toBeInTheDocument()
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
it('should proceed with SSR without hydration when query fails and skipSsrOnError is false', async () => {
|
|
139
|
+
const queryClient = new QueryClient()
|
|
140
|
+
const mockQueryFn = vi.fn().mockRejectedValue(new Error('Query failed'))
|
|
141
|
+
|
|
142
|
+
const queries = [
|
|
143
|
+
{
|
|
144
|
+
queryKey: ['failing-query'],
|
|
145
|
+
queryFn: mockQueryFn,
|
|
146
|
+
},
|
|
147
|
+
]
|
|
148
|
+
|
|
149
|
+
const result = await QueriesHydration({
|
|
150
|
+
queries,
|
|
151
|
+
queryClient,
|
|
152
|
+
skipSsrOnError: false,
|
|
153
|
+
children: <div>Test Children</div>,
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
expect(mockQueryFn).toHaveBeenCalledTimes(1)
|
|
157
|
+
|
|
158
|
+
// When skipSsrOnError is false, it should still render Hydrate component
|
|
159
|
+
// even though the query failed
|
|
160
|
+
expect(result).toBeDefined()
|
|
161
|
+
expect(result.type).toBeDefined()
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
it('should handle partial query failures when skipSsrOnError is false', async () => {
|
|
165
|
+
const queryClient = new QueryClient()
|
|
166
|
+
const mockSuccessQueryFn = vi.fn().mockResolvedValue({ data: 'success' })
|
|
167
|
+
const mockFailQueryFn = vi.fn().mockRejectedValue(new Error('Query failed'))
|
|
168
|
+
|
|
169
|
+
const queries = [
|
|
170
|
+
{
|
|
171
|
+
queryKey: ['success-query'],
|
|
172
|
+
queryFn: mockSuccessQueryFn,
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
queryKey: ['fail-query'],
|
|
176
|
+
queryFn: mockFailQueryFn,
|
|
177
|
+
},
|
|
178
|
+
]
|
|
179
|
+
|
|
180
|
+
const result = await QueriesHydration({
|
|
181
|
+
queries,
|
|
182
|
+
queryClient,
|
|
183
|
+
skipSsrOnError: false,
|
|
184
|
+
children: <div>Test Children</div>,
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
// Promise.all rejects if any promise rejects
|
|
188
|
+
expect(mockSuccessQueryFn).toHaveBeenCalledTimes(1)
|
|
189
|
+
expect(mockFailQueryFn).toHaveBeenCalledTimes(1)
|
|
190
|
+
expect(result).toBeDefined()
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
it('should use default QueryClient when queryClient prop is not provided', async () => {
|
|
194
|
+
const mockQueryFn = vi.fn().mockResolvedValue({ data: 'test-data' })
|
|
195
|
+
|
|
196
|
+
const queries = [
|
|
197
|
+
{
|
|
198
|
+
queryKey: ['test-query'],
|
|
199
|
+
queryFn: mockQueryFn,
|
|
200
|
+
},
|
|
201
|
+
]
|
|
202
|
+
|
|
203
|
+
const result = await QueriesHydration({
|
|
204
|
+
queries,
|
|
205
|
+
children: <div>Test Children</div>,
|
|
206
|
+
})
|
|
207
|
+
|
|
208
|
+
expect(mockQueryFn).toHaveBeenCalledTimes(1)
|
|
209
|
+
expect(result).toBeDefined()
|
|
210
|
+
})
|
|
211
|
+
|
|
212
|
+
it('should pass additional Hydrate props through', async () => {
|
|
213
|
+
const queryClient = new QueryClient()
|
|
214
|
+
const mockQueryFn = vi.fn().mockResolvedValue({ data: 'test-data' })
|
|
215
|
+
|
|
216
|
+
const queries = [
|
|
217
|
+
{
|
|
218
|
+
queryKey: ['test-query'],
|
|
219
|
+
queryFn: mockQueryFn,
|
|
220
|
+
},
|
|
221
|
+
]
|
|
222
|
+
|
|
223
|
+
const result = await QueriesHydration({
|
|
224
|
+
queries,
|
|
225
|
+
queryClient,
|
|
226
|
+
children: <div>Test Children</div>,
|
|
227
|
+
// Additional props that should be passed to Hydrate
|
|
228
|
+
} as ComponentProps<typeof QueriesHydration>)
|
|
229
|
+
|
|
230
|
+
expect(mockQueryFn).toHaveBeenCalledTimes(1)
|
|
231
|
+
expect(result).toBeDefined()
|
|
232
|
+
})
|
|
233
|
+
|
|
234
|
+
it('should dehydrate query state correctly', async () => {
|
|
235
|
+
const queryClient = new QueryClient()
|
|
236
|
+
const mockData = { data: 'test-data' }
|
|
237
|
+
const mockQueryFn = vi.fn().mockResolvedValue(mockData)
|
|
238
|
+
|
|
239
|
+
const queries = [
|
|
240
|
+
{
|
|
241
|
+
queryKey: ['test-query'],
|
|
242
|
+
queryFn: mockQueryFn,
|
|
243
|
+
},
|
|
244
|
+
]
|
|
245
|
+
|
|
246
|
+
await QueriesHydration({
|
|
247
|
+
queries,
|
|
248
|
+
queryClient,
|
|
249
|
+
children: <div>Test Children</div>,
|
|
250
|
+
})
|
|
251
|
+
|
|
252
|
+
const dehydratedState = dehydrate(queryClient)
|
|
253
|
+
expect(dehydratedState.queries).toHaveLength(1)
|
|
254
|
+
expect(dehydratedState.queries[0].queryKey).toEqual(['test-query'])
|
|
255
|
+
expect(dehydratedState.queries[0].state.data).toEqual(mockData)
|
|
256
|
+
})
|
|
257
|
+
})
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { QueryClient, queryOptions } from '@tanstack/react-query'
|
|
2
|
+
import { describe, expectTypeOf, it } from 'vitest'
|
|
3
|
+
import { QueriesHydration } from './QueriesHydration'
|
|
4
|
+
import { queryFn, queryKey } from './test-utils'
|
|
5
|
+
|
|
6
|
+
describe('<QueriesHydration/>', () => {
|
|
7
|
+
it('type check', () => {
|
|
8
|
+
const options1 = queryOptions({
|
|
9
|
+
queryKey: ['query1'],
|
|
10
|
+
queryFn: queryFn,
|
|
11
|
+
})
|
|
12
|
+
const options2 = queryOptions({
|
|
13
|
+
queryKey: ['query2'],
|
|
14
|
+
queryFn: queryFn,
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
// Should accept queries array with queryKey
|
|
18
|
+
void (async () =>
|
|
19
|
+
await QueriesHydration({
|
|
20
|
+
queries: [
|
|
21
|
+
{
|
|
22
|
+
queryKey: queryKey,
|
|
23
|
+
queryFn: queryFn,
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
children: <></>,
|
|
27
|
+
}))()
|
|
28
|
+
|
|
29
|
+
// Should accept multiple queries
|
|
30
|
+
void (async () =>
|
|
31
|
+
await QueriesHydration({
|
|
32
|
+
queries: [options1, options2],
|
|
33
|
+
children: <></>,
|
|
34
|
+
}))()
|
|
35
|
+
|
|
36
|
+
// Should accept skipSsrOnError as boolean
|
|
37
|
+
void (async () =>
|
|
38
|
+
await QueriesHydration({
|
|
39
|
+
queries: [options1],
|
|
40
|
+
skipSsrOnError: true,
|
|
41
|
+
children: <></>,
|
|
42
|
+
}))()
|
|
43
|
+
|
|
44
|
+
// Should accept skipSsrOnError with fallback
|
|
45
|
+
void (async () =>
|
|
46
|
+
await QueriesHydration({
|
|
47
|
+
queries: [options1],
|
|
48
|
+
skipSsrOnError: { fallback: <div>Loading...</div> },
|
|
49
|
+
children: <></>,
|
|
50
|
+
}))()
|
|
51
|
+
|
|
52
|
+
// Should accept undefined queryClient prop
|
|
53
|
+
void (async () =>
|
|
54
|
+
await QueriesHydration({
|
|
55
|
+
queries: [options1],
|
|
56
|
+
queryClient: undefined,
|
|
57
|
+
children: <></>,
|
|
58
|
+
}))()
|
|
59
|
+
|
|
60
|
+
// Should accept QueryClient instance for queryClient prop
|
|
61
|
+
void (async () =>
|
|
62
|
+
await QueriesHydration({
|
|
63
|
+
queries: [options1],
|
|
64
|
+
queryClient: new QueryClient(),
|
|
65
|
+
children: <></>,
|
|
66
|
+
}))()
|
|
67
|
+
|
|
68
|
+
// Return type should be JSX.Element (Promise<JSX.Element>)
|
|
69
|
+
expectTypeOf(
|
|
70
|
+
QueriesHydration({
|
|
71
|
+
queries: [options1],
|
|
72
|
+
children: <></>,
|
|
73
|
+
})
|
|
74
|
+
).toEqualTypeOf<Promise<React.JSX.Element>>()
|
|
75
|
+
})
|
|
76
|
+
})
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { QueryClient } from '@tanstack/react-query'
|
|
2
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
3
|
+
|
|
4
|
+
// Mock isServer from @tanstack/react-query
|
|
5
|
+
vi.mock('@tanstack/react-query', async () => {
|
|
6
|
+
const actual = await vi.importActual('@tanstack/react-query')
|
|
7
|
+
return {
|
|
8
|
+
...actual,
|
|
9
|
+
isServer: false,
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
describe('getQueryClient', () => {
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
// Reset modules to clear the browserQueryClient singleton
|
|
16
|
+
vi.resetModules()
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it('should return a QueryClient instance', async () => {
|
|
20
|
+
const { createGetQueryClient } = await import('./createGetQueryClient')
|
|
21
|
+
const { getQueryClient } = createGetQueryClient()
|
|
22
|
+
const queryClient = getQueryClient()
|
|
23
|
+
expect(queryClient).toBeInstanceOf(QueryClient)
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it('should return the same QueryClient instance on multiple calls in browser environment', async () => {
|
|
27
|
+
const { createGetQueryClient } = await import('./createGetQueryClient')
|
|
28
|
+
const { getQueryClient } = createGetQueryClient()
|
|
29
|
+
const queryClient1 = getQueryClient()
|
|
30
|
+
const queryClient2 = getQueryClient()
|
|
31
|
+
expect(queryClient1).toBe(queryClient2)
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('should apply config when creating initial QueryClient', async () => {
|
|
35
|
+
const { createGetQueryClient } = await import('./createGetQueryClient')
|
|
36
|
+
const { getQueryClient } = createGetQueryClient({
|
|
37
|
+
defaultOptions: {
|
|
38
|
+
queries: {
|
|
39
|
+
staleTime: 5000,
|
|
40
|
+
retry: 3,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
})
|
|
44
|
+
const queryClient = getQueryClient()
|
|
45
|
+
expect(queryClient).toBeInstanceOf(QueryClient)
|
|
46
|
+
expect(queryClient.getDefaultOptions().queries?.staleTime).toBe(5000)
|
|
47
|
+
expect(queryClient.getDefaultOptions().queries?.retry).toBe(3)
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it('should use provided cacheTime value in browser environment (not Infinity)', async () => {
|
|
51
|
+
const { createGetQueryClient } = await import('./createGetQueryClient')
|
|
52
|
+
const { getQueryClient } = createGetQueryClient({
|
|
53
|
+
defaultOptions: {
|
|
54
|
+
queries: {
|
|
55
|
+
cacheTime: 5000,
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
})
|
|
59
|
+
const queryClient = getQueryClient()
|
|
60
|
+
// In browser, cacheTime should use the provided value, not Infinity
|
|
61
|
+
expect(queryClient.getDefaultOptions().queries?.cacheTime).toBe(5000)
|
|
62
|
+
expect(queryClient.getDefaultOptions().queries?.cacheTime).not.toBe(Infinity)
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
it('should not set cacheTime to Infinity in browser environment when no config provided', async () => {
|
|
66
|
+
const { createGetQueryClient } = await import('./createGetQueryClient')
|
|
67
|
+
const { getQueryClient } = createGetQueryClient()
|
|
68
|
+
const queryClient = getQueryClient()
|
|
69
|
+
// In browser, cacheTime should use default value (not Infinity)
|
|
70
|
+
// Default cacheTime in React Query v4 is 5 minutes (300000ms)
|
|
71
|
+
expect(queryClient.getDefaultOptions().queries?.cacheTime).not.toBe(Infinity)
|
|
72
|
+
})
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
describe('getQueryClient (server environment)', () => {
|
|
76
|
+
beforeEach(() => {
|
|
77
|
+
vi.resetModules()
|
|
78
|
+
// Mock isServer as true for server tests
|
|
79
|
+
vi.doMock('@tanstack/react-query', async () => {
|
|
80
|
+
const actual = await vi.importActual('@tanstack/react-query')
|
|
81
|
+
return {
|
|
82
|
+
...actual,
|
|
83
|
+
isServer: true,
|
|
84
|
+
}
|
|
85
|
+
})
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
it('should return new QueryClient instance on each call in server environment', async () => {
|
|
89
|
+
const { createGetQueryClient } = await import('./createGetQueryClient')
|
|
90
|
+
const { getQueryClient } = createGetQueryClient()
|
|
91
|
+
const queryClient1 = getQueryClient()
|
|
92
|
+
const queryClient2 = getQueryClient()
|
|
93
|
+
expect(queryClient1).toBeInstanceOf(QueryClient)
|
|
94
|
+
expect(queryClient2).toBeInstanceOf(QueryClient)
|
|
95
|
+
expect(queryClient1).not.toBe(queryClient2)
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
it('should set cacheTime to Infinity in server environment to prevent OOM', async () => {
|
|
99
|
+
const { createGetQueryClient } = await import('./createGetQueryClient')
|
|
100
|
+
const { getQueryClient } = createGetQueryClient()
|
|
101
|
+
const queryClient = getQueryClient()
|
|
102
|
+
expect(queryClient.getDefaultOptions().queries?.cacheTime).toBe(Infinity)
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
it('should override cacheTime to Infinity even if config provides different value in server environment', async () => {
|
|
106
|
+
const { createGetQueryClient } = await import('./createGetQueryClient')
|
|
107
|
+
const { getQueryClient } = createGetQueryClient({
|
|
108
|
+
defaultOptions: {
|
|
109
|
+
queries: {
|
|
110
|
+
cacheTime: 5000,
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
})
|
|
114
|
+
const queryClient = getQueryClient()
|
|
115
|
+
// cacheTime should be Infinity regardless of config to prevent OOM on server
|
|
116
|
+
expect(queryClient.getDefaultOptions().queries?.cacheTime).toBe(Infinity)
|
|
117
|
+
})
|
|
118
|
+
})
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { QueryClient } from '@tanstack/react-query'
|
|
2
|
+
import { createGetQueryClient } from './createGetQueryClient'
|
|
3
|
+
|
|
4
|
+
describe('getQueryClient', () => {
|
|
5
|
+
it('type check', () => {
|
|
6
|
+
const { getQueryClient } = createGetQueryClient({ defaultOptions: { queries: { staleTime: 5000 } } })
|
|
7
|
+
|
|
8
|
+
const queryClient = getQueryClient()
|
|
9
|
+
expectTypeOf(queryClient).toEqualTypeOf<QueryClient>()
|
|
10
|
+
|
|
11
|
+
const queryClientWithConfig = getQueryClient()
|
|
12
|
+
expectTypeOf(queryClientWithConfig).toEqualTypeOf<QueryClient>()
|
|
13
|
+
})
|
|
14
|
+
})
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { QueryClient, type QueryClientConfig, isServer } from '@tanstack/react-query'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Creates a function that returns a QueryClient instance, with different behavior for server and client environments.
|
|
5
|
+
*
|
|
6
|
+
* On the server, it always creates a new QueryClient instance with `cacheTime: Infinity` to prevent data from being garbage collected.
|
|
7
|
+
* On the client, it reuses the same QueryClient instance to avoid recreating it during React's initial render suspension.
|
|
8
|
+
*
|
|
9
|
+
* @experimental This component is experimental and may be changed or removed in the future.
|
|
10
|
+
*
|
|
11
|
+
* @param config - Optional QueryClient configuration. On the server, `cacheTime` will be automatically set to `Infinity`.
|
|
12
|
+
* @returns An object containing a `getQueryClient` function that returns a QueryClient instance.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* // Create a get-query-client.ts file in your project:
|
|
17
|
+
* // get-query-client.ts
|
|
18
|
+
* import { createGetQueryClient } from '@suspensive/react-query'
|
|
19
|
+
*
|
|
20
|
+
* export const { getQueryClient } = createGetQueryClient()
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* // Then import and use it in your code:
|
|
25
|
+
* // app/providers.tsx
|
|
26
|
+
* 'use client'
|
|
27
|
+
*
|
|
28
|
+
* import { QueryClientProvider } from '@tanstack/react-query'
|
|
29
|
+
* import { ReactQueryDevtools } from '@tanstack/react-query-devtools'
|
|
30
|
+
* import { getQueryClient } from '@/app/get-query-client'
|
|
31
|
+
* import type * as React from 'react'
|
|
32
|
+
*
|
|
33
|
+
* export default function Providers({ children }: { children: React.ReactNode }) {
|
|
34
|
+
* const queryClient = getQueryClient()
|
|
35
|
+
*
|
|
36
|
+
* return (
|
|
37
|
+
* <QueryClientProvider client={queryClient}>
|
|
38
|
+
* {children}
|
|
39
|
+
* <ReactQueryDevtools />
|
|
40
|
+
* </QueryClientProvider>
|
|
41
|
+
* )
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @see {@link https://suspensive.org/docs/react-query/createGetQueryClient Suspensive Docs}
|
|
46
|
+
*/
|
|
47
|
+
export function createGetQueryClient(config: QueryClientConfig = {}) {
|
|
48
|
+
let browserQueryClient: QueryClient | undefined
|
|
49
|
+
const getQueryClientConfig: QueryClientConfig = isServer
|
|
50
|
+
? {
|
|
51
|
+
...config,
|
|
52
|
+
defaultOptions: {
|
|
53
|
+
...config.defaultOptions,
|
|
54
|
+
queries: {
|
|
55
|
+
...config.defaultOptions?.queries,
|
|
56
|
+
cacheTime: Infinity,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
}
|
|
60
|
+
: config
|
|
61
|
+
|
|
62
|
+
function getQueryClient() {
|
|
63
|
+
if (isServer) {
|
|
64
|
+
// Server: always make a new query client
|
|
65
|
+
return new QueryClient(getQueryClientConfig)
|
|
66
|
+
}
|
|
67
|
+
// Browser: make a new query client if we don't already have one
|
|
68
|
+
// This is very important, so we don't re-make a new client if React
|
|
69
|
+
// suspends during the initial render. This may not be needed if we
|
|
70
|
+
// have a suspense boundary BELOW the creation of the query client
|
|
71
|
+
if (!browserQueryClient) {
|
|
72
|
+
browserQueryClient = new QueryClient(getQueryClientConfig)
|
|
73
|
+
}
|
|
74
|
+
return browserQueryClient
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return { getQueryClient }
|
|
78
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { createGetQueryClient } from './createGetQueryClient'
|
|
1
2
|
export { infiniteQueryOptions } from './infiniteQueryOptions'
|
|
2
3
|
export type { SelectedInfiniteOptions, UnSelectedInfiniteOptions } from './infiniteQueryOptions'
|
|
3
4
|
export { QueriesHydration } from './QueriesHydration'
|
|
File without changes
|