@tanstack/solid-query 6.0.0-rc.0 → 6.0.0-rc.1
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/README.md +15 -1
- package/build/_tsup-dts-rollup.d.cts +150 -157
- package/build/_tsup-dts-rollup.d.ts +150 -157
- package/build/dev.cjs +718 -559
- package/build/dev.d.cts +0 -22
- package/build/dev.d.ts +0 -22
- package/build/dev.js +721 -559
- package/build/index.cjs +718 -550
- package/build/index.d.cts +0 -22
- package/build/index.d.ts +0 -22
- package/build/index.js +721 -550
- package/package.json +6 -6
- package/src/QueryClient.ts +24 -45
- package/src/QueryClientProvider.tsx +77 -58
- package/src/cacheAggregate.ts +90 -0
- package/src/index.ts +1 -29
- package/src/types.ts +62 -44
- package/src/useBaseQuery.ts +674 -412
- package/src/useInfiniteQuery.ts +156 -4
- package/src/useIsFetching.ts +6 -16
- package/src/useIsMutating.ts +6 -16
- package/src/useMutation.ts +304 -57
- package/src/useMutationState.ts +9 -22
- package/src/useQueries.ts +61 -110
- package/src/hydrationChannel.ts +0 -260
package/README.md
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
<img src="https://static.scarf.sh/a.png?x-pxid=be2d8a11-9712-4c1d-9963-580b2d4fb133" />
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<picture>
|
|
4
|
+
<source
|
|
5
|
+
media="(prefers-color-scheme: dark)"
|
|
6
|
+
srcset="https://tanstack.com/api/readme/query.png?framework=solid&theme=dark"
|
|
7
|
+
/>
|
|
8
|
+
<source
|
|
9
|
+
media="(prefers-color-scheme: light)"
|
|
10
|
+
srcset="https://tanstack.com/api/readme/query.png?framework=solid"
|
|
11
|
+
/>
|
|
12
|
+
<img
|
|
13
|
+
src="https://tanstack.com/api/readme/query.png?framework=solid"
|
|
14
|
+
alt="TanStack Solid Query"
|
|
15
|
+
width="900"
|
|
16
|
+
/>
|
|
17
|
+
</picture>
|
|
4
18
|
|
|
5
19
|
Hooks for fetching, caching and updating asynchronous data in Solid
|
|
6
20
|
|
|
@@ -143,54 +143,55 @@ import { WithRequired } from '@tanstack/query-core';
|
|
|
143
143
|
|
|
144
144
|
export { AnyDataTag }
|
|
145
145
|
|
|
146
|
+
/** Internal seam: everything the read layer builds, for hooks that extend
|
|
147
|
+
* the base result (`useInfiniteQuery` pagers ride the same entry). */
|
|
148
|
+
declare interface BaseQueryLayer<TQueryFnData, TError, TData, TQueryData, TQueryKey extends QueryKey> {
|
|
149
|
+
result: UseBaseQueryResult<TData, TError>;
|
|
150
|
+
observer: QueryObserver<TQueryFnData, TError, TData, TQueryData, TQueryKey>;
|
|
151
|
+
/** Version-tracked: reading it subscribes to this query's cache events. */
|
|
152
|
+
query: () => Query<TQueryFnData, TError, TQueryData, TQueryKey>;
|
|
153
|
+
defaultedOptions: Accessor<ReturnType<QueryClient['defaultQueryOptions']>>;
|
|
154
|
+
isFetching: () => boolean;
|
|
155
|
+
status: () => 'pending' | 'error' | 'success';
|
|
156
|
+
}
|
|
157
|
+
|
|
146
158
|
export { CancelledError }
|
|
147
159
|
|
|
148
160
|
export { CancelOptions }
|
|
149
161
|
|
|
150
162
|
/**
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
* early-hydrated components live while other boundaries still stream.
|
|
156
|
-
*/
|
|
157
|
-
export declare function createHydrationCoordinator(client: () => QueryClient): HydrationCoordinator;
|
|
158
|
-
|
|
159
|
-
export declare const createInfiniteQuery: typeof useInfiniteQuery;
|
|
160
|
-
|
|
161
|
-
export declare const createMutation: typeof useMutation;
|
|
162
|
-
|
|
163
|
-
export declare const createQueries: typeof useQueries;
|
|
164
|
-
|
|
165
|
-
export declare const createQuery: typeof useQuery;
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Server side of the library-owned serialization channel.
|
|
163
|
+
* Shared reactive core for the cross-cache aggregate hooks — `useIsFetching`,
|
|
164
|
+
* `useIsMutating`, `useMutationState` — which all reduce to "a value derived
|
|
165
|
+
* from a whole cache, refreshed on its events". Two invariants live here so
|
|
166
|
+
* each hook doesn't restate them:
|
|
169
167
|
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
168
|
+
* Dual write. Cache events can fire inside an action transaction
|
|
169
|
+
* (`useMutation` rides core `action`; an onSuccess invalidation dispatches
|
|
170
|
+
* refetches mid-action), where a plain signal write is held until settle —
|
|
171
|
+
* the in-flight value would be invisible. An optimistic override alone fails
|
|
172
|
+
* the other way: outside a transaction, overrides drop at batch end. So a
|
|
173
|
+
* durable signal carries committed state and an optimistic node tracks it as
|
|
174
|
+
* its base; in-transaction values surface through the override, and the held
|
|
175
|
+
* durable write becomes the base when the settle lands.
|
|
178
176
|
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
177
|
+
* Hydration. A cross-cache aggregate is not tied to a single async source,
|
|
178
|
+
* so it cannot ride the boundary contract per-query meta uses (suspend until
|
|
179
|
+
* settled). Its contract is fixed by construction instead: a hydrating
|
|
180
|
+
* client can only ever observe the empty value at claim time — its own
|
|
181
|
+
* fetches are held inside the hydration window, channel-primed entries are
|
|
182
|
+
* settled, and mutations do not transfer across SSR. So the server
|
|
183
|
+
* serializes the empty value, and a hydrated mount latches there until its
|
|
184
|
+
* window closes: the subscription and first sync run from an effect half,
|
|
185
|
+
* deferred past hydration — the earliest globally-safe moment for a
|
|
186
|
+
* cross-cache read to go live (on a streamed page, an already-hydrated
|
|
187
|
+
* region's refetch can be in flight while this region is still claiming).
|
|
189
188
|
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
189
|
+
* Every node here is created on the server too, where it is never read or
|
|
190
|
+
* written: hydration id assignment is positional, so both sides must create
|
|
191
|
+
* the same reactive nodes or every id downstream shifts and the subtree
|
|
192
|
+
* key-misses.
|
|
192
193
|
*/
|
|
193
|
-
export declare function
|
|
194
|
+
export declare function createCacheAggregate<T>(subscribe: (onEvent: () => void) => () => void, read: (prev: T) => T, empty: T): Accessor<T>;
|
|
194
195
|
|
|
195
196
|
export { DataTag }
|
|
196
197
|
|
|
@@ -232,57 +233,24 @@ export { DefinedInitialDataOptions as DefinedInitialDataOptions_alias_1 }
|
|
|
232
233
|
|
|
233
234
|
export { DefinedQueryObserverResult }
|
|
234
235
|
|
|
235
|
-
declare type DefinedUseBaseQueryResult<TData = unknown, TError = DefaultError> = DefinedQueryObserverResult<TData, TError
|
|
236
|
-
export { DefinedUseBaseQueryResult as DefinedCreateBaseQueryResult }
|
|
236
|
+
declare type DefinedUseBaseQueryResult<TData = unknown, TError = DefaultError> = OmitIsInitialLoading<DefinedQueryObserverResult<TData, TError>>;
|
|
237
237
|
export { DefinedUseBaseQueryResult }
|
|
238
238
|
export { DefinedUseBaseQueryResult as DefinedUseBaseQueryResult_alias_1 }
|
|
239
239
|
|
|
240
|
-
declare type DefinedUseInfiniteQueryResult<TData = unknown, TError = DefaultError> = DefinedInfiniteQueryObserverResult<TData, TError
|
|
241
|
-
export { DefinedUseInfiniteQueryResult as DefinedCreateInfiniteQueryResult }
|
|
240
|
+
declare type DefinedUseInfiniteQueryResult<TData = unknown, TError = DefaultError> = OmitIsInitialLoading<DefinedInfiniteQueryObserverResult<TData, TError>>;
|
|
242
241
|
export { DefinedUseInfiniteQueryResult }
|
|
243
242
|
export { DefinedUseInfiniteQueryResult as DefinedUseInfiniteQueryResult_alias_1 }
|
|
244
243
|
|
|
245
244
|
declare type DefinedUseQueryResult<TData = unknown, TError = DefaultError> = DefinedUseBaseQueryResult<TData, TError>;
|
|
246
|
-
export { DefinedUseQueryResult as DefinedCreateQueryResult }
|
|
247
245
|
export { DefinedUseQueryResult }
|
|
248
246
|
export { DefinedUseQueryResult as DefinedUseQueryResult_alias_1 }
|
|
249
247
|
|
|
250
248
|
export { dehydrate }
|
|
251
249
|
|
|
252
|
-
declare type DehydratedQueryEntry = DehydratedState['queries'][number];
|
|
253
|
-
|
|
254
250
|
export { DehydratedState }
|
|
255
251
|
|
|
256
252
|
export { DehydrateOptions }
|
|
257
253
|
|
|
258
|
-
/**
|
|
259
|
-
* A single message on the dehydration channel. `entries` is *cumulative* —
|
|
260
|
-
* every yield carries all entries settled so far. Two reasons:
|
|
261
|
-
*
|
|
262
|
-
* - It is what makes Solid's signal-path hydration replay lossless.
|
|
263
|
-
* Yields still buffered when hydration begins are conflated to the
|
|
264
|
-
* LATEST one (`normalizeIterator` drains synchronously available
|
|
265
|
-
* results, keeps the last data yield, and delivers the stream's done
|
|
266
|
-
* result on a subsequent pull), so each yield must be self-contained:
|
|
267
|
-
* the latest cumulative snapshot alone carries everything the dropped
|
|
268
|
-
* intermediates did. Requires the solid-js build with that conflation
|
|
269
|
-
* behavior (> 2.0.0-beta.32); earlier betas pinned the replay at the
|
|
270
|
-
* FIRST buffered yield, dropping every later entry and the `done`
|
|
271
|
-
* marker.
|
|
272
|
-
* - Entry objects keep their identity across yields, so seroval's
|
|
273
|
-
* cross-reference serialization emits each entry once and later yields
|
|
274
|
-
* only reference it — the cumulative shape costs bytes proportional to
|
|
275
|
-
* the number of entries, not its square.
|
|
276
|
-
*
|
|
277
|
-
* `done: true` marks the final yield. The client uses it to release
|
|
278
|
-
* subscribers still waiting for entries that will never arrive (e.g.
|
|
279
|
-
* queries that errored during SSR and were not dehydrated).
|
|
280
|
-
*/
|
|
281
|
-
export declare interface DehydrationChannelYield {
|
|
282
|
-
entries: Array<DehydratedQueryEntry>;
|
|
283
|
-
done: boolean;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
254
|
export { DistributiveOmit }
|
|
287
255
|
|
|
288
256
|
export { EnsureInfiniteQueryDataOptions }
|
|
@@ -347,23 +315,13 @@ export { hydrate }
|
|
|
347
315
|
|
|
348
316
|
export { HydrateOptions }
|
|
349
317
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
* Invoke `callback` (on a microtask) once the entry for `queryHash` has
|
|
359
|
-
* been applied — or immediately-on-a-microtask if it already was, or
|
|
360
|
-
* when the channel completes without one (SSR-errored queries are not
|
|
361
|
-
* dehydrated, so their components must not wait forever).
|
|
362
|
-
*/
|
|
363
|
-
whenQueryPrimed: (queryHash: string, callback: () => void) => void;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
export declare const HydrationCoordinatorContext: Context<HydrationCoordinator | null>;
|
|
318
|
+
/**
|
|
319
|
+
* Namespace prefix for cache entries in Solid's hydration registry — the
|
|
320
|
+
* registry is shared with positional node ids and other libraries'
|
|
321
|
+
* content-addressed keys (Solid Router uses its own cache keys), so query
|
|
322
|
+
* hashes get their own prefix.
|
|
323
|
+
*/
|
|
324
|
+
export declare const HYDRATION_KEY_PREFIX = "sq:";
|
|
367
325
|
|
|
368
326
|
export { InferDataFromTag }
|
|
369
327
|
|
|
@@ -379,15 +337,7 @@ export { InfiniteQueryObserverLoadingErrorResult }
|
|
|
379
337
|
|
|
380
338
|
export { InfiniteQueryObserverLoadingResult }
|
|
381
339
|
|
|
382
|
-
declare
|
|
383
|
-
/**
|
|
384
|
-
* Set this to a reconciliation key to enable reconciliation between query results.
|
|
385
|
-
* Set this to `false` to disable reconciliation between query results.
|
|
386
|
-
* Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom reconciliation logic.
|
|
387
|
-
* Defaults reconciliation to false.
|
|
388
|
-
*/
|
|
389
|
-
reconcile?: string | false | ((oldData: TData | undefined, newData: TData) => TData);
|
|
390
|
-
}
|
|
340
|
+
declare type InfiniteQueryObserverOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = InfiniteQueryObserverOptions_2<TQueryFnData, TError, TData, TQueryKey, TPageParam>;
|
|
391
341
|
export { InfiniteQueryObserverOptions }
|
|
392
342
|
export { InfiniteQueryObserverOptions as InfiniteQueryObserverOptions_alias_1 }
|
|
393
343
|
|
|
@@ -404,18 +354,16 @@ export { InfiniteQueryObserverSuccessResult }
|
|
|
404
354
|
declare interface InfiniteQueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> extends OmitKeyof<InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, 'queryKey' | 'suspense'> {
|
|
405
355
|
queryKey: TQueryKey;
|
|
406
356
|
/**
|
|
407
|
-
*
|
|
408
|
-
*
|
|
409
|
-
* This can be useful to avoid sending a loading state to the client before the query has resolved.
|
|
410
|
-
* Defaults to `false`.
|
|
357
|
+
* Defer the SSR stream flush until this query resolves on the server —
|
|
358
|
+
* see {@link UseBaseQueryOptions.deferStream}.
|
|
411
359
|
*/
|
|
412
360
|
deferStream?: boolean;
|
|
413
361
|
/**
|
|
414
|
-
*
|
|
415
|
-
*
|
|
416
|
-
*
|
|
362
|
+
* Reconciliation key for the data store — see
|
|
363
|
+
* {@link UseBaseQueryOptions.reconcile}. For infinite queries this keys
|
|
364
|
+
* items within pages; pages themselves merge positionally.
|
|
417
365
|
*/
|
|
418
|
-
|
|
366
|
+
reconcile?: string | ((item: NonNullable<any>) => any) | null;
|
|
419
367
|
}
|
|
420
368
|
export { InfiniteQueryOptions }
|
|
421
369
|
export { InfiniteQueryOptions as InfiniteQueryOptions_alias_1 }
|
|
@@ -530,6 +478,12 @@ export { notifyManager }
|
|
|
530
478
|
|
|
531
479
|
export { NotifyOnChangeProps }
|
|
532
480
|
|
|
481
|
+
/**
|
|
482
|
+
* Distributes an `isInitialLoading` omit over result unions so status
|
|
483
|
+
* discriminants survive (a plain Omit over a union collapses it).
|
|
484
|
+
*/
|
|
485
|
+
declare type OmitIsInitialLoading<T> = T extends unknown ? OmitKeyof<T, 'isInitialLoading' & keyof T> : never;
|
|
486
|
+
|
|
533
487
|
export { OmitKeyof }
|
|
534
488
|
|
|
535
489
|
export { onlineManager }
|
|
@@ -598,6 +552,12 @@ declare const QueryClientContext: Context<(() => QueryClient) | null>;
|
|
|
598
552
|
export { QueryClientContext }
|
|
599
553
|
export { QueryClientContext as QueryClientContext_alias_1 }
|
|
600
554
|
|
|
555
|
+
/**
|
|
556
|
+
* Provides the QueryClient and manages its mount lifecycle. On the server
|
|
557
|
+
* it also registers the cache serializer above; on the client, hooks prime
|
|
558
|
+
* the cache from their hash-keyed registry entries themselves — see
|
|
559
|
+
* `useBaseQuery`.
|
|
560
|
+
*/
|
|
601
561
|
declare const QueryClientProvider: (props: QueryClientProviderProps) => JSX.Element;
|
|
602
562
|
export { QueryClientProvider }
|
|
603
563
|
export { QueryClientProvider as QueryClientProvider_alias_1 }
|
|
@@ -629,15 +589,14 @@ export { QueryObserverLoadingErrorResult }
|
|
|
629
589
|
|
|
630
590
|
export { QueryObserverLoadingResult }
|
|
631
591
|
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
}
|
|
592
|
+
/**
|
|
593
|
+
* Core observer options pass through unchanged. The old adapter omitted
|
|
594
|
+
* `structuralSharing` and replaced it with a store-level `reconcile`
|
|
595
|
+
* option; with reads derived directly from cache state, core's
|
|
596
|
+
* cache-level structural sharing is exactly what keeps the data memo
|
|
597
|
+
* referentially stable, so it is exposed again and `reconcile` is gone.
|
|
598
|
+
*/
|
|
599
|
+
declare type QueryObserverOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = never> = QueryObserverOptions_2<TQueryFnData, TError, TData, TQueryData, TQueryKey, TPageParam>;
|
|
641
600
|
export { QueryObserverOptions }
|
|
642
601
|
export { QueryObserverOptions as QueryObserverOptions_alias_1 }
|
|
643
602
|
|
|
@@ -724,38 +683,49 @@ export { unsetMarker }
|
|
|
724
683
|
|
|
725
684
|
export { Updater }
|
|
726
685
|
|
|
727
|
-
declare type UseBaseMutationResult<TData = unknown, TError = DefaultError, TVariables = unknown, TOnMutateResult = unknown> = Override<MutationObserverResult<TData, TError, TVariables, TOnMutateResult>, {
|
|
686
|
+
declare type UseBaseMutationResult<TData = unknown, TError = DefaultError, TVariables = unknown, TOnMutateResult = unknown> = Override<OmitKeyof<MutationObserverResult<TData, TError, TVariables, TOnMutateResult>, 'context'>, {
|
|
728
687
|
mutate: UseMutateFunction<TData, TError, TVariables, TOnMutateResult>;
|
|
729
|
-
}
|
|
730
|
-
mutateAsync: UseMutateAsyncFunction<TData, TError, TVariables, TOnMutateResult>;
|
|
731
|
-
};
|
|
732
|
-
export { UseBaseMutationResult as CreateBaseMutationResult }
|
|
688
|
+
}>;
|
|
733
689
|
export { UseBaseMutationResult }
|
|
734
690
|
export { UseBaseMutationResult as UseBaseMutationResult_alias_1 }
|
|
735
691
|
|
|
736
|
-
export declare function useBaseQuery<TQueryFnData, TError, TData, TQueryData, TQueryKey extends QueryKey>(options: Accessor<UseBaseQueryOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>>, Observer: typeof QueryObserver, queryClient?: Accessor<QueryClient>):
|
|
692
|
+
export declare function useBaseQuery<TQueryFnData, TError, TData, TQueryData, TQueryKey extends QueryKey>(options: Accessor<UseBaseQueryOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>>, Observer: typeof QueryObserver, queryClient?: Accessor<QueryClient>): UseBaseQueryResult<TData, TError>;
|
|
693
|
+
|
|
694
|
+
export declare function useBaseQueryLayer<TQueryFnData, TError, TData, TQueryData, TQueryKey extends QueryKey>(options: Accessor<UseBaseQueryOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>>, Observer: typeof QueryObserver, queryClient?: Accessor<QueryClient>): BaseQueryLayer<TQueryFnData, TError, TData, TQueryData, TQueryKey>;
|
|
737
695
|
|
|
738
696
|
declare interface UseBaseQueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> extends OmitKeyof<QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>, 'suspense'> {
|
|
739
697
|
/**
|
|
740
|
-
*
|
|
741
|
-
*
|
|
742
|
-
*
|
|
743
|
-
*
|
|
698
|
+
* Defer the SSR stream flush until this query resolves on the server,
|
|
699
|
+
* instead of letting the surrounding `<Loading>` boundary render its
|
|
700
|
+
* fallback into the HTML. Passed through to Solid's own per-computation
|
|
701
|
+
* `deferStream` option; server-only, ignored on the client.
|
|
744
702
|
*/
|
|
745
703
|
deferStream?: boolean;
|
|
746
704
|
/**
|
|
747
|
-
*
|
|
748
|
-
*
|
|
749
|
-
*
|
|
705
|
+
* Reconciliation key for the data store. `data` is served as a Solid
|
|
706
|
+
* store projection: every landing (refetch, invalidation, placeholder
|
|
707
|
+
* upgrade) reconciles into the existing proxy graph instead of replacing
|
|
708
|
+
* it, so deep reads are fine-grained and item identity survives across
|
|
709
|
+
* fetches. This sets the identity key for that reconciliation — a
|
|
710
|
+
* property name, a key-extraction function, or `null` to merge
|
|
711
|
+
* positionally. Defaults to `'id'`. Read once at creation.
|
|
750
712
|
*/
|
|
751
|
-
|
|
713
|
+
reconcile?: string | ((item: NonNullable<any>) => any) | null;
|
|
752
714
|
}
|
|
753
|
-
export { UseBaseQueryOptions as CreateBaseQueryOptions }
|
|
754
715
|
export { UseBaseQueryOptions }
|
|
755
716
|
export { UseBaseQueryOptions as UseBaseQueryOptions_alias_1 }
|
|
756
717
|
|
|
757
|
-
|
|
758
|
-
|
|
718
|
+
/**
|
|
719
|
+
* `data` is non-optional: it is a suspending async read. It never returns
|
|
720
|
+
* `undefined` — a read either suspends into the nearest `<Loading>`
|
|
721
|
+
* boundary (first fetch in flight, disabled, restoring), returns a value
|
|
722
|
+
* (committed, placeholder, initial), or throws (`<Errored>` /
|
|
723
|
+
* `throwOnError`). The v5 `TData | undefined` face existed because reads
|
|
724
|
+
* could observe the pre-fetch gap; here that gap is suspension.
|
|
725
|
+
*/
|
|
726
|
+
declare type UseBaseQueryResult<TData = unknown, TError = DefaultError> = Override<OmitKeyof<QueryObserverResult<TData, TError>, 'isInitialLoading'>, {
|
|
727
|
+
data: TData;
|
|
728
|
+
}>;
|
|
759
729
|
export { UseBaseQueryResult }
|
|
760
730
|
export { UseBaseQueryResult as UseBaseQueryResult_alias_1 }
|
|
761
731
|
|
|
@@ -766,22 +736,21 @@ export { useInfiniteQuery }
|
|
|
766
736
|
export { useInfiniteQuery as useInfiniteQuery_alias_1 }
|
|
767
737
|
|
|
768
738
|
declare type UseInfiniteQueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = Accessor<InfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>>;
|
|
769
|
-
export { UseInfiniteQueryOptions as CreateInfiniteQueryOptions }
|
|
770
739
|
export { UseInfiniteQueryOptions }
|
|
771
740
|
export { UseInfiniteQueryOptions as UseInfiniteQueryOptions_alias_1 }
|
|
772
741
|
|
|
773
|
-
|
|
774
|
-
|
|
742
|
+
/** Non-optional `data` for the same reason as {@link UseBaseQueryResult}. */
|
|
743
|
+
declare type UseInfiniteQueryResult<TData = unknown, TError = DefaultError> = Override<OmitKeyof<InfiniteQueryObserverResult<TData, TError>, 'isInitialLoading'>, {
|
|
744
|
+
data: TData;
|
|
745
|
+
}>;
|
|
775
746
|
export { UseInfiniteQueryResult }
|
|
776
747
|
export { UseInfiniteQueryResult as UseInfiniteQueryResult_alias_1 }
|
|
777
748
|
|
|
778
749
|
declare function useIsFetching(filters?: Accessor<QueryFilters>, queryClient?: Accessor<QueryClient>): Accessor<number>;
|
|
779
|
-
export { useIsFetching as createIsFetching }
|
|
780
750
|
export { useIsFetching }
|
|
781
751
|
export { useIsFetching as useIsFetching_alias_1 }
|
|
782
752
|
|
|
783
753
|
declare function useIsMutating(filters?: Accessor<MutationFilters>, queryClient?: Accessor<QueryClient>): Accessor<number>;
|
|
784
|
-
export { useIsMutating as createIsMutating }
|
|
785
754
|
export { useIsMutating }
|
|
786
755
|
export { useIsMutating as useIsMutating_alias_1 }
|
|
787
756
|
|
|
@@ -789,36 +758,62 @@ declare const useIsRestoring: () => Accessor<boolean>;
|
|
|
789
758
|
export { useIsRestoring }
|
|
790
759
|
export { useIsRestoring as useIsRestoring_alias_1 }
|
|
791
760
|
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
761
|
+
/**
|
|
762
|
+
* One `mutate`, returning a safe-to-ignore promise: errors are also routed
|
|
763
|
+
* into reactive state, and ignoring the promise never surfaces an
|
|
764
|
+
* unhandled rejection. Call-site callbacks are gone — settle logic that
|
|
765
|
+
* used to live in `mutate(vars, { onSuccess })` is linear code after
|
|
766
|
+
* `await mutate(vars)` or a config-level callback.
|
|
767
|
+
*/
|
|
768
|
+
declare type UseMutateFunction<TData = unknown, _TError = DefaultError, TVariables = void, _TOnMutateResult = unknown> = (variables: TVariables) => Promise<TData>;
|
|
799
769
|
export { UseMutateFunction }
|
|
800
770
|
export { UseMutateFunction as UseMutateFunction_alias_1 }
|
|
801
771
|
|
|
772
|
+
/**
|
|
773
|
+
* Mutations ride core `action`: each `mutate()` call is one transaction.
|
|
774
|
+
*
|
|
775
|
+
* - Transient flight state (`isPending`, in-flight `variables`) is a
|
|
776
|
+
* `createOptimistic` overlay written at the top of the action — visible
|
|
777
|
+
* immediately, dropped automatically when the transition settles. The
|
|
778
|
+
* engine's revert-on-settle IS the submission state machine.
|
|
779
|
+
* - `options.onMutate(variables)` runs inside the same window: it is the
|
|
780
|
+
* place to apply the caller's own optimistic overlays
|
|
781
|
+
* (`createOptimistic` / `createOptimisticStore` writes). No context
|
|
782
|
+
* object, no rollback plumbing — reverting is the engine's job.
|
|
783
|
+
* - The fetch itself goes through query-core:
|
|
784
|
+
* `mutationCache.build().execute()` supplies retry/backoff, offline
|
|
785
|
+
* pausing, scoped serial execution, and cache-level lifecycle callbacks.
|
|
786
|
+
* No `MutationObserver` — the adapter reads the Mutation's state
|
|
787
|
+
* directly where flight metadata (failureCount, isPaused) is needed.
|
|
788
|
+
* - Options-level callbacks are stripped from the built mutation and
|
|
789
|
+
* re-run *post-`yield`*, inside the transaction: an
|
|
790
|
+
* `onSuccess → invalidateQueries` chain issues version bumps whose
|
|
791
|
+
* refetches hold this very transition, so mutation success and fresh
|
|
792
|
+
* query data land in one atomic paint (and a single-flight payload has
|
|
793
|
+
* already primed the cache by the time `execute` resolves).
|
|
794
|
+
* - One `mutate`, returning a safe-to-ignore promise: rejection is also
|
|
795
|
+
* routed into reactive state, and a no-op catch keeps the ignored
|
|
796
|
+
* branch from surfacing as an unhandled rejection. The
|
|
797
|
+
* `mutate`/`mutateAsync` split existed for React's callback-vs-promise
|
|
798
|
+
* error routing; it has no space here.
|
|
799
|
+
*/
|
|
802
800
|
declare function useMutation<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown>(options: UseMutationOptions<TData, TError, TVariables, TOnMutateResult>, queryClient?: Accessor<QueryClient>): UseMutationResult<TData, TError, TVariables, TOnMutateResult>;
|
|
803
801
|
export { useMutation }
|
|
804
802
|
export { useMutation as useMutation_alias_1 }
|
|
805
803
|
|
|
806
804
|
declare type UseMutationOptions<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> = Accessor<MutationOptions<TData, TError, TVariables, TOnMutateResult>>;
|
|
807
|
-
export { UseMutationOptions as CreateMutationOptions }
|
|
808
805
|
export { UseMutationOptions }
|
|
809
806
|
export { UseMutationOptions as UseMutationOptions_alias_1 }
|
|
810
807
|
|
|
811
808
|
declare type UseMutationResult<TData = unknown, TError = DefaultError, TVariables = unknown, TOnMutateResult = unknown> = UseBaseMutationResult<TData, TError, TVariables, TOnMutateResult>;
|
|
812
|
-
export { UseMutationResult as CreateMutationResult }
|
|
813
809
|
export { UseMutationResult }
|
|
814
810
|
export { UseMutationResult as UseMutationResult_alias_1 }
|
|
815
811
|
|
|
816
812
|
declare function useMutationState<TResult = MutationState>(options?: Accessor<MutationStateOptions<TResult>>, queryClient?: Accessor<QueryClient>): Accessor<Array<TResult>>;
|
|
817
|
-
export { useMutationState as createMutationState }
|
|
818
813
|
export { useMutationState }
|
|
819
814
|
export { useMutationState as useMutationState_alias_1 }
|
|
820
815
|
|
|
821
|
-
declare function useQueries<T extends Array<any>, TCombinedResult
|
|
816
|
+
declare function useQueries<T extends Array<any>, TCombinedResult = QueriesResults<T>>(queriesOptions: Accessor<{
|
|
822
817
|
queries: readonly [...QueriesOptions<T>] | readonly [...{
|
|
823
818
|
[K in keyof T]: GetOptions<T[K]>;
|
|
824
819
|
}];
|
|
@@ -838,23 +833,21 @@ export { useQueryClient }
|
|
|
838
833
|
export { useQueryClient as useQueryClient_alias_1 }
|
|
839
834
|
|
|
840
835
|
declare type UseQueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = Accessor<QueryOptions<TQueryFnData, TError, TData, TQueryKey>>;
|
|
841
|
-
export { UseQueryOptions as CreateQueryOptions }
|
|
842
836
|
export { UseQueryOptions }
|
|
843
837
|
export { UseQueryOptions as UseQueryOptions_alias_1 }
|
|
844
838
|
|
|
845
|
-
declare type UseQueryOptionsForUseQueries<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = OmitKeyof<QueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'placeholderData'
|
|
839
|
+
declare type UseQueryOptionsForUseQueries<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = OmitKeyof<QueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'placeholderData'> & {
|
|
846
840
|
placeholderData?: TQueryFnData | QueriesPlaceholderDataFunction<TQueryFnData>;
|
|
847
841
|
/**
|
|
848
|
-
* @deprecated The `suspense` option has been
|
|
849
|
-
*
|
|
850
|
-
*
|
|
851
|
-
*
|
|
842
|
+
* @deprecated The `suspense` option has been removed. Suspense is the
|
|
843
|
+
* model: each result's `data` is an async read that suspends into the
|
|
844
|
+
* nearest `<Loading>` boundary while its first fetch is in flight, same
|
|
845
|
+
* as `useQuery`. Setting `suspense` is a no-op.
|
|
852
846
|
*/
|
|
853
847
|
suspense?: boolean;
|
|
854
848
|
};
|
|
855
849
|
|
|
856
850
|
declare type UseQueryResult<TData = unknown, TError = DefaultError> = UseBaseQueryResult<TData, TError>;
|
|
857
|
-
export { UseQueryResult as CreateQueryResult }
|
|
858
851
|
export { UseQueryResult }
|
|
859
852
|
export { UseQueryResult as UseQueryResult_alias_1 }
|
|
860
853
|
|