@tanstack/solid-query 5.103.0 → 5.103.2

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/build/dev.cjs CHANGED
@@ -10,7 +10,7 @@ let solid_js_store = require("solid-js/store");
10
10
  const QueryClientContext = (0, solid_js.createContext)(void 0);
11
11
  const queryClientContextError = "No QueryClient set, use QueryClientProvider to set one";
12
12
  /**
13
- * The `useQueryClient` hook returns the current `QueryClient` instance.
13
+ * The `useQueryClient` primitive returns the current `QueryClient` instance.
14
14
  *
15
15
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
16
16
  * be used.
@@ -69,7 +69,7 @@ const QueryClientProvider = (props) => {
69
69
  //#region src/isRestoring.ts
70
70
  const IsRestoringContext = (0, solid_js.createContext)(() => false);
71
71
  /**
72
- * If you are using `PersistQueryClientProvider`, you can also use the `useIsRestoring` hook alongside it to
72
+ * If you are using `PersistQueryClientProvider`, you can also use the `useIsRestoring` primitive alongside it to
73
73
  * check if a restore is currently in progress. `useQuery` and friends also check this internally to avoid
74
74
  * race conditions between the restore and mounting queries.
75
75
  *
@@ -290,6 +290,9 @@ function useInfiniteQuery(options, queryClient) {
290
290
  //#endregion
291
291
  //#region src/useMutation.ts
292
292
  /**
293
+ * Unlike queries, mutations are typically used to create/update/delete data or perform server side-effects.
294
+ * `useMutation` is the primitive for that.
295
+ *
293
296
  * @param options - An accessor returning the {@link UseMutationOptions} to use.
294
297
  * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context
295
298
  * will be used.
@@ -479,7 +482,7 @@ function useMutation(options, queryClient) {
479
482
  //#endregion
480
483
  //#region src/useQueries.ts
481
484
  /**
482
- * The `useQueries` hook can be used to fetch a variable number of queries.
485
+ * The `useQueries` primitive can be used to fetch a variable number of queries.
483
486
  *
484
487
  * The `queries` key accepts an array with query option objects mostly identical to `useQuery` — see
485
488
  * `placeholderData` below for the one difference. A custom `QueryClient` is supplied once, as `useQueries`'
@@ -653,7 +656,7 @@ function queryOptions(options) {
653
656
  //#endregion
654
657
  //#region src/useIsFetching.ts
655
658
  /**
656
- * The `useIsFetching` hook returns the `number` of the queries that your application is loading or fetching
659
+ * The `useIsFetching` primitive returns the `number` of the queries that your application is loading or fetching
657
660
  * in the background (useful for app-wide loading indicators).
658
661
  *
659
662
  * @param filters - An accessor returning the {@link QueryFilters} to narrow down the matched queries.
@@ -701,7 +704,7 @@ function mutationOptions(options) {
701
704
  //#endregion
702
705
  //#region src/useIsMutating.ts
703
706
  /**
704
- * The `useIsMutating` hook returns the `number` of mutations that your application currently has `pending`
707
+ * The `useIsMutating` primitive returns the `number` of mutations that your application currently has `pending`
705
708
  * (useful for app-wide loading indicators).
706
709
  *
707
710
  * @param filters - An accessor returning the {@link MutationFilters} to narrow down the matched mutations.
@@ -741,7 +744,7 @@ function getResult(mutationCache, options) {
741
744
  return mutationCache.findAll(options.filters).map((mutation) => options.select ? options.select(mutation) : mutation.state);
742
745
  }
743
746
  /**
744
- * `useMutationState` is a hook that gives you access to all mutations in the `MutationCache`. You can pass
747
+ * `useMutationState` is a primitive that gives you access to all mutations in the `MutationCache`. You can pass
745
748
  * `filters` ({@link MutationFilters}) to narrow down your mutations, and `select` to transform the mutation
746
749
  * state.
747
750
  *
package/build/dev.js CHANGED
@@ -10,7 +10,7 @@ export * from "@tanstack/query-core";
10
10
  const QueryClientContext = createContext(void 0);
11
11
  const queryClientContextError = "No QueryClient set, use QueryClientProvider to set one";
12
12
  /**
13
- * The `useQueryClient` hook returns the current `QueryClient` instance.
13
+ * The `useQueryClient` primitive returns the current `QueryClient` instance.
14
14
  *
15
15
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
16
16
  * be used.
@@ -69,7 +69,7 @@ const QueryClientProvider = (props) => {
69
69
  //#region src/isRestoring.ts
70
70
  const IsRestoringContext = createContext(() => false);
71
71
  /**
72
- * If you are using `PersistQueryClientProvider`, you can also use the `useIsRestoring` hook alongside it to
72
+ * If you are using `PersistQueryClientProvider`, you can also use the `useIsRestoring` primitive alongside it to
73
73
  * check if a restore is currently in progress. `useQuery` and friends also check this internally to avoid
74
74
  * race conditions between the restore and mounting queries.
75
75
  *
@@ -290,6 +290,9 @@ function useInfiniteQuery(options, queryClient) {
290
290
  //#endregion
291
291
  //#region src/useMutation.ts
292
292
  /**
293
+ * Unlike queries, mutations are typically used to create/update/delete data or perform server side-effects.
294
+ * `useMutation` is the primitive for that.
295
+ *
293
296
  * @param options - An accessor returning the {@link UseMutationOptions} to use.
294
297
  * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context
295
298
  * will be used.
@@ -479,7 +482,7 @@ function useMutation(options, queryClient) {
479
482
  //#endregion
480
483
  //#region src/useQueries.ts
481
484
  /**
482
- * The `useQueries` hook can be used to fetch a variable number of queries.
485
+ * The `useQueries` primitive can be used to fetch a variable number of queries.
483
486
  *
484
487
  * The `queries` key accepts an array with query option objects mostly identical to `useQuery` — see
485
488
  * `placeholderData` below for the one difference. A custom `QueryClient` is supplied once, as `useQueries`'
@@ -653,7 +656,7 @@ function queryOptions(options) {
653
656
  //#endregion
654
657
  //#region src/useIsFetching.ts
655
658
  /**
656
- * The `useIsFetching` hook returns the `number` of the queries that your application is loading or fetching
659
+ * The `useIsFetching` primitive returns the `number` of the queries that your application is loading or fetching
657
660
  * in the background (useful for app-wide loading indicators).
658
661
  *
659
662
  * @param filters - An accessor returning the {@link QueryFilters} to narrow down the matched queries.
@@ -701,7 +704,7 @@ function mutationOptions(options) {
701
704
  //#endregion
702
705
  //#region src/useIsMutating.ts
703
706
  /**
704
- * The `useIsMutating` hook returns the `number` of mutations that your application currently has `pending`
707
+ * The `useIsMutating` primitive returns the `number` of mutations that your application currently has `pending`
705
708
  * (useful for app-wide loading indicators).
706
709
  *
707
710
  * @param filters - An accessor returning the {@link MutationFilters} to narrow down the matched mutations.
@@ -741,7 +744,7 @@ function getResult(mutationCache, options) {
741
744
  return mutationCache.findAll(options.filters).map((mutation) => options.select ? options.select(mutation) : mutation.state);
742
745
  }
743
746
  /**
744
- * `useMutationState` is a hook that gives you access to all mutations in the `MutationCache`. You can pass
747
+ * `useMutationState` is a primitive that gives you access to all mutations in the `MutationCache`. You can pass
745
748
  * `filters` ({@link MutationFilters}) to narrow down your mutations, and `select` to transform the mutation
746
749
  * state.
747
750
  *
package/build/index.d.cts CHANGED
@@ -81,7 +81,8 @@ interface UseBaseQueryOptions<TQueryFnData = unknown, TError = DefaultError, TDa
81
81
  * Only applicable while rendering queries on the server with streaming.
82
82
  * Set `deferStream` to `true` to wait for the query to resolve on the server before flushing the stream.
83
83
  * This can be useful to avoid sending a loading state to the client before the query has resolved.
84
- * Defaults to `false`.
84
+ *
85
+ * @defaultValue false
85
86
  */
86
87
  deferStream?: boolean;
87
88
  /**
@@ -153,12 +154,21 @@ type DefinedUseQueryResult<TData = unknown, TError = DefaultError> = DefinedUseB
153
154
  * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.
154
155
  */
155
156
  interface InfiniteQueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> extends OmitKeyof<InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, 'queryKey' | 'suspense'> {
157
+ /**
158
+ * The query key to use for this query. Required here, unlike on the options this type extends.
159
+ *
160
+ * The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/solid/guides/query-keys)
161
+ * for more information.
162
+ *
163
+ * The query will automatically update when this key changes (as long as `enabled` is not set to `false`).
164
+ */
156
165
  queryKey: TQueryKey;
157
166
  /**
158
167
  * Only applicable while rendering queries on the server with streaming.
159
168
  * Set `deferStream` to `true` to wait for the query to resolve on the server before flushing the stream.
160
169
  * This can be useful to avoid sending a loading state to the client before the query has resolved.
161
- * Defaults to `false`.
170
+ *
171
+ * @defaultValue false
162
172
  */
163
173
  deferStream?: boolean;
164
174
  /**
@@ -360,6 +370,9 @@ declare function queryOptions<TQueryFnData = unknown, TError = DefaultError, TDa
360
370
  //#endregion
361
371
  //#region src/useQuery.d.ts
362
372
  /**
373
+ * Subscribes to a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
374
+ * The query runs when the options call for it — `enabled: false` skips the initial fetch.
375
+ *
363
376
  * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.
364
377
  * @param options - An accessor returning the {@link UndefinedInitialDataOptions} to use — everything you can
365
378
  * pass to `useQuery`.
@@ -522,6 +535,9 @@ declare function queryOptions<TQueryFnData = unknown, TError = DefaultError, TDa
522
535
  */
523
536
  declare function useQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>, queryClient?: () => QueryClient): UseQueryResult<TData, TError>;
524
537
  /**
538
+ * Subscribes to a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
539
+ * The query runs when the options call for it — `enabled: false` skips the initial fetch.
540
+ *
525
541
  * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined`.
526
542
  *
527
543
  * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.
@@ -836,6 +852,9 @@ declare function useInfiniteQuery<TQueryFnData, TError = DefaultError, TData = I
836
852
  //#endregion
837
853
  //#region src/useMutation.d.ts
838
854
  /**
855
+ * Unlike queries, mutations are typically used to create/update/delete data or perform server side-effects.
856
+ * `useMutation` is the primitive for that.
857
+ *
839
858
  * @param options - An accessor returning the {@link UseMutationOptions} to use.
840
859
  * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context
841
860
  * will be used.
@@ -1048,7 +1067,7 @@ type QueriesOptions<T extends Array<any>, TResult extends Array<any> = [], TDept
1048
1067
  */
1049
1068
  type QueriesResults<T extends Array<any>, TResult extends Array<any> = [], TDepth extends ReadonlyArray<number> = []> = TDepth['length'] extends MAXIMUM_DEPTH ? Array<UseQueryResult> : T extends [] ? [] : T extends [infer Head] ? [...TResult, GetResults<Head>] : T extends [infer Head, ...infer Tail] ? QueriesResults<[...Tail], [...TResult, GetResults<Head>], [...TDepth, 1]> : { [K in keyof T]: GetResults<T[K]>; };
1050
1069
  /**
1051
- * The `useQueries` hook can be used to fetch a variable number of queries.
1070
+ * The `useQueries` primitive can be used to fetch a variable number of queries.
1052
1071
  *
1053
1072
  * The `queries` key accepts an array with query option objects mostly identical to `useQuery` — see
1054
1073
  * `placeholderData` below for the one difference. A custom `QueryClient` is supplied once, as `useQueries`'
@@ -1145,7 +1164,7 @@ declare function useQueries<T extends Array<any>, TCombinedResult extends Querie
1145
1164
  */
1146
1165
  declare const QueryClientContext: import("solid-js").Context<(() => QueryClient) | undefined>;
1147
1166
  /**
1148
- * The `useQueryClient` hook returns the current `QueryClient` instance.
1167
+ * The `useQueryClient` primitive returns the current `QueryClient` instance.
1149
1168
  *
1150
1169
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
1151
1170
  * be used.
@@ -1191,7 +1210,7 @@ declare const QueryClientProvider: (props: QueryClientProviderProps) => JSX.Elem
1191
1210
  //#endregion
1192
1211
  //#region src/useIsFetching.d.ts
1193
1212
  /**
1194
- * The `useIsFetching` hook returns the `number` of the queries that your application is loading or fetching
1213
+ * The `useIsFetching` primitive returns the `number` of the queries that your application is loading or fetching
1195
1214
  * in the background (useful for app-wide loading indicators).
1196
1215
  *
1197
1216
  * @param filters - An accessor returning the {@link QueryFilters} to narrow down the matched queries.
@@ -1275,7 +1294,7 @@ declare function mutationOptions<TData = unknown, TError = DefaultError, TVariab
1275
1294
  //#endregion
1276
1295
  //#region src/useIsMutating.d.ts
1277
1296
  /**
1278
- * The `useIsMutating` hook returns the `number` of mutations that your application currently has `pending`
1297
+ * The `useIsMutating` primitive returns the `number` of mutations that your application currently has `pending`
1279
1298
  * (useful for app-wide loading indicators).
1280
1299
  *
1281
1300
  * @param filters - An accessor returning the {@link MutationFilters} to narrow down the matched mutations.
@@ -1304,7 +1323,7 @@ type MutationStateOptions<TResult = MutationState, TMutation extends Mutation<an
1304
1323
  select?: (mutation: TMutation) => TResult;
1305
1324
  };
1306
1325
  /**
1307
- * `useMutationState` is a hook that gives you access to all mutations in the `MutationCache`. You can pass
1326
+ * `useMutationState` is a primitive that gives you access to all mutations in the `MutationCache`. You can pass
1308
1327
  * `filters` ({@link MutationFilters}) to narrow down your mutations, and `select` to transform the mutation
1309
1328
  * state.
1310
1329
  *
@@ -1380,7 +1399,7 @@ declare function useMutationState<TResult = MutationState, TMutation extends Mut
1380
1399
  //#endregion
1381
1400
  //#region src/isRestoring.d.ts
1382
1401
  /**
1383
- * If you are using `PersistQueryClientProvider`, you can also use the `useIsRestoring` hook alongside it to
1402
+ * If you are using `PersistQueryClientProvider`, you can also use the `useIsRestoring` primitive alongside it to
1384
1403
  * check if a restore is currently in progress. `useQuery` and friends also check this internally to avoid
1385
1404
  * race conditions between the restore and mounting queries.
1386
1405
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/QueryClient.ts","../src/types.ts","../src/queryOptions.ts","../src/useQuery.ts","../src/infiniteQueryOptions.ts","../src/useInfiniteQuery.ts","../src/useMutation.ts","../src/useQueries.ts","../src/QueryClientProvider.tsx","../src/useIsFetching.ts","../src/mutationOptions.ts","../src/useIsMutating.ts","../src/useMutationState.ts","../src/isRestoring.ts","../src/index.ts"],"mappings":";;;;;;;;;;;;;;;UAsBiB,qBACf,wBACA,SAAS,cACT,QAAQ,cACR,aAAa,cACb,kBAAkB,WAAW,UAC7B,4BACQ,UACR,uBACE,cACA,QACA,OACA,YACA,WACA;;;;;;;EAUF,+BAGM,SAAS,mBAAmB,SAAS,UAAU;;;;;;;;;;;UAYtC,6BACf,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAC7B,8BACQ,UACR,+BACE,cACA,QACA,OACA,WACA;;;;;;;EAUF,+BAG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B,uBAAc;cAMd,sBAAa"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/QueryClient.ts","../src/types.ts","../src/queryOptions.ts","../src/useQuery.ts","../src/infiniteQueryOptions.ts","../src/useInfiniteQuery.ts","../src/useMutation.ts","../src/useQueries.ts","../src/QueryClientProvider.tsx","../src/useIsFetching.ts","../src/mutationOptions.ts","../src/useIsMutating.ts","../src/useMutationState.ts","../src/isRestoring.ts","../src/index.ts"],"mappings":";;;;;;;;;;;;;;;UAsBiB,qBACf,wBACA,SAAS,cACT,QAAQ,cACR,aAAa,cACb,kBAAkB,WAAW,UAC7B,4BACQ,UACR,uBACE,cACA,QACA,OACA,YACA,WACA;;;;;;;EAUF,+BAGM,SAAS,mBAAmB,SAAS,UAAU;;;;;;;;;;;UAYtC,6BACf,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAC7B,8BACQ,UACR,+BACE,cACA,QACA,OACA,WACA;;;;;;;EAUF,+BAGM,SAAS,mBAAmB,SAAS,UAAU;;;;;;;;UAStC,eACf,SAAS,sBACD,iBAAmB;EAC3B,UAAU,UAAU,8BAA8B;;;;;UAMnC,0BAA0B;EACzC,iBAAiB;;;;;;cAON,oBAAoB;EACnB,YAAA,SAAQ;;;;;;;;;;;;;;;;UChFL,oBACf,wBACA,SAAS,cACT,QAAQ,cACR,aAAa,cACb,kBAAkB,WAAW,kBACrB,UACR,qBAAqB,cAAc,QAAQ,OAAO,YAAY;;;;;;;;EAU9D;;;;;;EAMA;;;;;;;;;;;UAYe,aACf,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,kBACrB,oBACR,cACA,QACA,OACA,cACA;;;;;;;;;;;KAaU,gBACV,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,YAC3B,SAAS,aAAa,cAAc,QAAQ,OAAO;;;;;;;;;KAY3C,mBACV,iBACA,SAAS,gBACP,oBAAoB,OAAO;;;;;;;;KASnB,eACV,iBACA,SAAS,gBACP,mB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,KACP,gBAAgB,OAAO,QAAQ,YAAY,mCAG5C,KACD,gBAAgB,OAAO,QAAQ,YAAY;;;;;;;;;;;;;;;;;;;;;;;;iBCxD7B,cACd,UAAU,SAAS,kBACnB,cAAc,SAAS,eACtB;;;KClBE,uBAAuB,YAAY,kBACtC,oBACQ,aACA,cACA,kBACA,oBAGN,SAAS,OAAO,QAAQ,YAAY,mBACpC;KAEC,qBACH,UAAU,eACV,kBAAkB,+BAChB,uBAAuB;EAEzB,UAAU;EACV,UAAU,UAAU,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA8FpB,iBACd,UAAU,eACV,kBAAkB,+BAChB,uBAAuB,UAEzB,UAAS,SAAS,qBAAqB,SAAS,aAChD,cAAc,SAAS,eACtB,SAAS,MAAM;;;;;;;;;;cCtHL,sBAAc;;;;;cAMd,wCAAmB,yBAAA;;;cCsCnB,oBAAW;cAeX,4BAAmB;cAQnB,uBAAc;cAMd,sBAAa"}
package/build/index.d.ts CHANGED
@@ -81,7 +81,8 @@ interface UseBaseQueryOptions<TQueryFnData = unknown, TError = DefaultError, TDa
81
81
  * Only applicable while rendering queries on the server with streaming.
82
82
  * Set `deferStream` to `true` to wait for the query to resolve on the server before flushing the stream.
83
83
  * This can be useful to avoid sending a loading state to the client before the query has resolved.
84
- * Defaults to `false`.
84
+ *
85
+ * @defaultValue false
85
86
  */
86
87
  deferStream?: boolean;
87
88
  /**
@@ -153,12 +154,21 @@ type DefinedUseQueryResult<TData = unknown, TError = DefaultError> = DefinedUseB
153
154
  * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.
154
155
  */
155
156
  interface InfiniteQueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> extends OmitKeyof<InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, 'queryKey' | 'suspense'> {
157
+ /**
158
+ * The query key to use for this query. Required here, unlike on the options this type extends.
159
+ *
160
+ * The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/solid/guides/query-keys)
161
+ * for more information.
162
+ *
163
+ * The query will automatically update when this key changes (as long as `enabled` is not set to `false`).
164
+ */
156
165
  queryKey: TQueryKey;
157
166
  /**
158
167
  * Only applicable while rendering queries on the server with streaming.
159
168
  * Set `deferStream` to `true` to wait for the query to resolve on the server before flushing the stream.
160
169
  * This can be useful to avoid sending a loading state to the client before the query has resolved.
161
- * Defaults to `false`.
170
+ *
171
+ * @defaultValue false
162
172
  */
163
173
  deferStream?: boolean;
164
174
  /**
@@ -360,6 +370,9 @@ declare function queryOptions<TQueryFnData = unknown, TError = DefaultError, TDa
360
370
  //#endregion
361
371
  //#region src/useQuery.d.ts
362
372
  /**
373
+ * Subscribes to a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
374
+ * The query runs when the options call for it — `enabled: false` skips the initial fetch.
375
+ *
363
376
  * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.
364
377
  * @param options - An accessor returning the {@link UndefinedInitialDataOptions} to use — everything you can
365
378
  * pass to `useQuery`.
@@ -522,6 +535,9 @@ declare function queryOptions<TQueryFnData = unknown, TError = DefaultError, TDa
522
535
  */
523
536
  declare function useQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>, queryClient?: () => QueryClient): UseQueryResult<TData, TError>;
524
537
  /**
538
+ * Subscribes to a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
539
+ * The query runs when the options call for it — `enabled: false` skips the initial fetch.
540
+ *
525
541
  * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined`.
526
542
  *
527
543
  * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.
@@ -836,6 +852,9 @@ declare function useInfiniteQuery<TQueryFnData, TError = DefaultError, TData = I
836
852
  //#endregion
837
853
  //#region src/useMutation.d.ts
838
854
  /**
855
+ * Unlike queries, mutations are typically used to create/update/delete data or perform server side-effects.
856
+ * `useMutation` is the primitive for that.
857
+ *
839
858
  * @param options - An accessor returning the {@link UseMutationOptions} to use.
840
859
  * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context
841
860
  * will be used.
@@ -1048,7 +1067,7 @@ type QueriesOptions<T extends Array<any>, TResult extends Array<any> = [], TDept
1048
1067
  */
1049
1068
  type QueriesResults<T extends Array<any>, TResult extends Array<any> = [], TDepth extends ReadonlyArray<number> = []> = TDepth['length'] extends MAXIMUM_DEPTH ? Array<UseQueryResult> : T extends [] ? [] : T extends [infer Head] ? [...TResult, GetResults<Head>] : T extends [infer Head, ...infer Tail] ? QueriesResults<[...Tail], [...TResult, GetResults<Head>], [...TDepth, 1]> : { [K in keyof T]: GetResults<T[K]>; };
1050
1069
  /**
1051
- * The `useQueries` hook can be used to fetch a variable number of queries.
1070
+ * The `useQueries` primitive can be used to fetch a variable number of queries.
1052
1071
  *
1053
1072
  * The `queries` key accepts an array with query option objects mostly identical to `useQuery` — see
1054
1073
  * `placeholderData` below for the one difference. A custom `QueryClient` is supplied once, as `useQueries`'
@@ -1145,7 +1164,7 @@ declare function useQueries<T extends Array<any>, TCombinedResult extends Querie
1145
1164
  */
1146
1165
  declare const QueryClientContext: import("solid-js").Context<(() => QueryClient) | undefined>;
1147
1166
  /**
1148
- * The `useQueryClient` hook returns the current `QueryClient` instance.
1167
+ * The `useQueryClient` primitive returns the current `QueryClient` instance.
1149
1168
  *
1150
1169
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
1151
1170
  * be used.
@@ -1191,7 +1210,7 @@ declare const QueryClientProvider: (props: QueryClientProviderProps) => JSX.Elem
1191
1210
  //#endregion
1192
1211
  //#region src/useIsFetching.d.ts
1193
1212
  /**
1194
- * The `useIsFetching` hook returns the `number` of the queries that your application is loading or fetching
1213
+ * The `useIsFetching` primitive returns the `number` of the queries that your application is loading or fetching
1195
1214
  * in the background (useful for app-wide loading indicators).
1196
1215
  *
1197
1216
  * @param filters - An accessor returning the {@link QueryFilters} to narrow down the matched queries.
@@ -1275,7 +1294,7 @@ declare function mutationOptions<TData = unknown, TError = DefaultError, TVariab
1275
1294
  //#endregion
1276
1295
  //#region src/useIsMutating.d.ts
1277
1296
  /**
1278
- * The `useIsMutating` hook returns the `number` of mutations that your application currently has `pending`
1297
+ * The `useIsMutating` primitive returns the `number` of mutations that your application currently has `pending`
1279
1298
  * (useful for app-wide loading indicators).
1280
1299
  *
1281
1300
  * @param filters - An accessor returning the {@link MutationFilters} to narrow down the matched mutations.
@@ -1304,7 +1323,7 @@ type MutationStateOptions<TResult = MutationState, TMutation extends Mutation<an
1304
1323
  select?: (mutation: TMutation) => TResult;
1305
1324
  };
1306
1325
  /**
1307
- * `useMutationState` is a hook that gives you access to all mutations in the `MutationCache`. You can pass
1326
+ * `useMutationState` is a primitive that gives you access to all mutations in the `MutationCache`. You can pass
1308
1327
  * `filters` ({@link MutationFilters}) to narrow down your mutations, and `select` to transform the mutation
1309
1328
  * state.
1310
1329
  *
@@ -1380,7 +1399,7 @@ declare function useMutationState<TResult = MutationState, TMutation extends Mut
1380
1399
  //#endregion
1381
1400
  //#region src/isRestoring.d.ts
1382
1401
  /**
1383
- * If you are using `PersistQueryClientProvider`, you can also use the `useIsRestoring` hook alongside it to
1402
+ * If you are using `PersistQueryClientProvider`, you can also use the `useIsRestoring` primitive alongside it to
1384
1403
  * check if a restore is currently in progress. `useQuery` and friends also check this internally to avoid
1385
1404
  * race conditions between the restore and mounting queries.
1386
1405
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/QueryClient.ts","../src/types.ts","../src/queryOptions.ts","../src/useQuery.ts","../src/infiniteQueryOptions.ts","../src/useInfiniteQuery.ts","../src/useMutation.ts","../src/useQueries.ts","../src/QueryClientProvider.tsx","../src/useIsFetching.ts","../src/mutationOptions.ts","../src/useIsMutating.ts","../src/useMutationState.ts","../src/isRestoring.ts","../src/index.ts"],"mappings":";;;;;;;;;;;;;;;UAsBiB,qBACf,wBACA,SAAS,cACT,QAAQ,cACR,aAAa,cACb,kBAAkB,WAAW,UAC7B,4BACQ,UACR,uBACE,cACA,QACA,OACA,YACA,WACA;;;;;;;EAUF,+BAGM,SAAS,mBAAmB,SAAS,UAAU;;;;;;;;;;;UAYtC,6BACf,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAC7B,8BACQ,UACR,+BACE,cACA,QACA,OACA,WACA;;;;;;;EAUF,+BAGM,SAAS,mBAAmB,SAAS,UAAU;;;;;;;;UAStC,eACf,SAAS,sBACD,iBAAmB;EAC3B,UAAU,UAAU,8BAA8B;;;;;UAMnC,0BAA0B;EACzC,iBAAiB;;;;;;cAON,oBAAoB;EACnB,YAAA,SAAQ;;;;;;;;;;;;;;;;UChFL,oBACf,wBACA,SAAS,cACT,QAAQ,cACR,aAAa,cACb,kBAAkB,WAAW,kBACrB,UACR,qBAAqB,cAAc,QAAQ,OAAO,YAAY;;;;;;;EAS9D;;;;;;EAMA;;;;;;;;;;;UAYe,aACf,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,kBACrB,oBACR,cACA,QACA,OACA,cACA;;;;;;;;;;;KAaU,gBACV,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,YAC3B,SAAS,aAAa,cAAc,QAAQ,OAAO;;;;;;;;;KAY3C,mBACV,iBACA,SAAS,gBACP,oBAAoB,OAAO;;;;;;;;KASnB,eACV,iBACA,SAAS,gBACP,mBAAmB,OAAO;;;;;;;KAQlB,0BACV,iBACA,SAAS,gBACP,2BAA2B,OAAO;;;;;;;KAQ1B,sBACV,iBACA,SAAS,gBACP,0BAA0B,OAAO;;;;;;;;;;UAYpB,qBACf,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,U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AGN,SAAS,OAAO,QAAQ,YAAY,mBACpC;KAEC,qBACH,UAAU,eACV,kBAAkB,+BAChB,uBAAuB;EAEzB,UAAU;EACV,UAAU,UAAU,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA8FpB,iBACd,UAAU,eACV,kBAAkB,+BAChB,uBAAuB,UAEzB,UAAS,SAAS,qBAAqB,SAAS,aAChD,cAAc,SAAS,eACtB,SAAS,MAAM;;;;;;;;;;cCtHL,sBAAc;;;;;cAMd,wCAAmB,yBAAA;;;cCsCnB,oBAAW;cAeX,4BAAmB;cAQnB,uBAAc;cAMd,sBAAa"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/QueryClient.ts","../src/types.ts","../src/queryOptions.ts","../src/useQuery.ts","../src/infiniteQueryOptions.ts","../src/useInfiniteQuery.ts","../src/useMutation.ts","../src/useQueries.ts","../src/QueryClientProvider.tsx","../src/useIsFetching.ts","../src/mutationOptions.ts","../src/useIsMutating.ts","../src/useMutationState.ts","../src/isRestoring.ts","../src/index.ts"],"mappings":";;;;;;;;;;;;;;;UAsBiB,qBACf,wBACA,SAAS,cACT,QAAQ,cACR,aAAa,cACb,kBAAkB,WAAW,UAC7B,4BACQ,UACR,uBACE,cACA,QACA,OACA,YACA,WACA;;;;;;;EAUF,+BAGM,SAAS,mBAAmB,SAAS,UAAU;;;;;;;;;;;UAYtC,6BACf,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAC7B,8BACQ,UACR,+BACE,cACA,QACA,OACA,WACA;;;;;;;EAUF,+BAGM,SAAS,mBAAmB,SAAS,UAAU;;;;;;;;UAStC,eACf,SAAS,sBACD,iBAAmB;EAC3B,UAAU,UAAU,8BAA8B;;;;;UAMnC,0BAA0B;EACzC,iBAAiB;;;;;;cAON,oBAAoB;EACnB,YAAA,SAAQ;;;;;;;;;;;;;;;;UChFL,oBACf,wBACA,SA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C;;;;;;EAMV,QAAQ;;;;EAIR,WAAW,IAAI;;;;;;;;;;;;;;;;;;;;;cAsBJ,sBACX,OAAO,6BACN,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;iBCpES,cACd,UAAU,SAAS,eACnB,cAAc,SAAS,eACtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBCCa,gBACd,iBACA,SAAS,cACT,mBACA,2BAEA,SAAS,aACP,gBAAgB,OAAO,QAAQ,YAAY,mCAG5C,aACD,gBAAgB,OAAO,QAAQ,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6B7B,gBACd,iBACA,SAAS,cACT,mBACA,2BAEA,SAAS,KACP,gBAAgB,OAAO,QAAQ,YAAY,mCAG5C,KACD,gBAAgB,OAAO,QAAQ,YAAY;;;;;;;;;;;;;;;;;;;;;;;;iBCxD7B,cACd,UAAU,SAAS,kBACnB,cAAc,SAAS,eACtB;;;KClBE,uBAAuB,YAAY,kBACtC,oBACQ,aACA,cACA,kBACA,oBAGN,SAAS,OAAO,QAAQ,YAAY,mBACpC;KAEC,qBACH,UAAU,eACV,kBAAkB,+BAChB,uBAAuB;EAEzB,UAAU;EACV,UAAU,UAAU,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA8FpB,iBACd,UAAU,eACV,kBAAkB,+BAChB,uBAAuB,UAEzB,UAAS,SAAS,qBAAqB,SAAS,aAChD,cAAc,SAAS,eACtB,SAAS,MAAM;;;;;;;;;;cCtHL,sBAAc;;;;;cAMd,wCAAmB,yBAAA;;;cCsCnB,oBAAW;cAeX,4BAAmB;cAQnB,uBAAc;cAMd,sBAAa"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["createContext","createRenderEffect","onCleanup","useContext","QueryClient","Accessor","JSX","QueryClientContext","undefined","queryClientContextError","useQueryClient","queryClient","client","Error","useQueryClientResolver","contextClient","resolvedClient","QueryClientProviderProps","children","Element","QueryClientProvider","props","unmount","mount","bind","_$createComponent","Provider","value","QueryCoreClient"],"sources":["../src/QueryClientProvider.tsx","../src/isRestoring.ts","../src/useBaseQuery.ts","../src/useQuery.ts","../src/useInfiniteQuery.ts","../src/useMutation.ts","../src/useQueries.ts","../src/QueryClient.ts","../src/queryOptions.ts","../src/useIsFetching.ts","../src/infiniteQueryOptions.ts","../src/mutationOptions.ts","../src/useIsMutating.ts","../src/useMutationState.ts","../src/index.ts"],"sourcesContent":["import {\n createContext,\n createRenderEffect,\n onCleanup,\n useContext,\n} from 'solid-js'\nimport type { QueryClient } from './QueryClient'\nimport type { Accessor, JSX } from 'solid-js'\n\n/**\n * The context that `useQueryClient` reads from. `QueryClientProvider` is the normal way to set it.\n */\nexport const QueryClientContext = createContext<\n (() => QueryClient) | undefined\n>(undefined)\n\nconst queryClientContextError =\n 'No QueryClient set, use QueryClientProvider to set one'\n\n/**\n * The `useQueryClient` hook returns the current `QueryClient` instance.\n *\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n * be used.\n * @returns The current `QueryClient` instance.\n * @throws If no `queryClient` argument is passed and no `QueryClientProvider` is found in the component tree.\n */\nexport const useQueryClient = (queryClient?: QueryClient) => {\n if (queryClient) {\n return queryClient\n }\n const client = useContext(QueryClientContext)\n\n if (!client) {\n throw new Error(queryClientContextError)\n }\n\n return client()\n}\n\nexport const useQueryClientResolver = (\n queryClient?: Accessor<QueryClient | undefined>,\n): Accessor<QueryClient> => {\n const contextClient = useContext(QueryClientContext)\n\n return () => {\n const resolvedClient = queryClient?.()\n if (resolvedClient) {\n return resolvedClient\n }\n\n if (!contextClient) {\n throw new Error(queryClientContextError)\n }\n\n return contextClient()\n }\n}\n\n/**\n * The props accepted by `QueryClientProvider`.\n */\nexport type QueryClientProviderProps = {\n /**\n * **Required**\n *\n * The `QueryClient` instance to provide.\n */\n client: QueryClient\n /**\n * The components that get access to the provided `QueryClient`.\n */\n children?: JSX.Element\n}\n\n/**\n * Use the `QueryClientProvider` component to connect and provide a `QueryClient` to your application. Also\n * calls `client.mount()`/`client.unmount()` as this component mounts/unmounts, which subscribes the client to\n * focus/online events (resuming any paused mutations and refetching as needed when the app regains focus or\n * comes back online).\n *\n * @returns The provided `children`, wrapped so they can read the `QueryClient` via `useQueryClient`.\n *\n * @example\n * ```tsx\n * import { QueryClient, QueryClientProvider } from '@tanstack/solid-query'\n *\n * const queryClient = new QueryClient()\n *\n * function App() {\n * return <QueryClientProvider client={queryClient}>...</QueryClientProvider>\n * }\n * ```\n */\nexport const QueryClientProvider = (\n props: QueryClientProviderProps,\n): JSX.Element => {\n createRenderEffect<() => void>((unmount) => {\n unmount?.()\n props.client.mount()\n return props.client.unmount.bind(props.client)\n })\n onCleanup(() => props.client.unmount())\n\n return (\n <QueryClientContext.Provider value={() => props.client}>\n {props.children}\n </QueryClientContext.Provider>\n )\n}\n","import { createContext, useContext } from 'solid-js'\nimport type { Accessor } from 'solid-js'\n\nconst IsRestoringContext = createContext<Accessor<boolean>>(() => false)\n\n/**\n * If you are using `PersistQueryClientProvider`, you can also use the `useIsRestoring` hook alongside it to\n * check if a restore is currently in progress. `useQuery` and friends also check this internally to avoid\n * race conditions between the restore and mounting queries.\n *\n * @returns An accessor that reads `true` while a persisted client is being restored, `false` otherwise.\n */\nexport const useIsRestoring = () => useContext(IsRestoringContext)\n\n/**\n * The Provider that `PersistQueryClientProvider` uses to signal whether a persisted client is currently\n * being restored, read by `useIsRestoring`.\n */\nexport const IsRestoringProvider = IsRestoringContext.Provider\n","// Had to disable the lint rule because isServer type is defined as false\n// in solid-js/web package. I'll create a GitHub issue with them to see\n// why that happens.\nimport { hydrate, notifyManager, shouldThrowError } from '@tanstack/query-core'\nimport { isServer } from 'solid-js/web'\nimport {\n createComputed,\n createMemo,\n createResource,\n createSignal,\n on,\n onCleanup,\n} from 'solid-js'\nimport { createStore, reconcile, unwrap } from 'solid-js/store'\nimport { useQueryClientResolver } from './QueryClientProvider'\nimport { useIsRestoring } from './isRestoring'\nimport type { UseBaseQueryOptions } from './types'\nimport type { Accessor, Signal } from 'solid-js'\nimport type { QueryClient } from './QueryClient'\nimport type {\n Query,\n QueryKey,\n QueryObserver,\n QueryObserverResult,\n} from '@tanstack/query-core'\n\nfunction reconcileFn<TData, TError>(\n store: QueryObserverResult<TData, TError>,\n result: QueryObserverResult<TData, TError>,\n reconcileOption:\n | string\n | false\n | ((oldData: TData | undefined, newData: TData) => TData),\n queryHash?: string,\n): QueryObserverResult<TData, TError> {\n if (reconcileOption === false) return result\n if (typeof reconcileOption === 'function') {\n const newData = reconcileOption(store.data, result.data as TData)\n return { ...result, data: newData } as typeof result\n }\n let data = result.data\n if (store.data === undefined) {\n try {\n data = structuredClone(data)\n } catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n if (error instanceof Error) {\n console.warn(\n `Unable to correctly reconcile data for query key: ${queryHash}. ` +\n `Possibly because the query data contains data structures that aren't supported ` +\n `by the 'structuredClone' algorithm. Consider using a callback function instead ` +\n `to manage the reconciliation manually.\\n\\n Error Received: ${error.name} - ${error.message}`,\n )\n }\n }\n }\n }\n const newData = reconcile(data, { key: reconcileOption })(store.data)\n return { ...result, data: newData } as typeof result\n}\n\n/**\n * Solid's `onHydrated` functionality will silently \"fail\" (hydrate with an empty object)\n * if the resource data is not serializable.\n */\nconst hydratableObserverResult = <\n TQueryFnData,\n TError,\n TData,\n TQueryKey extends QueryKey,\n TDataHydratable,\n>(\n query: Query<TQueryFnData, TError, TData, TQueryKey>,\n result: QueryObserverResult<TDataHydratable, TError>,\n) => {\n if (!isServer) return result\n const obj: any = {\n ...unwrap(result),\n // During SSR, functions cannot be serialized, so we need to remove them\n // This is safe because we will add these functions back when the query is hydrated\n refetch: undefined,\n }\n\n // If the query is an infinite query, we need to remove additional properties\n if ('fetchNextPage' in result) {\n obj.fetchNextPage = undefined\n obj.fetchPreviousPage = undefined\n }\n\n // We will also attach the dehydrated state of the query to the result\n // This will be removed on client after hydration\n obj.hydrationData = {\n state: query.state,\n queryKey: query.queryKey,\n queryHash: query.queryHash,\n ...(query.meta && { meta: query.meta }),\n }\n\n return obj\n}\n\n// Base Query Function that is used to create the query.\nexport function useBaseQuery<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey,\n>(\n options: Accessor<\n UseBaseQueryOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>\n >,\n Observer: typeof QueryObserver,\n queryClient?: Accessor<QueryClient>,\n) {\n type ResourceData = QueryObserverResult<TData, TError>\n\n const resolveClient = useQueryClientResolver(queryClient)\n const client = createMemo(() => resolveClient())\n const isRestoring = useIsRestoring()\n // There are times when we run a query on the server but the resource is never read\n // This could lead to times when the queryObserver is unsubscribed before the resource has loaded\n // Causing a time out error. To prevent this we will queue the unsubscribe if the cleanup is called\n // before the resource has loaded\n let unsubscribeQueued = false\n\n const defaultedOptions = createMemo(() => {\n const defaultOptions = client().defaultQueryOptions(options())\n defaultOptions._optimisticResults = isRestoring()\n ? 'isRestoring'\n : 'optimistic'\n defaultOptions.structuralSharing = false\n if (isServer) {\n defaultOptions.retry = false\n defaultOptions.throwOnError = true\n }\n return defaultOptions\n })\n const initialOptions = defaultedOptions()\n\n const [observer, setObserver] = createSignal(\n new Observer(client(), defaultedOptions()),\n )\n\n let observerResult = observer().getOptimisticResult(defaultedOptions())\n const [state, setState] =\n createStore<QueryObserverResult<TData, TError>>(observerResult)\n\n const createServerSubscriber = (\n resolve: (\n data: ResourceData | PromiseLike<ResourceData | undefined> | undefined,\n ) => void,\n reject: (reason?: any) => void,\n ) => {\n return observer().subscribe((result) => {\n notifyManager.batchCalls(() => {\n const query = observer().getCurrentQuery()\n const unwrappedResult = hydratableObserverResult(query, result)\n\n if (result.data !== undefined && unwrappedResult.isError) {\n reject(unwrappedResult.error)\n unsubscribeIfQueued()\n } else {\n resolve(unwrappedResult)\n unsubscribeIfQueued()\n }\n })()\n })\n }\n\n const unsubscribeIfQueued = () => {\n if (unsubscribeQueued) {\n unsubscribe?.()\n unsubscribeQueued = false\n }\n }\n\n const createClientSubscriber = () => {\n const obs = observer()\n return obs.subscribe((result) => {\n observerResult = result\n queueMicrotask(() => {\n if (unsubscribe) {\n refetch()\n }\n })\n })\n }\n\n function setStateWithReconciliation(res: typeof observerResult) {\n const opts = observer().options\n // @ts-expect-error - Reconcile option is not correctly typed internally\n const reconcileOptions = opts.reconcile\n\n setState((store) => {\n return reconcileFn(\n store,\n res,\n reconcileOptions === undefined ? false : reconcileOptions,\n opts.queryHash,\n )\n })\n }\n\n function createDeepSignal<T>(): Signal<T> {\n return [\n () => state,\n (v: any) => {\n const unwrapped = unwrap(state)\n if (typeof v === 'function') {\n v = v(unwrapped)\n }\n // Hydration data exists on first load after SSR,\n // and should be removed from the observer result\n if (v?.hydrationData) {\n const { hydrationData, ...rest } = v\n v = rest\n }\n setStateWithReconciliation(v)\n },\n ] as Signal<T>\n }\n\n /**\n * Unsubscribe is set lazily, so that we can subscribe after hydration when needed.\n */\n let unsubscribe: (() => void) | null = null\n\n /*\n Fixes #7275\n In a few cases, the observer could unmount before the resource is loaded.\n This leads to Suspense boundaries to be suspended indefinitely.\n This resolver will be called when the observer is unmounting\n but the resource is still in a loading state\n */\n let resolver: ((value: ResourceData) => void) | null = null\n const [queryResource, { refetch }] = createResource<ResourceData | undefined>(\n () => {\n const obs = observer()\n return new Promise((resolve, reject) => {\n resolver = resolve\n if (isServer) {\n unsubscribe = createServerSubscriber(resolve, reject)\n } else if (!unsubscribe && !isRestoring()) {\n unsubscribe = createClientSubscriber()\n }\n obs.updateResult()\n\n if (\n observerResult.isError &&\n !observerResult.isFetching &&\n !isRestoring() &&\n shouldThrowError(obs.options.throwOnError, [\n observerResult.error,\n obs.getCurrentQuery(),\n ])\n ) {\n setStateWithReconciliation(observerResult)\n return reject(observerResult.error)\n }\n if (!observerResult.isLoading) {\n resolver = null\n return resolve(\n hydratableObserverResult(obs.getCurrentQuery(), observerResult),\n )\n }\n\n setStateWithReconciliation(observerResult)\n })\n },\n {\n storage: createDeepSignal,\n\n get deferStream() {\n return options().deferStream\n },\n\n /**\n * If this resource was populated on the server (either sync render, or streamed in over time), onHydrated\n * will be called. This is the point at which we can hydrate the query cache state, and setup the query subscriber.\n *\n * Leveraging onHydrated allows us to plug into the async and streaming support that solidjs resources already support.\n *\n * Note that this is only invoked on the client, for queries that were originally run on the server.\n */\n onHydrated(_k, info) {\n if (info.value && 'hydrationData' in info.value) {\n hydrate(client(), {\n // @ts-expect-error - hydrationData is not correctly typed internally\n queries: [{ ...info.value.hydrationData }],\n })\n }\n\n if (unsubscribe) return\n /**\n * Do not refetch query on mount if query was fetched on server,\n * even if `staleTime` is not set.\n */\n const newOptions = { ...initialOptions }\n if (\n (initialOptions.staleTime || !initialOptions.initialData) &&\n info.value\n ) {\n newOptions.refetchOnMount = false\n }\n // Setting the options as an immutable object to prevent\n // wonky behavior with observer subscriptions\n observer().setOptions(newOptions)\n setStateWithReconciliation(observer().getOptimisticResult(newOptions))\n unsubscribe = createClientSubscriber()\n },\n },\n )\n\n createComputed(\n on(\n client,\n (c) => {\n if (unsubscribe) {\n unsubscribe()\n }\n const newObserver = new Observer(c, defaultedOptions())\n unsubscribe = createClientSubscriber()\n setObserver(newObserver)\n },\n {\n defer: true,\n },\n ),\n )\n\n createComputed(\n on(\n isRestoring,\n (restoring) => {\n if (!restoring && !isServer) {\n refetch()\n }\n },\n { defer: true },\n ),\n )\n\n onCleanup(() => {\n if (isServer && queryResource.loading) {\n unsubscribeQueued = true\n return\n }\n if (unsubscribe) {\n unsubscribe()\n unsubscribe = null\n }\n if (resolver && !isServer) {\n resolver(observerResult)\n resolver = null\n }\n })\n\n createComputed(\n on(\n [observer, defaultedOptions],\n ([obs, opts]) => {\n obs.setOptions(opts)\n setStateWithReconciliation(obs.getOptimisticResult(opts))\n refetch()\n },\n { defer: true },\n ),\n )\n\n const handler = {\n get(\n target: QueryObserverResult<TData, TError>,\n prop: keyof QueryObserverResult<TData, TError>,\n ): any {\n if (prop === 'data') {\n if (state.data !== undefined) {\n return queryResource.latest?.data\n }\n return queryResource()?.data\n }\n return Reflect.get(target, prop)\n },\n }\n\n return new Proxy(state, handler)\n}\n","import { QueryObserver } from '@tanstack/query-core'\nimport { createMemo } from 'solid-js'\nimport { useBaseQuery } from './useBaseQuery'\nimport type { DefaultError, QueryKey } from '@tanstack/query-core'\nimport type { QueryClient } from './QueryClient'\nimport type { Accessor } from 'solid-js'\nimport type {\n DefinedUseQueryResult,\n UseQueryOptions,\n UseQueryResult,\n} from './types'\nimport type {\n DefinedInitialDataOptions,\n UndefinedInitialDataOptions,\n} from './queryOptions'\n\n/**\n * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.\n * @param options - An accessor returning the {@link UndefinedInitialDataOptions} to use — everything you can\n * pass to `useQuery`.\n * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns The current query result, as a Solid store. `status` is `pending` if there is no cached data to\n * display, `error` if the last fetch attempt failed, or `success` if the query has data to display.\n * `isPending`/`isSuccess`/`isError` are derived booleans for convenience.\n *\n * @example\n * ```tsx\n * import { For, Match, Switch } from 'solid-js'\n * import { useQuery } from '@tanstack/solid-query'\n *\n * function Posts() {\n * const postsQuery = useQuery(() => ({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * }))\n *\n * return (\n * <Switch>\n * <Match when={postsQuery.isPending}>Loading...</Match>\n * <Match when={postsQuery.isError}>Error: {postsQuery.error.message}</Match>\n * <Match when={postsQuery.isSuccess}>\n * <ul>\n * <For each={postsQuery.data}>{(post) => <li>{post.title}</li>}</For>\n * </ul>\n * <div>{postsQuery.isFetching ? 'Background Updating...' : ' '}</div>\n * </Match>\n * </Switch>\n * )\n * }\n * ```\n *\n * @example\n * `select` derives whatever `data` a component needs from the cached value, without changing what's\n * actually stored in the cache — the cache still holds the full `Post[]`, but `data` here is a `number`:\n * ```tsx\n * import { Match, Switch } from 'solid-js'\n * import { useQuery } from '@tanstack/solid-query'\n *\n * function PostCount() {\n * const postsQuery = useQuery(() => ({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * select: (posts) => posts.length,\n * }))\n *\n * return (\n * <Switch>\n * <Match when={postsQuery.isPending}>Loading...</Match>\n * <Match when={postsQuery.isError}>Error: {postsQuery.error.message}</Match>\n * <Match when={postsQuery.isSuccess}>{postsQuery.data} posts</Match>\n * </Switch>\n * )\n * }\n * ```\n *\n * @example\n * A dependent query, only enabled once `postId` is set:\n * ```tsx\n * import { Match, Switch } from 'solid-js'\n * import { useQuery } from '@tanstack/solid-query'\n *\n * function Post(props: { postId: number | undefined }) {\n * const postQuery = useQuery(() => ({\n * queryKey: ['post', props.postId],\n * queryFn: () => fetchPost(props.postId!),\n * enabled: props.postId != null,\n * }))\n *\n * return (\n * <Switch fallback={<h1>{postQuery.data?.title}</h1>}>\n * <Match when={props.postId == null}>Select a post</Match>\n * <Match when={postQuery.isLoading}>Loading...</Match>\n * <Match when={postQuery.isError}>Error: {postQuery.error.message}</Match>\n * </Switch>\n * )\n * }\n * ```\n *\n * @example\n * The same dependent query, using `skipToken` to disable it in a type-safe way instead of relying on\n * `enabled`. The non-null assertion is still needed — Solid's `props` narrowing doesn't survive into the\n * `queryFn` closure the way a local `const` would — but `skipToken` keeps `queryFn`'s return type accurate\n * without it. `refetch` doesn't work while `queryFn` is `skipToken` — use `enabled: false` instead if you\n * need to trigger the query manually:\n * ```tsx\n * import { Match, Switch } from 'solid-js'\n * import { skipToken, useQuery } from '@tanstack/solid-query'\n *\n * function Post(props: { postId: number | undefined }) {\n * const postQuery = useQuery(() => ({\n * queryKey: ['post', props.postId],\n * queryFn: props.postId != null ? () => fetchPost(props.postId!) : skipToken,\n * }))\n *\n * return (\n * <Switch fallback={<h1>{postQuery.data?.title}</h1>}>\n * <Match when={props.postId == null}>Select a post</Match>\n * <Match when={postQuery.isLoading}>Loading...</Match>\n * <Match when={postQuery.isError}>Error: {postQuery.error.message}</Match>\n * </Switch>\n * )\n * }\n * ```\n *\n * @example\n * Seeding a detail query from an already-cached list, to skip the loading state:\n * ```tsx\n * import { useQuery, useQueryClient } from '@tanstack/solid-query'\n *\n * function Post(props: { postId: number }) {\n * const queryClient = useQueryClient()\n *\n * const postQuery = useQuery(() => ({\n * queryKey: ['post', props.postId],\n * queryFn: () => fetchPost(props.postId),\n * initialData: () =>\n * queryClient\n * .getQueryData<Array<Post>>(['posts'])\n * ?.find((post) => post.id === props.postId),\n * }))\n *\n * return postQuery.isError ? <span>Error: {postQuery.error.message}</span> : <h1>{postQuery.data?.title}</h1>\n * }\n * ```\n *\n * @example\n * Paginated data, keeping the previous page's data visible while the next page loads:\n * ```tsx\n * import { For, createSignal } from 'solid-js'\n * import { keepPreviousData, useQuery } from '@tanstack/solid-query'\n *\n * function Posts() {\n * const [page, setPage] = createSignal(0)\n *\n * const postsQuery = useQuery(() => ({\n * queryKey: ['posts', page()],\n * queryFn: () => fetchPosts(page()),\n * placeholderData: keepPreviousData,\n * }))\n *\n * return (\n * <div>\n * <ul>\n * <For each={postsQuery.data}>{(post) => <li>{post.title}</li>}</For>\n * </ul>\n * <button\n * disabled={postsQuery.isPlaceholderData}\n * onClick={() => setPage((old) => old + 1)}\n * >\n * Next Page\n * </button>\n * </div>\n * )\n * }\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: () => QueryClient,\n): UseQueryResult<TData, TError>\n\n/**\n * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined`.\n *\n * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.\n * @param options - An accessor returning the {@link DefinedInitialDataOptions} to use — everything you can\n * pass to `useQuery`, with `initialData` set.\n * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns The current query result, as a Solid store, typed so that `status` is `success` — or `error` if a\n * fetch attempt fails while keeping the existing data (`status` never resolves to `pending` in this overload's\n * type, since `initialData` guarantees data upfront). `isSuccess`/`isError` are derived booleans for\n * convenience.\n *\n * @example\n * ```tsx\n * import { For } from 'solid-js'\n * import { useQuery } from '@tanstack/solid-query'\n *\n * function Posts() {\n * // `postsQuery.data` is never `undefined`, thanks to `initialData` — even if a refetch fails, so the\n * // list stays visible alongside the error.\n * const postsQuery = useQuery(() => ({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * initialData: [],\n * }))\n *\n * return (\n * <div>\n * {postsQuery.isError ? <span>Error: {postsQuery.error.message}</span> : null}\n * <ul>\n * <For each={postsQuery.data}>{(post) => <li>{post.title}</li>}</For>\n * </ul>\n * </div>\n * )\n * }\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: () => QueryClient,\n): DefinedUseQueryResult<TData, TError>\nexport function useQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: Accessor<QueryClient>,\n) {\n return useBaseQuery(\n createMemo(() => options()),\n QueryObserver,\n queryClient,\n )\n}\n","import { InfiniteQueryObserver } from '@tanstack/query-core'\nimport { createMemo } from 'solid-js'\nimport { useBaseQuery } from './useBaseQuery'\nimport type {\n DefaultError,\n InfiniteData,\n QueryKey,\n QueryObserver,\n} from '@tanstack/query-core'\nimport type { QueryClient } from './QueryClient'\nimport type {\n DefinedUseInfiniteQueryResult,\n UseInfiniteQueryOptions,\n UseInfiniteQueryResult,\n} from './types'\nimport type { Accessor } from 'solid-js'\nimport type {\n DefinedInitialDataInfiniteOptions,\n UndefinedInitialDataInfiniteOptions,\n} from './infiniteQueryOptions'\n\n/**\n * The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of\n * `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`.\n *\n * This overload is selected when `initialData` is set.\n *\n * @remarks Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default\n * refetch behavior, resulting in outdated data. Make sure to call these functions only in response to user\n * actions, or add conditions like `hasNextPage && !isFetching`.\n * @see {@link infiniteQueryOptions} to share these options between `useInfiniteQuery` and imperative APIs like `queryClient.infiniteQuery`.\n * @param options - An accessor returning the {@link DefinedInitialDataInfiniteOptions} to use — everything you\n * can pass to `useInfiniteQuery`, with `initialData` set.\n * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns The same properties as `useQuery`, with the addition of `fetchNextPage`, `fetchPreviousPage`,\n * `hasNextPage`, `hasPreviousPage`, `isFetchingNextPage`, and `isFetchingPreviousPage`. `data.pages` and\n * `data.pageParams` are also added, as long as a `select` doesn't change `TData` away from its default\n * `InfiniteData<TQueryFnData>` shape.\n *\n * @example\n * ```tsx\n * import { For } from 'solid-js'\n * import { useInfiniteQuery } from '@tanstack/solid-query'\n *\n * function Projects() {\n * // `projectsQuery.data` is never `undefined`, thanks to `initialData` — even if a refetch fails, so the\n * // list stays visible alongside the error.\n * const projectsQuery = useInfiniteQuery(() => ({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * initialData: { pages: [], pageParams: [] },\n * }))\n *\n * return (\n * <div>\n * {projectsQuery.isError ? <span>Error: {projectsQuery.error.message}</span> : null}\n * <ul>\n * <For each={projectsQuery.data.pages}>\n * {(page) => <For each={page.projects}>{(p) => <li>{p.name}</li>}</For>}\n * </For>\n * </ul>\n * </div>\n * )\n * }\n * ```\n */\nexport function useInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n queryClient?: Accessor<QueryClient>,\n): DefinedUseInfiniteQueryResult<TData, TError>\n\n/**\n * The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of\n * `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`.\n *\n * @remarks Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default\n * refetch behavior, resulting in outdated data. Make sure to call these functions only in response to user\n * actions, or add conditions like `hasNextPage && !isFetching`.\n * @see {@link infiniteQueryOptions} to share these options between `useInfiniteQuery` and imperative APIs like `queryClient.infiniteQuery`.\n * @param options - An accessor returning the {@link UndefinedInitialDataInfiniteOptions} to use — everything\n * you can pass to `useInfiniteQuery`.\n * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns The same properties as `useQuery`, with the addition of `fetchNextPage`, `fetchPreviousPage`,\n * `hasNextPage`, `hasPreviousPage`, `isFetchingNextPage`, and `isFetchingPreviousPage`. `data.pages` and\n * `data.pageParams` are also added, as long as a `select` doesn't change `TData` away from its default\n * `InfiniteData<TQueryFnData>` shape.\n *\n * @example\n * Fetching the next page from a \"Load More\" button click:\n * ```tsx\n * import { For, Match, Switch } from 'solid-js'\n * import { useInfiniteQuery } from '@tanstack/solid-query'\n *\n * function Projects() {\n * const projectsQuery = useInfiniteQuery(() => ({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * }))\n *\n * return (\n * <Switch>\n * <Match when={projectsQuery.isPending}>Loading...</Match>\n * <Match when={projectsQuery.isError}>Error: {projectsQuery.error.message}</Match>\n * <Match when={projectsQuery.isSuccess}>\n * <ul>\n * <For each={projectsQuery.data.pages}>\n * {(page) => <For each={page.projects}>{(p) => <li>{p.name}</li>}</For>}\n * </For>\n * </ul>\n * <button\n * onClick={() => projectsQuery.fetchNextPage()}\n * disabled={!projectsQuery.hasNextPage || projectsQuery.isFetching}\n * >\n * {projectsQuery.isFetchingNextPage\n * ? 'Loading more...'\n * : projectsQuery.hasNextPage\n * ? 'Load More'\n * : 'Nothing more to load'}\n * </button>\n * </Match>\n * </Switch>\n * )\n * }\n * ```\n *\n * @example\n * Fetching the next page automatically as the user scrolls, using an `IntersectionObserver` on a\n * sentinel element after the list:\n * ```tsx\n * import { For, Match, Switch, createEffect, onCleanup } from 'solid-js'\n * import { useInfiniteQuery } from '@tanstack/solid-query'\n *\n * function Projects() {\n * const projectsQuery = useInfiniteQuery(() => ({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * }))\n *\n * let sentinelRef: HTMLDivElement | undefined\n *\n * createEffect(() => {\n * if (sentinelRef == null || !projectsQuery.hasNextPage || projectsQuery.isFetching) return\n *\n * const observer = new IntersectionObserver(([entry]) => {\n * if (entry?.isIntersecting) projectsQuery.fetchNextPage()\n * })\n * observer.observe(sentinelRef)\n *\n * onCleanup(() => observer.disconnect())\n * })\n *\n * return (\n * <Switch>\n * <Match when={projectsQuery.isPending}>Loading...</Match>\n * <Match when={projectsQuery.isError}>Error: {projectsQuery.error.message}</Match>\n * <Match when={projectsQuery.isSuccess}>\n * <ul>\n * <For each={projectsQuery.data.pages}>\n * {(page) => <For each={page.projects}>{(p) => <li>{p.name}</li>}</For>}\n * </For>\n * </ul>\n * <div ref={sentinelRef}>{projectsQuery.isFetchingNextPage ? 'Loading more...' : null}</div>\n * </Match>\n * </Switch>\n * )\n * }\n * ```\n */\nexport function useInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n queryClient?: Accessor<QueryClient>,\n): UseInfiniteQueryResult<TData, TError>\n\nexport function useInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n queryClient?: Accessor<QueryClient>,\n): UseInfiniteQueryResult<TData, TError> {\n return useBaseQuery(\n createMemo(() => options()),\n InfiniteQueryObserver as typeof QueryObserver,\n queryClient,\n ) as UseInfiniteQueryResult<TData, TError>\n}\n","import { MutationObserver, noop, shouldThrowError } from '@tanstack/query-core'\nimport { createComputed, createMemo, on, onCleanup } from 'solid-js'\nimport { createStore } from 'solid-js/store'\nimport { useQueryClientResolver } from './QueryClientProvider'\nimport type { DefaultError } from '@tanstack/query-core'\nimport type { QueryClient } from './QueryClient'\nimport type {\n UseMutateFunction,\n UseMutationOptions,\n UseMutationResult,\n} from './types'\nimport type { Accessor } from 'solid-js'\n\n/**\n * @param options - An accessor returning the {@link UseMutationOptions} to use.\n * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns `mutate`/`mutateAsync` also accept per-call `onSuccess`/`onError`/`onSettled` callbacks as a second\n * argument, useful for triggering call-site side effects (e.g. navigation) without coupling them to the shared\n * mutation definition. Hook-level callbacks (passed to `options`) fire for every mutation; per-call callbacks\n * fire only for the latest call you've made, and only while the component is still mounted — unmounting before\n * the mutation settles removes the subscription and prevents them from firing.\n *\n * @example\n * ```tsx\n * import { useMutation, useQueryClient } from '@tanstack/solid-query'\n *\n * function TodoItem(props: { id: number }) {\n * const queryClient = useQueryClient()\n *\n * const deleteTodoMutation = useMutation(() => ({\n * mutationFn: deleteTodo,\n * onSuccess: () => {\n * queryClient.invalidateQueries({ queryKey: ['todos'] })\n * },\n * }))\n *\n * return (\n * <button onClick={() => deleteTodoMutation.mutate({ id: props.id })} disabled={deleteTodoMutation.isPending}>\n * Delete\n * </button>\n * )\n * }\n * ```\n *\n * @example\n * Rendering the mutation's own state, rather than just firing it off:\n * ```tsx\n * import { Match, Switch } from 'solid-js'\n * import { useMutation, useQueryClient } from '@tanstack/solid-query'\n *\n * function AddTodo() {\n * const queryClient = useQueryClient()\n *\n * const addMutation = useMutation(() => ({\n * mutationFn: addTodo,\n * onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),\n * }))\n *\n * return (\n * <Switch fallback={<button onClick={() => addMutation.mutate('Item')}>Add</button>}>\n * <Match when={addMutation.isPending}>Adding todo...</Match>\n * <Match when={addMutation.isError}>\n * <div>An error occurred: {addMutation.error?.message}</div>\n * <button onClick={() => addMutation.mutate('Item')}>Add</button>\n * </Match>\n * </Switch>\n * )\n * }\n * ```\n *\n * @example\n * Optimistic update via `onMutate`, rolling back on `onError`:\n * ```tsx\n * import { useMutation, useQueryClient } from '@tanstack/solid-query'\n *\n * function AddTodo() {\n * const queryClient = useQueryClient()\n *\n * const addMutation = useMutation(() => ({\n * mutationFn: addTodo,\n * onMutate: async (newTodo) => {\n * await queryClient.cancelQueries({ queryKey: ['todos'] })\n * const previousTodos = queryClient.getQueryData<Array<string>>(['todos'])\n *\n * queryClient.setQueryData<Array<string>>(['todos'], (old) => [\n * ...(old ?? []),\n * newTodo,\n * ])\n *\n * // Passed to `onError` as `onMutateResult` if the mutation fails.\n * return { previousTodos }\n * },\n * onError: (_err, _newTodo, onMutateResult) => {\n * queryClient.setQueryData(['todos'], onMutateResult?.previousTodos)\n * },\n * onSettled: () => {\n * queryClient.invalidateQueries({ queryKey: ['todos'] })\n * },\n * }))\n *\n * return (\n * <button onClick={() => addMutation.mutate('Item')}>Add</button>\n * )\n * }\n * ```\n *\n * @example\n * Callbacks passed per call to `mutate` only fire for the last call — `mutateAsync` gives you a\n * promise per call instead, so you can wait for all of them when they succeed:\n * ```tsx\n * import { useMutation, useQueryClient } from '@tanstack/solid-query'\n *\n * function AddTodos() {\n * const queryClient = useQueryClient()\n *\n * const addMutation = useMutation(() => ({\n * mutationFn: addTodo,\n * onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),\n * }))\n *\n * async function handleAddAll(todos: Array<string>) {\n * try {\n * await Promise.all(todos.map((todo) => addMutation.mutateAsync(todo)))\n * } catch (error) {\n * console.error('Failed to add todos:', error)\n * }\n * }\n *\n * return (\n * <button onClick={() => handleAddAll(['Todo 1', 'Todo 2', 'Todo 3'])}>\n * Add all\n * </button>\n * )\n * }\n * ```\n *\n * @example\n * If some of the mutations above can fail independently of the others, and you want to know which ones\n * did — rather than losing that information the moment the first one rejects — swap `Promise.all` for\n * `Promise.allSettled`:\n * ```tsx\n * import { useMutation, useQueryClient } from '@tanstack/solid-query'\n *\n * function AddTodos() {\n * const queryClient = useQueryClient()\n *\n * const addMutation = useMutation(() => ({\n * mutationFn: addTodo,\n * onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),\n * }))\n *\n * async function handleAddAll(todos: Array<string>) {\n * const addResults = await Promise.allSettled(\n * todos.map((todo) => addMutation.mutateAsync(todo)),\n * )\n *\n * addResults.forEach((addResult, index) => {\n * if (addResult.status === 'rejected') {\n * console.error(`Failed to add \"${todos[index]}\":`, addResult.reason)\n * }\n * })\n * }\n *\n * return (\n * <button onClick={() => handleAddAll(['Todo 1', 'Todo 2', 'Todo 3'])}>\n * Add all\n * </button>\n * )\n * }\n * ```\n */\nexport function useMutation<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n>(\n options: UseMutationOptions<TData, TError, TVariables, TOnMutateResult>,\n queryClient?: Accessor<QueryClient>,\n): UseMutationResult<TData, TError, TVariables, TOnMutateResult> {\n const resolveClient = useQueryClientResolver(queryClient)\n const client = createMemo(() => resolveClient())\n\n const observer = new MutationObserver<\n TData,\n TError,\n TVariables,\n TOnMutateResult\n >(client(), options())\n\n const mutate: UseMutateFunction<\n TData,\n TError,\n TVariables,\n TOnMutateResult\n > = (...args) => {\n observer.mutate(args[0] as TVariables, args[1]).catch(noop)\n }\n\n const [state, setState] = createStore<\n UseMutationResult<TData, TError, TVariables, TOnMutateResult>\n >({\n ...observer.getCurrentResult(),\n mutate,\n mutateAsync: observer.getCurrentResult().mutate,\n })\n\n createComputed(() => {\n observer.setOptions(options())\n })\n\n createComputed(\n on(\n () => state.status,\n () => {\n if (\n state.isError &&\n shouldThrowError(observer.options.throwOnError, [state.error])\n ) {\n throw state.error\n }\n },\n ),\n )\n\n const unsubscribe = observer.subscribe((result) => {\n setState({\n ...result,\n mutate,\n mutateAsync: result.mutate,\n })\n })\n\n onCleanup(unsubscribe)\n\n return state\n}\n","import { QueriesObserver, noop } from '@tanstack/query-core'\nimport { createStore, unwrap } from 'solid-js/store'\nimport {\n batch,\n createComputed,\n createMemo,\n createRenderEffect,\n createResource,\n mergeProps,\n on,\n onCleanup,\n onMount,\n} from 'solid-js'\nimport { useQueryClientResolver } from './QueryClientProvider'\nimport { useIsRestoring } from './isRestoring'\nimport type { QueryOptions, UseQueryResult } from './types'\nimport type { Accessor } from 'solid-js'\nimport type { QueryClient } from './QueryClient'\nimport type {\n DefaultError,\n OmitKeyof,\n QueriesObserverOptions,\n QueriesPlaceholderDataFunction,\n QueryFunction,\n QueryKey,\n QueryObserverOptions,\n QueryObserverResult,\n ThrowOnError,\n} from '@tanstack/query-core'\n\n// This defines the `UseQueryOptions` that are accepted in `QueriesOptions` & `GetOptions`.\n// `placeholderData` function does not have a parameter\ntype UseQueryOptionsForUseQueries<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = OmitKeyof<\n QueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n 'placeholderData' | 'suspense'\n> & {\n placeholderData?: TQueryFnData | QueriesPlaceholderDataFunction<TQueryFnData>\n /**\n * @deprecated The `suspense` option has been deprecated in v5 and will be removed in the next major version.\n * The `data` property on useQueries is a plain object and not a SolidJS Resource.\n * It will not suspend when the data is loading.\n * Setting `suspense` to `true` will be a no-op.\n */\n suspense?: boolean\n}\n\n// Avoid TS depth-limit error in case of large array literal\ntype MAXIMUM_DEPTH = 20\n\n// Widen the type of the symbol to enable type inference even if skipToken is not immutable.\ntype SkipTokenForUseQueries = symbol\n\ntype GetOptions<T> =\n // Part 1: responsible for applying explicit type parameter to function arguments, if object { queryFnData: TQueryFnData, error: TError, data: TData }\n T extends {\n queryFnData: infer TQueryFnData\n error?: infer TError\n data: infer TData\n }\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError, TData>\n : T extends { queryFnData: infer TQueryFnData; error?: infer TError }\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError>\n : T extends { data: infer TData; error?: infer TError }\n ? UseQueryOptionsForUseQueries<unknown, TError, TData>\n : // Part 2: responsible for applying explicit type parameter to function arguments, if tuple [TQueryFnData, TError, TData]\n T extends [infer TQueryFnData, infer TError, infer TData]\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError, TData>\n : T extends [infer TQueryFnData, infer TError]\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError>\n : T extends [infer TQueryFnData]\n ? UseQueryOptionsForUseQueries<TQueryFnData>\n : // Part 3: responsible for inferring and enforcing type if no explicit parameter was provided\n T extends {\n queryFn?:\n | QueryFunction<infer TQueryFnData, infer TQueryKey>\n | SkipTokenForUseQueries\n select?: (data: any) => infer TData\n throwOnError?: ThrowOnError<any, infer TError, any, any>\n }\n ? UseQueryOptionsForUseQueries<\n TQueryFnData,\n unknown extends TError ? DefaultError : TError,\n unknown extends TData ? TQueryFnData : TData,\n TQueryKey\n >\n : // Fallback\n UseQueryOptionsForUseQueries\n\ntype GetResults<T> =\n // Part 1: responsible for mapping explicit type parameter to function result, if object\n T extends { queryFnData: any; error?: infer TError; data: infer TData }\n ? UseQueryResult<TData, TError>\n : T extends { queryFnData: infer TQueryFnData; error?: infer TError }\n ? UseQueryResult<TQueryFnData, TError>\n : T extends { data: infer TData; error?: infer TError }\n ? UseQueryResult<TData, TError>\n : // Part 2: responsible for mapping explicit type parameter to function result, if tuple\n T extends [any, infer TError, infer TData]\n ? UseQueryResult<TData, TError>\n : T extends [infer TQueryFnData, infer TError]\n ? UseQueryResult<TQueryFnData, TError>\n : T extends [infer TQueryFnData]\n ? UseQueryResult<TQueryFnData>\n : // Part 3: responsible for mapping inferred type to results, if no explicit parameter was provided\n T extends {\n queryFn?:\n | QueryFunction<infer TQueryFnData, any>\n | SkipTokenForUseQueries\n select?: (data: any) => infer TData\n throwOnError?: ThrowOnError<any, infer TError, any, any>\n }\n ? UseQueryResult<\n unknown extends TData ? TQueryFnData : TData,\n unknown extends TError ? DefaultError : TError\n >\n : // Fallback\n UseQueryResult\n\n/**\n * QueriesOptions reducer recursively unwraps function arguments to infer/enforce type param\n */\ntype QueriesOptions<\n T extends Array<any>,\n TResult extends Array<any> = [],\n TDepth extends ReadonlyArray<number> = [],\n> = TDepth['length'] extends MAXIMUM_DEPTH\n ? Array<UseQueryOptionsForUseQueries>\n : T extends []\n ? []\n : T extends [infer Head]\n ? [...TResult, GetOptions<Head>]\n : T extends [infer Head, ...infer Tail]\n ? QueriesOptions<\n [...Tail],\n [...TResult, GetOptions<Head>],\n [...TDepth, 1]\n >\n : ReadonlyArray<unknown> extends T\n ? T\n : // If T is *some* array but we couldn't assign unknown[] to it, then it must hold some known/homogeneous type!\n // use this to infer the param types in the case of Array.map() argument\n T extends Array<\n UseQueryOptionsForUseQueries<\n infer TQueryFnData,\n infer TError,\n infer TData,\n infer TQueryKey\n >\n >\n ? Array<\n UseQueryOptionsForUseQueries<\n TQueryFnData,\n TError,\n TData,\n TQueryKey\n >\n >\n : // Fallback\n Array<UseQueryOptionsForUseQueries>\n\n/**\n * QueriesResults reducer recursively maps type param to results\n */\ntype QueriesResults<\n T extends Array<any>,\n TResult extends Array<any> = [],\n TDepth extends ReadonlyArray<number> = [],\n> = TDepth['length'] extends MAXIMUM_DEPTH\n ? Array<UseQueryResult>\n : T extends []\n ? []\n : T extends [infer Head]\n ? [...TResult, GetResults<Head>]\n : T extends [infer Head, ...infer Tail]\n ? QueriesResults<\n [...Tail],\n [...TResult, GetResults<Head>],\n [...TDepth, 1]\n >\n : { [K in keyof T]: GetResults<T[K]> }\n\n/**\n * The `useQueries` hook can be used to fetch a variable number of queries.\n *\n * The `queries` key accepts an array with query option objects mostly identical to `useQuery` — see\n * `placeholderData` below for the one difference. A custom `QueryClient` is supplied once, as `useQueries`'\n * own top-level second argument, rather than per query.\n *\n * Having the same query key more than once in the array of query objects may cause some data to be shared\n * between queries. To avoid this, consider de-duplicating the queries and map the results back to the desired\n * structure.\n *\n * The `combine` option can be used to combine the results of the queries into a single value. The result will\n * be structurally shared to be as referentially stable as possible.\n *\n * `placeholderData` is supported here too, but unlike `useQuery`, it doesn't receive information from\n * previously rendered queries, because the number of queries can differ between renders.\n * @param queriesOptions - An accessor returning the `queries` array to run, and an optional `combine`\n * function.\n * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns The combined result. Without `combine`, this is an array with all the query results, in the same\n * order as the input. When `combine` is provided, this is the value returned by `combine` instead.\n *\n * @example\n * ```tsx\n * import { For } from 'solid-js'\n * import { useQueries } from '@tanstack/solid-query'\n *\n * function Posts(props: { ids: Array<number> }) {\n * const postQueries = useQueries(() => ({\n * queries: props.ids.map((id) => ({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * staleTime: Infinity,\n * })),\n * }))\n *\n * return (\n * <ul>\n * <For each={postQueries}>\n * {(postQuery) => {\n * if (postQuery.isPending) return <li>Loading...</li>\n * if (postQuery.isError) return <li>Error: {postQuery.error.message}</li>\n * return <li>{postQuery.data.title}</li>\n * }}\n * </For>\n * </ul>\n * )\n * }\n * ```\n *\n * @example\n * Combining results into a single value:\n * ```tsx\n * import { For, Match, Switch } from 'solid-js'\n * import { useQueries } from '@tanstack/solid-query'\n *\n * function Posts(props: { ids: Array<number> }) {\n * const combinedPostsQuery = useQueries(() => ({\n * queries: props.ids.map((id) => ({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })),\n * combine: (postQueries) => {\n * return {\n * data: postQueries.map((postQuery) => postQuery.data),\n * isPending: postQueries.some((postQuery) => postQuery.isPending),\n * isError: postQueries.some((postQuery) => postQuery.isError),\n * }\n * },\n * }))\n *\n * return (\n * <Switch\n * fallback={\n * <ul>\n * <For each={combinedPostsQuery.data}>{(post) => <li>{post?.title}</li>}</For>\n * </ul>\n * }\n * >\n * <Match when={combinedPostsQuery.isPending}>Loading...</Match>\n * <Match when={combinedPostsQuery.isError}>Error loading posts</Match>\n * </Switch>\n * )\n * }\n * ```\n */\nexport function useQueries<\n T extends Array<any>,\n TCombinedResult extends QueriesResults<T> = QueriesResults<T>,\n>(\n queriesOptions: Accessor<{\n queries:\n | readonly [...QueriesOptions<T>]\n | readonly [...{ [K in keyof T]: GetOptions<T[K]> }]\n combine?: (result: QueriesResults<T>) => TCombinedResult\n }>,\n queryClient?: Accessor<QueryClient>,\n): TCombinedResult {\n const resolveClient = useQueryClientResolver(queryClient)\n const client = createMemo(() => resolveClient())\n const isRestoring = useIsRestoring()\n\n const defaultedQueries = createMemo(() =>\n queriesOptions().queries.map((options) =>\n mergeProps(\n client().defaultQueryOptions(options as QueryObserverOptions),\n {\n get _optimisticResults() {\n return isRestoring() ? 'isRestoring' : 'optimistic'\n },\n },\n ),\n ),\n )\n\n const observer = new QueriesObserver(\n client(),\n defaultedQueries(),\n queriesOptions().combine\n ? ({\n combine: queriesOptions().combine,\n } as QueriesObserverOptions<TCombinedResult>)\n : undefined,\n )\n\n const [state, setState] = createStore<TCombinedResult>(\n observer.getOptimisticResult(\n defaultedQueries(),\n (queriesOptions() as QueriesObserverOptions<TCombinedResult>).combine,\n )[1](),\n )\n\n createRenderEffect(\n on(\n () => queriesOptions().queries.length,\n () =>\n setState(\n observer.getOptimisticResult(\n defaultedQueries(),\n (queriesOptions() as QueriesObserverOptions<TCombinedResult>)\n .combine,\n )[1](),\n ),\n ),\n )\n\n const dataResources = createMemo(\n on(\n () => state.length,\n () =>\n state.map((queryRes) => {\n const dataPromise = () =>\n new Promise((resolve) => {\n if (queryRes.isFetching && queryRes.isLoading) return\n resolve(unwrap(queryRes.data))\n })\n return createResource(dataPromise)\n }),\n ),\n )\n\n batch(() => {\n const dataResources_ = dataResources()\n for (let index = 0; index < dataResources_.length; index++) {\n const dataResource = dataResources_[index]!\n dataResource[1].mutate(() => unwrap(state[index]!.data))\n dataResource[1].refetch()\n }\n })\n\n let taskQueue: Array<() => void> = []\n const subscribeToObserver = () =>\n observer.subscribe((result) => {\n taskQueue.push(() => {\n batch(() => {\n const dataResources_ = dataResources()\n for (let index = 0; index < dataResources_.length; index++) {\n const dataResource = dataResources_[index]!\n const unwrappedResult = { ...unwrap(result[index]) }\n // @ts-expect-error typescript pedantry regarding the possible range of index\n setState(index, unwrap(unwrappedResult))\n dataResource[1].mutate(() => unwrap(state[index]!.data))\n dataResource[1].refetch()\n }\n })\n })\n\n queueMicrotask(() => {\n const taskToRun = taskQueue.pop()\n if (taskToRun) taskToRun()\n taskQueue = []\n })\n })\n\n let unsubscribe: () => void = noop\n createComputed<() => void>((cleanup) => {\n cleanup?.()\n unsubscribe = isRestoring() ? noop : subscribeToObserver()\n // cleanup needs to be scheduled after synchronous effects take place\n return () => queueMicrotask(unsubscribe)\n })\n onCleanup(unsubscribe)\n\n onMount(() => {\n observer.setQueries(\n defaultedQueries(),\n queriesOptions().combine\n ? ({\n combine: queriesOptions().combine,\n } as QueriesObserverOptions<TCombinedResult>)\n : undefined,\n )\n })\n\n createComputed(() => {\n observer.setQueries(\n defaultedQueries(),\n queriesOptions().combine\n ? ({\n combine: queriesOptions().combine,\n } as QueriesObserverOptions<TCombinedResult>)\n : undefined,\n )\n })\n\n const handler = (index: number) => ({\n get(target: QueryObserverResult, prop: keyof QueryObserverResult): any {\n if (prop === 'data') {\n return dataResources()[index]![0]()\n }\n return Reflect.get(target, prop)\n },\n })\n\n const getProxies = () =>\n state.map((s, index) => {\n return new Proxy(s, handler(index))\n })\n\n const [proxyState, setProxyState] = createStore(getProxies())\n createRenderEffect(() => setProxyState(getProxies()))\n\n return proxyState as TCombinedResult\n}\n","import { QueryClient as QueryCoreClient } from '@tanstack/query-core'\nimport type {\n DefaultOptions as CoreDefaultOptions,\n DefaultError,\n OmitKeyof,\n QueryClientConfig as QueryCoreClientConfig,\n InfiniteQueryObserverOptions as QueryCoreInfiniteQueryObserverOptions,\n QueryObserverOptions as QueryCoreObserverOptions,\n QueryKey,\n} from '@tanstack/query-core'\n\n/**\n * The core `QueryObserverOptions`, with Solid's `reconcile` option added.\n *\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryData - The type of the data actually held in the query cache.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page, when this type\n * is shared with an infinite query's observer options. Defaults to `never` for regular queries.\n */\nexport interface QueryObserverOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = never,\n> extends OmitKeyof<\n QueryCoreObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey,\n TPageParam\n >,\n 'structuralSharing'\n> {\n /**\n * Set this to a reconciliation key to enable reconciliation between query results.\n * Set this to `false` to disable reconciliation between query results.\n * 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.\n * Defaults reconciliation to false.\n */\n reconcile?:\n | string\n | false\n | ((oldData: TData | undefined, newData: TData) => TData)\n}\n\n/**\n * The core `InfiniteQueryObserverOptions`, with Solid's `reconcile` option added.\n *\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport interface InfiniteQueryObserverOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> extends OmitKeyof<\n QueryCoreInfiniteQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n 'structuralSharing'\n> {\n /**\n * Set this to a reconciliation key to enable reconciliation between query results.\n * Set this to `false` to disable reconciliation between query results.\n * 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.\n * Defaults reconciliation to false.\n */\n reconcile?:\n | string\n | false\n | ((oldData: TData | undefined, newData: TData) => TData)\n}\n\n/**\n * The default options a `QueryClient` applies to every query, with Solid's `reconcile` option added to\n * `queries`.\n *\n * @template TError - The default type of errors thrown by queries and mutations using this `QueryClient`.\n */\nexport interface DefaultOptions<\n TError = DefaultError,\n> extends CoreDefaultOptions<TError> {\n queries?: OmitKeyof<QueryObserverOptions<unknown, TError>, 'queryKey'>\n}\n\n/**\n * The config accepted by `new QueryClient(config)`, with Solid's extended {@link DefaultOptions}.\n */\nexport interface QueryClientConfig extends QueryCoreClientConfig {\n defaultOptions?: DefaultOptions\n}\n\n/**\n * The core `@tanstack/query-core` `QueryClient`, typed so its `defaultOptions.queries` accepts Solid's\n * `reconcile` option.\n */\nexport class QueryClient extends QueryCoreClient {\n constructor(config: QueryClientConfig = {}) {\n super(config)\n }\n}\n","import type {\n DefaultError,\n QueryKey,\n QueryKeyWithDataTag,\n} from '@tanstack/query-core'\nimport type { QueryOptions } from './types'\nimport type { Accessor } from 'solid-js'\n\n/**\n * The options accepted by the `queryOptions` overload selected when no `initialData` is set — `data` may be\n * `undefined` while the query is `pending`. `queryOptions` itself accepts and returns a plain object (its\n * parameter type is `ReturnType<UndefinedInitialDataOptions<...>>`, i.e. this `Accessor` called); Solid's\n * reactivity applies where the result is consumed instead, e.g. `useQuery(() => options)`.\n *\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type UndefinedInitialDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = Accessor<\n QueryOptions<TQueryFnData, TError, TData, TQueryKey> & {\n initialData?: undefined\n }\n>\n\n/**\n * The options accepted by the `queryOptions` overload selected when `initialData` is set — `data` is never\n * `undefined`.\n *\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type DefinedInitialDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = Accessor<\n QueryOptions<TQueryFnData, TError, TData, TQueryKey> & {\n initialData: TQueryFnData | (() => TQueryFnData)\n }\n>\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can\n * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and\n * is the query key to generate options for.\n *\n * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined`.\n *\n * @see {@link useQuery} to run a query with these options.\n * @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData` set.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n *\n * @example\n * ```tsx\n * import { For } from 'solid-js'\n * import { queryOptions, useQuery } from '@tanstack/solid-query'\n *\n * const postsOptions = queryOptions({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * initialData: [],\n * })\n *\n * function Posts() {\n * // `postsQuery.data` is `Post[]`, never `undefined`, thanks to `initialData` — even if a refetch fails,\n * // so the list stays visible alongside the error.\n * const postsQuery = useQuery(() => postsOptions)\n *\n * return (\n * <div>\n * {postsQuery.isError ? <span>Error: {postsQuery.error.message}</span> : null}\n * <ul>\n * <For each={postsQuery.data}>{(post) => <li>{post.title}</li>}</For>\n * </ul>\n * </div>\n * )\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: ReturnType<\n DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>\n >,\n): ReturnType<\n DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>\n> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can\n * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and\n * is the query key to generate options for.\n *\n * @see {@link useQuery} to run a query with these options.\n * @param options - The {@link UndefinedInitialDataOptions} to use — everything you can pass to `useQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n *\n * @example\n * A parameterized factory, so the same options object can be reused per `id`:\n * ```tsx\n * import { Match, Switch } from 'solid-js'\n * import { queryOptions, useQuery } from '@tanstack/solid-query'\n *\n * const postOptions = (id: string) =>\n * queryOptions({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })\n *\n * function Post(props: { id: string }) {\n * const postQuery = useQuery(() => postOptions(props.id))\n *\n * return (\n * <Switch>\n * <Match when={postQuery.isPending}>Loading...</Match>\n * <Match when={postQuery.isError}>Error: {postQuery.error.message}</Match>\n * <Match when={postQuery.isSuccess}>\n * <h1>{postQuery.data.title}</h1>\n * </Match>\n * </Switch>\n * )\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: ReturnType<\n UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>\n >,\n): ReturnType<\n UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>\n> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\nexport function queryOptions(options: unknown) {\n return options\n}\n","import { createEffect, createMemo, createSignal, onCleanup } from 'solid-js'\nimport { useQueryClientResolver } from './QueryClientProvider'\nimport type { QueryFilters } from '@tanstack/query-core'\nimport type { QueryClient } from './QueryClient'\nimport type { Accessor } from 'solid-js'\n\n/**\n * The `useIsFetching` hook returns the `number` of the queries that your application is loading or fetching\n * in the background (useful for app-wide loading indicators).\n *\n * @param filters - An accessor returning the {@link QueryFilters} to narrow down the matched queries.\n * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns An accessor for the `number` of the queries that your application is currently loading or fetching\n * in the background.\n *\n * @example\n * ```tsx\n * import { useIsFetching } from '@tanstack/solid-query'\n *\n * function GlobalLoadingIndicator() {\n * // How many queries matching the posts prefix are fetching?\n * const isFetchingPosts = useIsFetching(() => ({ queryKey: ['posts'] }))\n *\n * return isFetchingPosts() > 0 ? <span>Loading posts...</span> : null\n * }\n * ```\n */\nexport function useIsFetching(\n filters?: Accessor<QueryFilters>,\n queryClient?: Accessor<QueryClient>,\n): Accessor<number> {\n const resolveClient = useQueryClientResolver(queryClient)\n const client = createMemo(() => resolveClient())\n const queryCache = createMemo(() => client().getQueryCache())\n\n const [fetches, setFetches] = createSignal(client().isFetching(filters?.()))\n\n createEffect(() => {\n setFetches(client().isFetching(filters?.()))\n\n const unsubscribe = queryCache().subscribe(() => {\n setFetches(client().isFetching(filters?.()))\n })\n\n onCleanup(unsubscribe)\n })\n\n return fetches\n}\n","import type {\n DefaultError,\n InfiniteData,\n NonUndefinedGuard,\n QueryKey,\n QueryKeyWithDataTag,\n} from '@tanstack/query-core'\nimport type { InfiniteQueryOptions } from './types'\nimport type { Accessor } from 'solid-js'\n\n/**\n * The options accepted by the `infiniteQueryOptions` overload selected when no `initialData` is set — `data`\n * may be `undefined` while the query is `pending`. `infiniteQueryOptions` itself accepts and returns a plain\n * object (its parameter type is `ReturnType<UndefinedInitialDataInfiniteOptions<...>>`, i.e. this `Accessor`\n * called); Solid's reactivity applies where the result is consumed instead, e.g.\n * `useInfiniteQuery(() => options)`.\n *\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,\n * the shape of all fetched pages plus their page params.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport type UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = Accessor<\n InfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & {\n initialData?: undefined\n }\n>\n\n/**\n * The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is set — `data` is\n * never `undefined`.\n *\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,\n * the shape of all fetched pages plus their page params.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport type DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n // should we handle page param correctly\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = Accessor<\n InfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & {\n initialData:\n | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n | (() => NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>)\n }\n>\n\n/**\n * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.\n * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.\n * `options.queryKey` is required and is the query key to generate options for.\n *\n * This overload is selected when `initialData` is set.\n *\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\n * @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`, with `initialData` set.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n *\n * @example\n * ```tsx\n * import { For } from 'solid-js'\n * import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/solid-query'\n *\n * const projectsOptions = infiniteQueryOptions({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * initialData: { pages: [], pageParams: [] },\n * })\n *\n * function Projects() {\n * // `projectsQuery.data` is never `undefined`, thanks to `initialData` — even if a refetch fails, so the\n * // list stays visible alongside the error.\n * const projectsQuery = useInfiniteQuery(() => projectsOptions)\n *\n * return (\n * <div>\n * {projectsQuery.isError ? <span>Error: {projectsQuery.error.message}</span> : null}\n * <ul>\n * <For each={projectsQuery.data.pages}>\n * {(page) => <For each={page.projects}>{(p) => <li>{p.name}</li>}</For>}\n * </For>\n * </ul>\n * </div>\n * )\n * }\n * ```\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: ReturnType<\n DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >\n >,\n): ReturnType<\n DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >\n> &\n QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n\n/**\n * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.\n * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.\n * `options.queryKey` is required and is the query key to generate options for.\n *\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\n * @param options - The {@link UndefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n *\n * @example\n * A parameterized factory, so the same options object can be reused per `postId`:\n * ```tsx\n * import { For, Match, Switch } from 'solid-js'\n * import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/solid-query'\n *\n * const commentsOptions = (postId: string) =>\n * infiniteQueryOptions({\n * queryKey: ['post', postId, 'comments'],\n * queryFn: ({ pageParam }) => fetchComments(postId, pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n *\n * function Comments(props: { postId: string }) {\n * const commentsQuery = useInfiniteQuery(() => commentsOptions(props.postId))\n *\n * return (\n * <Switch>\n * <Match when={commentsQuery.isPending}>Loading...</Match>\n * <Match when={commentsQuery.isError}>Error: {commentsQuery.error.message}</Match>\n * <Match when={commentsQuery.isSuccess}>\n * <ul>\n * <For each={commentsQuery.data.pages}>\n * {(page) => <For each={page.comments}>{(c) => <li>{c.text}</li>}</For>}\n * </For>\n * </ul>\n * </Match>\n * </Switch>\n * )\n * }\n * ```\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: ReturnType<\n UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >\n >,\n): ReturnType<\n UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >\n> &\n QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n\nexport function infiniteQueryOptions(options: unknown) {\n return options\n}\n","import type { DefaultError, WithRequired } from '@tanstack/query-core'\nimport type { MutationOptions } from './types'\n\n/**\n * You can generally pass everything to `mutationOptions` that you can also pass to `useMutation`. A\n * `mutationKey` is required on this overload so the mutation can be looked up later, e.g. with\n * `useMutationState`.\n *\n * @see {@link useMutation} to run the mutation these options describe.\n * @param options - The mutation options to use, identical to what you'd pass to `useMutation`, with a\n * required `mutationKey`.\n * @returns The same options object, unchanged.\n *\n * @example\n * Looking the mutation up elsewhere via its `mutationKey`, e.g. for a global \"saving…\" indicator:\n * ```tsx\n * import { mutationOptions, useMutationState } from '@tanstack/solid-query'\n *\n * const createPostOptions = mutationOptions({\n * mutationKey: ['posts', 'create'],\n * mutationFn: createPost,\n * })\n *\n * function SavingIndicator() {\n * const isCreatingPost = useMutationState(() => ({\n * filters: { mutationKey: createPostOptions.mutationKey, status: 'pending' },\n * }))\n *\n * return isCreatingPost().length > 0 ? <span>Saving…</span> : null\n * }\n * ```\n */\nexport function mutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n>(\n options: WithRequired<\n MutationOptions<TData, TError, TVariables, TOnMutateResult>,\n 'mutationKey'\n >,\n): WithRequired<\n MutationOptions<TData, TError, TVariables, TOnMutateResult>,\n 'mutationKey'\n>\n/**\n * You can generally pass everything to `mutationOptions` that you can also pass to `useMutation`. No\n * `mutationKey` is required on this overload — use this when you don't need to target the mutation via a\n * `mutationKey` filter later (e.g. with `useMutationState`); it can still be observed through other filters,\n * such as `status`.\n *\n * @see {@link useMutation} to run the mutation these options describe.\n * @param options - The mutation options to use, identical to what you'd pass to `useMutation`, without a\n * `mutationKey`.\n * @returns The same options object, unchanged.\n * @remarks See the other overload's example for looking a mutation up via `useMutationState`.\n *\n * @example\n * ```tsx\n * import { mutationOptions, useMutation } from '@tanstack/solid-query'\n *\n * const createPostOptions = mutationOptions({\n * mutationFn: createPost,\n * })\n *\n * function CreatePost() {\n * const createPostMutation = useMutation(() => createPostOptions)\n * return <button onClick={() => createPostMutation.mutate({ title: 'Hello' })}>Create</button>\n * }\n * ```\n */\nexport function mutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n>(\n options: Omit<\n MutationOptions<TData, TError, TVariables, TOnMutateResult>,\n 'mutationKey'\n >,\n): Omit<\n MutationOptions<TData, TError, TVariables, TOnMutateResult>,\n 'mutationKey'\n>\nexport function mutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n>(\n options: MutationOptions<TData, TError, TVariables, TOnMutateResult>,\n): MutationOptions<TData, TError, TVariables, TOnMutateResult> {\n return options\n}\n","import { createEffect, createMemo, createSignal, onCleanup } from 'solid-js'\nimport { useQueryClientResolver } from './QueryClientProvider'\nimport type { MutationFilters } from '@tanstack/query-core'\nimport type { QueryClient } from './QueryClient'\nimport type { Accessor } from 'solid-js'\n\n/**\n * The `useIsMutating` hook returns the `number` of mutations that your application currently has `pending`\n * (useful for app-wide loading indicators).\n *\n * @param filters - An accessor returning the {@link MutationFilters} to narrow down the matched mutations.\n * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns An accessor for the `number` of the mutations that your application currently has `pending`.\n *\n * @example\n * ```tsx\n * import { useIsMutating } from '@tanstack/solid-query'\n *\n * function PostsMutatingIndicator() {\n * // How many mutations matching the posts prefix are in progress?\n * const isMutatingPosts = useIsMutating(() => ({ mutationKey: ['posts'] }))\n *\n * return isMutatingPosts() > 0 ? <span>Saving posts...</span> : null\n * }\n * ```\n */\nexport function useIsMutating(\n filters?: Accessor<MutationFilters>,\n queryClient?: Accessor<QueryClient>,\n): Accessor<number> {\n const resolveClient = useQueryClientResolver(queryClient)\n const client = createMemo(() => resolveClient())\n const mutationCache = createMemo(() => client().getMutationCache())\n\n const [mutations, setMutations] = createSignal(\n client().isMutating(filters?.()),\n )\n\n createEffect(() => {\n setMutations(client().isMutating(filters?.()))\n\n const unsubscribe = mutationCache().subscribe(() => {\n setMutations(client().isMutating(filters?.()))\n })\n\n onCleanup(unsubscribe)\n })\n\n return mutations\n}\n","import { createEffect, createMemo, createSignal, onCleanup } from 'solid-js'\nimport { replaceEqualDeep } from '@tanstack/query-core'\nimport { useQueryClientResolver } from './QueryClientProvider'\nimport type {\n Mutation,\n MutationCache,\n MutationFilters,\n MutationState,\n} from '@tanstack/query-core'\nimport type { Accessor } from 'solid-js'\nimport type { QueryClient } from './QueryClient'\n\ntype MutationTypeFromResult<TResult> = [TResult] extends [\n MutationState<\n infer TData,\n infer TError,\n infer TVariables,\n infer TOnMutateResult\n >,\n]\n ? Mutation<TData, TError, TVariables, TOnMutateResult>\n : Mutation\n\ntype MutationStateOptions<\n TResult = MutationState,\n TMutation extends Mutation<any, any, any, any> =\n MutationTypeFromResult<TResult>,\n> = {\n filters?: MutationFilters\n select?: (mutation: TMutation) => TResult\n}\n\nfunction getResult<\n TResult = MutationState,\n TMutation extends Mutation<any, any, any, any> =\n MutationTypeFromResult<TResult>,\n>(\n mutationCache: MutationCache,\n options: MutationStateOptions<TResult, TMutation>,\n): Array<TResult> {\n return mutationCache\n .findAll(options.filters)\n .map(\n (mutation): TResult =>\n (options.select\n ? options.select(mutation as TMutation)\n : mutation.state) as TResult,\n )\n}\n\n/**\n * `useMutationState` is a hook that gives you access to all mutations in the `MutationCache`. You can pass\n * `filters` ({@link MutationFilters}) to narrow down your mutations, and `select` to transform the mutation\n * state.\n *\n * @param options - An accessor returning the `filters` to narrow down matched mutations, and an optional\n * `select` to transform the mutation state.\n * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns An accessor for an array of whatever `select` returns for each matching mutation.\n *\n * @example\n * Get all variables of all running mutations:\n * ```tsx\n * import { useMutationState } from '@tanstack/solid-query'\n *\n * function PendingPosts() {\n * const pendingVariables = useMutationState(() => ({\n * filters: { status: 'pending' },\n * select: (mutation) => mutation.state.variables,\n * }))\n *\n * return <>{pendingVariables().length} posts saving...</>\n * }\n * ```\n *\n * @example\n * Get all data for specific mutations via the `mutationKey`:\n * ```tsx\n * import { useMutation, useMutationState } from '@tanstack/solid-query'\n *\n * const mutationKey = ['posts']\n *\n * function Posts() {\n * // Some mutation that we want to get the state for\n * const createPostsMutation = useMutation(() => ({\n * mutationKey,\n * mutationFn: createPosts,\n * }))\n *\n * const savedPosts = useMutationState(() => ({\n * // this mutation key needs to match the mutation key of the given mutation (see above)\n * filters: { mutationKey, status: 'success' },\n * select: (mutation) => mutation.state.data,\n * }))\n *\n * return (\n * <button onClick={() => createPostsMutation.mutate(['New Post'])}>\n * Create post ({savedPosts().length} saved so far)\n * </button>\n * )\n * }\n * ```\n *\n * @example\n * Access the latest successful mutation data via the `mutationKey`. Each invocation of `mutate` adds a new\n * entry to the mutation cache for `gcTime` milliseconds — with the `status: 'success'` filter below, check the\n * last item that `useMutationState` returns to get the latest successful invocation:\n * ```tsx\n * import { useMutationState } from '@tanstack/solid-query'\n *\n * function LatestPost() {\n * const savedPosts = useMutationState(() => ({\n * filters: { mutationKey: ['posts'], status: 'success' },\n * select: (mutation) => mutation.state.data,\n * }))\n *\n * const latestPost = () => savedPosts()[savedPosts().length - 1]\n *\n * return <span>{latestPost()?.title}</span>\n * }\n * ```\n */\nexport function useMutationState<\n TResult = MutationState,\n TMutation extends Mutation<any, any, any, any> =\n MutationTypeFromResult<TResult>,\n>(\n options: Accessor<MutationStateOptions<TResult, TMutation>> = () => ({}),\n queryClient?: Accessor<QueryClient>,\n): Accessor<Array<TResult>> {\n const resolveClient = useQueryClientResolver(queryClient)\n const client = createMemo(() => resolveClient())\n const mutationCache = createMemo(() => client().getMutationCache())\n\n const [result, setResult] = createSignal(\n getResult(mutationCache(), options()),\n )\n\n createEffect(() => {\n const unsubscribe = mutationCache().subscribe(() => {\n const nextResult = replaceEqualDeep(\n result(),\n getResult(mutationCache(), options()),\n )\n if (result() !== nextResult) {\n setResult(nextResult)\n }\n })\n\n onCleanup(unsubscribe)\n })\n\n return result\n}\n","/* istanbul ignore file */\n\nimport { useQuery } from './useQuery'\nimport { useInfiniteQuery } from './useInfiniteQuery'\nimport { useMutation } from './useMutation'\nimport { useQueries } from './useQueries'\n\n// Re-export core\nexport * from '@tanstack/query-core'\n\n// Solid Query\nexport * from './types'\n\nexport type {\n DefinedUseBaseQueryResult,\n DefinedUseInfiniteQueryResult,\n DefinedUseQueryResult,\n InfiniteQueryOptions,\n MutationOptions,\n QueryOptions,\n UseBaseMutationResult,\n UseBaseQueryOptions,\n UseBaseQueryResult,\n UseInfiniteQueryOptions,\n UseInfiniteQueryResult,\n UseMutateAsyncFunction,\n UseMutateFunction,\n UseMutationOptions,\n UseMutationResult,\n UseQueryOptions,\n UseQueryResult,\n // Aliases (create* and use* are both supported)\n UseBaseQueryOptions as CreateBaseQueryOptions,\n UseBaseQueryResult as CreateBaseQueryResult,\n UseInfiniteQueryOptions as CreateInfiniteQueryOptions,\n UseInfiniteQueryResult as CreateInfiniteQueryResult,\n UseMutateAsyncFunction as CreateMutateAsyncFunction,\n UseMutateFunction as CreateMutateFunction,\n UseMutationOptions as CreateMutationOptions,\n UseMutationResult as CreateMutationResult,\n UseBaseMutationResult as CreateBaseMutationResult,\n UseQueryOptions as CreateQueryOptions,\n UseQueryResult as CreateQueryResult,\n DefinedUseBaseQueryResult as DefinedCreateBaseQueryResult,\n DefinedUseInfiniteQueryResult as DefinedCreateInfiniteQueryResult,\n DefinedUseQueryResult as DefinedCreateQueryResult,\n} from './types'\n\nexport { QueryClient } from './QueryClient'\nexport type {\n QueryObserverOptions,\n DefaultOptions,\n QueryClientConfig,\n InfiniteQueryObserverOptions,\n} from './QueryClient'\nexport { useQuery } from './useQuery'\nexport const createQuery = useQuery\nexport { queryOptions } from './queryOptions'\nexport type {\n DefinedInitialDataOptions,\n UndefinedInitialDataOptions,\n} from './queryOptions'\nexport {\n QueryClientContext,\n QueryClientProvider,\n useQueryClient,\n} from './QueryClientProvider'\nexport type { QueryClientProviderProps } from './QueryClientProvider'\nexport { useIsFetching } from './useIsFetching'\nexport { useIsFetching as createIsFetching } from './useIsFetching'\nexport { useInfiniteQuery }\nexport const createInfiniteQuery = useInfiniteQuery\nexport { infiniteQueryOptions } from './infiniteQueryOptions'\nexport type {\n DefinedInitialDataInfiniteOptions,\n UndefinedInitialDataInfiniteOptions,\n} from './infiniteQueryOptions'\nexport { useMutation } from './useMutation'\nexport { mutationOptions } from './mutationOptions'\nexport const createMutation = useMutation\nexport { useIsMutating } from './useIsMutating'\nexport { useIsMutating as createIsMutating } from './useIsMutating'\nexport { useMutationState } from './useMutationState'\nexport { useMutationState as createMutationState } from './useMutationState'\nexport { useQueries } from './useQueries'\nexport const createQueries = useQueries\nexport { useIsRestoring, IsRestoringProvider } from './isRestoring'\n"],"mappings":"qnBAYA,MAAaO,EAAqBP,EAEhCQ,IAAAA,EAAS,EAELC,EACJ,yDAUWC,EAAkBC,GAA8B,CAC3D,GAAIA,EACF,OAAOA,EAET,IAAMC,EAAST,EAAWI,CAAkB,EAE5C,GAAI,CAACK,EACH,MAAUC,MAAMJ,CAAuB,EAGzC,OAAOG,EAAO,CAChB,EAEaE,EACXH,GAC0B,CAC1B,IAAMI,EAAgBZ,EAAWI,CAAkB,EAEnD,UAAa,CACX,IAAMS,EAAiBL,IAAc,EACrC,GAAIK,EACF,OAAOA,EAGT,GAAI,CAACD,EACH,MAAUF,MAAMJ,CAAuB,EAGzC,OAAOM,EAAc,CACvB,CACF,EAqCaK,EACXC,IAEApB,EAAgCqB,IAC9BA,IAAU,EACVD,EAAMT,OAAOW,MAAM,EACZF,EAAMT,OAAOU,QAAQE,KAAKH,EAAMT,MAAM,EAC9C,EACDV,MAAgBmB,EAAMT,OAAOU,QAAQ,CAAC,EAEtCG,EACGlB,EAAmBmB,SAAQ,CAACC,UAAaN,EAAMT,OAAM,IAAAM,UAAA,CAAA,OACnDG,EAAMH,QAAQ,CAAA,CAAA,GCvGf,EAAqB,MAAuC,EAAK,EAS1D,MAAuB,EAAW,CAAkB,EAMpD,EAAsB,EAAmB,SCQtD,SAAS,EACP,EACA,EACA,EAIA,EACoC,CACpC,GAAI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AAM,EAAc,EAAc,CAAC,CAAC,cAAgB,CAClD,IAAM,EAAa,EACjB,EAAO,EACP,EAAU,EAAc,EAAG,EAAQ,CAAC,CACtC,EACI,EAAO,IAAM,GACf,EAAU,CAAU,CAExB,CAAC,EAED,EAAU,CAAW,CACvB,CAAC,EAEM,CACT,CClGA,MAAa,EAAc,EAed,EAAsB,EAQtB,EAAiB,EAMjB,GAAgB"}
1
+ {"version":3,"file":"index.js","names":["createContext","createRenderEffect","onCleanup","useContext","QueryClient","Accessor","JSX","QueryClientContext","undefined","queryClientContextError","useQueryClient","queryClient","client","Error","useQueryClientResolver","contextClient","resolvedClient","QueryClientProviderProps","children","Element","QueryClientProvider","props","unmount","mount","bind","_$createComponent","Provider","value","QueryCoreClient"],"sources":["../src/QueryClientProvider.tsx","../src/isRestoring.ts","../src/useBaseQuery.ts","../src/useQuery.ts","../src/useInfiniteQuery.ts","../src/useMutation.ts","../src/useQueries.ts","../src/QueryClient.ts","../src/queryOptions.ts","../src/useIsFetching.ts","../src/infiniteQueryOptions.ts","../src/mutationOptions.ts","../src/useIsMutating.ts","../src/useMutationState.ts","../src/index.ts"],"sourcesContent":["import {\n createContext,\n createRenderEffect,\n onCleanup,\n useContext,\n} from 'solid-js'\nimport type { QueryClient } from './QueryClient'\nimport type { Accessor, JSX } from 'solid-js'\n\n/**\n * The context that `useQueryClient` reads from. `QueryClientProvider` is the normal way to set it.\n */\nexport const QueryClientContext = createContext<\n (() => QueryClient) | undefined\n>(undefined)\n\nconst queryClientContextError =\n 'No QueryClient set, use QueryClientProvider to set one'\n\n/**\n * The `useQueryClient` primitive returns the current `QueryClient` instance.\n *\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n * be used.\n * @returns The current `QueryClient` instance.\n * @throws If no `queryClient` argument is passed and no `QueryClientProvider` is found in the component tree.\n */\nexport const useQueryClient = (queryClient?: QueryClient) => {\n if (queryClient) {\n return queryClient\n }\n const client = useContext(QueryClientContext)\n\n if (!client) {\n throw new Error(queryClientContextError)\n }\n\n return client()\n}\n\nexport const useQueryClientResolver = (\n queryClient?: Accessor<QueryClient | undefined>,\n): Accessor<QueryClient> => {\n const contextClient = useContext(QueryClientContext)\n\n return () => {\n const resolvedClient = queryClient?.()\n if (resolvedClient) {\n return resolvedClient\n }\n\n if (!contextClient) {\n throw new Error(queryClientContextError)\n }\n\n return contextClient()\n }\n}\n\n/**\n * The props accepted by `QueryClientProvider`.\n */\nexport type QueryClientProviderProps = {\n /**\n * **Required**\n *\n * The `QueryClient` instance to provide.\n */\n client: QueryClient\n /**\n * The components that get access to the provided `QueryClient`.\n */\n children?: JSX.Element\n}\n\n/**\n * Use the `QueryClientProvider` component to connect and provide a `QueryClient` to your application. Also\n * calls `client.mount()`/`client.unmount()` as this component mounts/unmounts, which subscribes the client to\n * focus/online events (resuming any paused mutations and refetching as needed when the app regains focus or\n * comes back online).\n *\n * @returns The provided `children`, wrapped so they can read the `QueryClient` via `useQueryClient`.\n *\n * @example\n * ```tsx\n * import { QueryClient, QueryClientProvider } from '@tanstack/solid-query'\n *\n * const queryClient = new QueryClient()\n *\n * function App() {\n * return <QueryClientProvider client={queryClient}>...</QueryClientProvider>\n * }\n * ```\n */\nexport const QueryClientProvider = (\n props: QueryClientProviderProps,\n): JSX.Element => {\n createRenderEffect<() => void>((unmount) => {\n unmount?.()\n props.client.mount()\n return props.client.unmount.bind(props.client)\n })\n onCleanup(() => props.client.unmount())\n\n return (\n <QueryClientContext.Provider value={() => props.client}>\n {props.children}\n </QueryClientContext.Provider>\n )\n}\n","import { createContext, useContext } from 'solid-js'\nimport type { Accessor } from 'solid-js'\n\nconst IsRestoringContext = createContext<Accessor<boolean>>(() => false)\n\n/**\n * If you are using `PersistQueryClientProvider`, you can also use the `useIsRestoring` primitive alongside it to\n * check if a restore is currently in progress. `useQuery` and friends also check this internally to avoid\n * race conditions between the restore and mounting queries.\n *\n * @returns An accessor that reads `true` while a persisted client is being restored, `false` otherwise.\n */\nexport const useIsRestoring = () => useContext(IsRestoringContext)\n\n/**\n * The Provider that `PersistQueryClientProvider` uses to signal whether a persisted client is currently\n * being restored, read by `useIsRestoring`.\n */\nexport const IsRestoringProvider = IsRestoringContext.Provider\n","// Had to disable the lint rule because isServer type is defined as false\n// in solid-js/web package. I'll create a GitHub issue with them to see\n// why that happens.\nimport { hydrate, notifyManager, shouldThrowError } from '@tanstack/query-core'\nimport { isServer } from 'solid-js/web'\nimport {\n createComputed,\n createMemo,\n createResource,\n createSignal,\n on,\n onCleanup,\n} from 'solid-js'\nimport { createStore, reconcile, unwrap } from 'solid-js/store'\nimport { useQueryClientResolver } from './QueryClientProvider'\nimport { useIsRestoring } from './isRestoring'\nimport type { UseBaseQueryOptions } from './types'\nimport type { Accessor, Signal } from 'solid-js'\nimport type { QueryClient } from './QueryClient'\nimport type {\n Query,\n QueryKey,\n QueryObserver,\n QueryObserverResult,\n} from '@tanstack/query-core'\n\nfunction reconcileFn<TData, TError>(\n store: QueryObserverResult<TData, TError>,\n result: QueryObserverResult<TData, TError>,\n reconcileOption:\n | string\n | false\n | ((oldData: TData | undefined, newData: TData) => TData),\n queryHash?: string,\n): QueryObserverResult<TData, TError> {\n if (reconcileOption === false) return result\n if (typeof reconcileOption === 'function') {\n const newData = reconcileOption(store.data, result.data as TData)\n return { ...result, data: newData } as typeof result\n }\n let data = result.data\n if (store.data === undefined) {\n try {\n data = structuredClone(data)\n } catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n if (error instanceof Error) {\n console.warn(\n `Unable to correctly reconcile data for query key: ${queryHash}. ` +\n `Possibly because the query data contains data structures that aren't supported ` +\n `by the 'structuredClone' algorithm. Consider using a callback function instead ` +\n `to manage the reconciliation manually.\\n\\n Error Received: ${error.name} - ${error.message}`,\n )\n }\n }\n }\n }\n const newData = reconcile(data, { key: reconcileOption })(store.data)\n return { ...result, data: newData } as typeof result\n}\n\n/**\n * Solid's `onHydrated` functionality will silently \"fail\" (hydrate with an empty object)\n * if the resource data is not serializable.\n */\nconst hydratableObserverResult = <\n TQueryFnData,\n TError,\n TData,\n TQueryKey extends QueryKey,\n TDataHydratable,\n>(\n query: Query<TQueryFnData, TError, TData, TQueryKey>,\n result: QueryObserverResult<TDataHydratable, TError>,\n) => {\n if (!isServer) return result\n const obj: any = {\n ...unwrap(result),\n // During SSR, functions cannot be serialized, so we need to remove them\n // This is safe because we will add these functions back when the query is hydrated\n refetch: undefined,\n }\n\n // If the query is an infinite query, we need to remove additional properties\n if ('fetchNextPage' in result) {\n obj.fetchNextPage = undefined\n obj.fetchPreviousPage = undefined\n }\n\n // We will also attach the dehydrated state of the query to the result\n // This will be removed on client after hydration\n obj.hydrationData = {\n state: query.state,\n queryKey: query.queryKey,\n queryHash: query.queryHash,\n ...(query.meta && { meta: query.meta }),\n }\n\n return obj\n}\n\n// Base Query Function that is used to create the query.\nexport function useBaseQuery<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey,\n>(\n options: Accessor<\n UseBaseQueryOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>\n >,\n Observer: typeof QueryObserver,\n queryClient?: Accessor<QueryClient>,\n) {\n type ResourceData = QueryObserverResult<TData, TError>\n\n const resolveClient = useQueryClientResolver(queryClient)\n const client = createMemo(() => resolveClient())\n const isRestoring = useIsRestoring()\n // There are times when we run a query on the server but the resource is never read\n // This could lead to times when the queryObserver is unsubscribed before the resource has loaded\n // Causing a time out error. To prevent this we will queue the unsubscribe if the cleanup is called\n // before the resource has loaded\n let unsubscribeQueued = false\n\n const defaultedOptions = createMemo(() => {\n const defaultOptions = client().defaultQueryOptions(options())\n defaultOptions._optimisticResults = isRestoring()\n ? 'isRestoring'\n : 'optimistic'\n defaultOptions.structuralSharing = false\n if (isServer) {\n defaultOptions.retry = false\n defaultOptions.throwOnError = true\n }\n return defaultOptions\n })\n const initialOptions = defaultedOptions()\n\n const [observer, setObserver] = createSignal(\n new Observer(client(), defaultedOptions()),\n )\n\n let observerResult = observer().getOptimisticResult(defaultedOptions())\n const [state, setState] =\n createStore<QueryObserverResult<TData, TError>>(observerResult)\n\n const createServerSubscriber = (\n resolve: (\n data: ResourceData | PromiseLike<ResourceData | undefined> | undefined,\n ) => void,\n reject: (reason?: any) => void,\n ) => {\n return observer().subscribe((result) => {\n notifyManager.batchCalls(() => {\n const query = observer().getCurrentQuery()\n const unwrappedResult = hydratableObserverResult(query, result)\n\n if (result.data !== undefined && unwrappedResult.isError) {\n reject(unwrappedResult.error)\n unsubscribeIfQueued()\n } else {\n resolve(unwrappedResult)\n unsubscribeIfQueued()\n }\n })()\n })\n }\n\n const unsubscribeIfQueued = () => {\n if (unsubscribeQueued) {\n unsubscribe?.()\n unsubscribeQueued = false\n }\n }\n\n const createClientSubscriber = () => {\n const obs = observer()\n return obs.subscribe((result) => {\n observerResult = result\n queueMicrotask(() => {\n if (unsubscribe) {\n refetch()\n }\n })\n })\n }\n\n function setStateWithReconciliation(res: typeof observerResult) {\n const opts = observer().options\n // @ts-expect-error - Reconcile option is not correctly typed internally\n const reconcileOptions = opts.reconcile\n\n setState((store) => {\n return reconcileFn(\n store,\n res,\n reconcileOptions === undefined ? false : reconcileOptions,\n opts.queryHash,\n )\n })\n }\n\n function createDeepSignal<T>(): Signal<T> {\n return [\n () => state,\n (v: any) => {\n const unwrapped = unwrap(state)\n if (typeof v === 'function') {\n v = v(unwrapped)\n }\n // Hydration data exists on first load after SSR,\n // and should be removed from the observer result\n if (v?.hydrationData) {\n const { hydrationData, ...rest } = v\n v = rest\n }\n setStateWithReconciliation(v)\n },\n ] as Signal<T>\n }\n\n /**\n * Unsubscribe is set lazily, so that we can subscribe after hydration when needed.\n */\n let unsubscribe: (() => void) | null = null\n\n /*\n Fixes #7275\n In a few cases, the observer could unmount before the resource is loaded.\n This leads to Suspense boundaries to be suspended indefinitely.\n This resolver will be called when the observer is unmounting\n but the resource is still in a loading state\n */\n let resolver: ((value: ResourceData) => void) | null = null\n const [queryResource, { refetch }] = createResource<ResourceData | undefined>(\n () => {\n const obs = observer()\n return new Promise((resolve, reject) => {\n resolver = resolve\n if (isServer) {\n unsubscribe = createServerSubscriber(resolve, reject)\n } else if (!unsubscribe && !isRestoring()) {\n unsubscribe = createClientSubscriber()\n }\n obs.updateResult()\n\n if (\n observerResult.isError &&\n !observerResult.isFetching &&\n !isRestoring() &&\n shouldThrowError(obs.options.throwOnError, [\n observerResult.error,\n obs.getCurrentQuery(),\n ])\n ) {\n setStateWithReconciliation(observerResult)\n return reject(observerResult.error)\n }\n if (!observerResult.isLoading) {\n resolver = null\n return resolve(\n hydratableObserverResult(obs.getCurrentQuery(), observerResult),\n )\n }\n\n setStateWithReconciliation(observerResult)\n })\n },\n {\n storage: createDeepSignal,\n\n get deferStream() {\n return options().deferStream\n },\n\n /**\n * If this resource was populated on the server (either sync render, or streamed in over time), onHydrated\n * will be called. This is the point at which we can hydrate the query cache state, and setup the query subscriber.\n *\n * Leveraging onHydrated allows us to plug into the async and streaming support that solidjs resources already support.\n *\n * Note that this is only invoked on the client, for queries that were originally run on the server.\n */\n onHydrated(_k, info) {\n if (info.value && 'hydrationData' in info.value) {\n hydrate(client(), {\n // @ts-expect-error - hydrationData is not correctly typed internally\n queries: [{ ...info.value.hydrationData }],\n })\n }\n\n if (unsubscribe) return\n /**\n * Do not refetch query on mount if query was fetched on server,\n * even if `staleTime` is not set.\n */\n const newOptions = { ...initialOptions }\n if (\n (initialOptions.staleTime || !initialOptions.initialData) &&\n info.value\n ) {\n newOptions.refetchOnMount = false\n }\n // Setting the options as an immutable object to prevent\n // wonky behavior with observer subscriptions\n observer().setOptions(newOptions)\n setStateWithReconciliation(observer().getOptimisticResult(newOptions))\n unsubscribe = createClientSubscriber()\n },\n },\n )\n\n createComputed(\n on(\n client,\n (c) => {\n if (unsubscribe) {\n unsubscribe()\n }\n const newObserver = new Observer(c, defaultedOptions())\n unsubscribe = createClientSubscriber()\n setObserver(newObserver)\n },\n {\n defer: true,\n },\n ),\n )\n\n createComputed(\n on(\n isRestoring,\n (restoring) => {\n if (!restoring && !isServer) {\n refetch()\n }\n },\n { defer: true },\n ),\n )\n\n onCleanup(() => {\n if (isServer && queryResource.loading) {\n unsubscribeQueued = true\n return\n }\n if (unsubscribe) {\n unsubscribe()\n unsubscribe = null\n }\n if (resolver && !isServer) {\n resolver(observerResult)\n resolver = null\n }\n })\n\n createComputed(\n on(\n [observer, defaultedOptions],\n ([obs, opts]) => {\n obs.setOptions(opts)\n setStateWithReconciliation(obs.getOptimisticResult(opts))\n refetch()\n },\n { defer: true },\n ),\n )\n\n const handler = {\n get(\n target: QueryObserverResult<TData, TError>,\n prop: keyof QueryObserverResult<TData, TError>,\n ): any {\n if (prop === 'data') {\n if (state.data !== undefined) {\n return queryResource.latest?.data\n }\n return queryResource()?.data\n }\n return Reflect.get(target, prop)\n },\n }\n\n return new Proxy(state, handler)\n}\n","import { QueryObserver } from '@tanstack/query-core'\nimport { createMemo } from 'solid-js'\nimport { useBaseQuery } from './useBaseQuery'\nimport type { DefaultError, QueryKey } from '@tanstack/query-core'\nimport type { QueryClient } from './QueryClient'\nimport type { Accessor } from 'solid-js'\nimport type {\n DefinedUseQueryResult,\n UseQueryOptions,\n UseQueryResult,\n} from './types'\nimport type {\n DefinedInitialDataOptions,\n UndefinedInitialDataOptions,\n} from './queryOptions'\n\n/**\n * Subscribes to a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.\n * The query runs when the options call for it — `enabled: false` skips the initial fetch.\n *\n * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.\n * @param options - An accessor returning the {@link UndefinedInitialDataOptions} to use — everything you can\n * pass to `useQuery`.\n * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns The current query result, as a Solid store. `status` is `pending` if there is no cached data to\n * display, `error` if the last fetch attempt failed, or `success` if the query has data to display.\n * `isPending`/`isSuccess`/`isError` are derived booleans for convenience.\n *\n * @example\n * ```tsx\n * import { For, Match, Switch } from 'solid-js'\n * import { useQuery } from '@tanstack/solid-query'\n *\n * function Posts() {\n * const postsQuery = useQuery(() => ({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * }))\n *\n * return (\n * <Switch>\n * <Match when={postsQuery.isPending}>Loading...</Match>\n * <Match when={postsQuery.isError}>Error: {postsQuery.error.message}</Match>\n * <Match when={postsQuery.isSuccess}>\n * <ul>\n * <For each={postsQuery.data}>{(post) => <li>{post.title}</li>}</For>\n * </ul>\n * <div>{postsQuery.isFetching ? 'Background Updating...' : ' '}</div>\n * </Match>\n * </Switch>\n * )\n * }\n * ```\n *\n * @example\n * `select` derives whatever `data` a component needs from the cached value, without changing what's\n * actually stored in the cache — the cache still holds the full `Post[]`, but `data` here is a `number`:\n * ```tsx\n * import { Match, Switch } from 'solid-js'\n * import { useQuery } from '@tanstack/solid-query'\n *\n * function PostCount() {\n * const postsQuery = useQuery(() => ({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * select: (posts) => posts.length,\n * }))\n *\n * return (\n * <Switch>\n * <Match when={postsQuery.isPending}>Loading...</Match>\n * <Match when={postsQuery.isError}>Error: {postsQuery.error.message}</Match>\n * <Match when={postsQuery.isSuccess}>{postsQuery.data} posts</Match>\n * </Switch>\n * )\n * }\n * ```\n *\n * @example\n * A dependent query, only enabled once `postId` is set:\n * ```tsx\n * import { Match, Switch } from 'solid-js'\n * import { useQuery } from '@tanstack/solid-query'\n *\n * function Post(props: { postId: number | undefined }) {\n * const postQuery = useQuery(() => ({\n * queryKey: ['post', props.postId],\n * queryFn: () => fetchPost(props.postId!),\n * enabled: props.postId != null,\n * }))\n *\n * return (\n * <Switch fallback={<h1>{postQuery.data?.title}</h1>}>\n * <Match when={props.postId == null}>Select a post</Match>\n * <Match when={postQuery.isLoading}>Loading...</Match>\n * <Match when={postQuery.isError}>Error: {postQuery.error.message}</Match>\n * </Switch>\n * )\n * }\n * ```\n *\n * @example\n * The same dependent query, using `skipToken` to disable it in a type-safe way instead of relying on\n * `enabled`. The non-null assertion is still needed — Solid's `props` narrowing doesn't survive into the\n * `queryFn` closure the way a local `const` would — but `skipToken` keeps `queryFn`'s return type accurate\n * without it. `refetch` doesn't work while `queryFn` is `skipToken` — use `enabled: false` instead if you\n * need to trigger the query manually:\n * ```tsx\n * import { Match, Switch } from 'solid-js'\n * import { skipToken, useQuery } from '@tanstack/solid-query'\n *\n * function Post(props: { postId: number | undefined }) {\n * const postQuery = useQuery(() => ({\n * queryKey: ['post', props.postId],\n * queryFn: props.postId != null ? () => fetchPost(props.postId!) : skipToken,\n * }))\n *\n * return (\n * <Switch fallback={<h1>{postQuery.data?.title}</h1>}>\n * <Match when={props.postId == null}>Select a post</Match>\n * <Match when={postQuery.isLoading}>Loading...</Match>\n * <Match when={postQuery.isError}>Error: {postQuery.error.message}</Match>\n * </Switch>\n * )\n * }\n * ```\n *\n * @example\n * Seeding a detail query from an already-cached list, to skip the loading state:\n * ```tsx\n * import { useQuery, useQueryClient } from '@tanstack/solid-query'\n *\n * function Post(props: { postId: number }) {\n * const queryClient = useQueryClient()\n *\n * const postQuery = useQuery(() => ({\n * queryKey: ['post', props.postId],\n * queryFn: () => fetchPost(props.postId),\n * initialData: () =>\n * queryClient\n * .getQueryData<Array<Post>>(['posts'])\n * ?.find((post) => post.id === props.postId),\n * }))\n *\n * return postQuery.isError ? <span>Error: {postQuery.error.message}</span> : <h1>{postQuery.data?.title}</h1>\n * }\n * ```\n *\n * @example\n * Paginated data, keeping the previous page's data visible while the next page loads:\n * ```tsx\n * import { For, createSignal } from 'solid-js'\n * import { keepPreviousData, useQuery } from '@tanstack/solid-query'\n *\n * function Posts() {\n * const [page, setPage] = createSignal(0)\n *\n * const postsQuery = useQuery(() => ({\n * queryKey: ['posts', page()],\n * queryFn: () => fetchPosts(page()),\n * placeholderData: keepPreviousData,\n * }))\n *\n * return (\n * <div>\n * <ul>\n * <For each={postsQuery.data}>{(post) => <li>{post.title}</li>}</For>\n * </ul>\n * <button\n * disabled={postsQuery.isPlaceholderData}\n * onClick={() => setPage((old) => old + 1)}\n * >\n * Next Page\n * </button>\n * </div>\n * )\n * }\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: () => QueryClient,\n): UseQueryResult<TData, TError>\n\n/**\n * Subscribes to a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.\n * The query runs when the options call for it — `enabled: false` skips the initial fetch.\n *\n * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined`.\n *\n * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.\n * @param options - An accessor returning the {@link DefinedInitialDataOptions} to use — everything you can\n * pass to `useQuery`, with `initialData` set.\n * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns The current query result, as a Solid store, typed so that `status` is `success` — or `error` if a\n * fetch attempt fails while keeping the existing data (`status` never resolves to `pending` in this overload's\n * type, since `initialData` guarantees data upfront). `isSuccess`/`isError` are derived booleans for\n * convenience.\n *\n * @example\n * ```tsx\n * import { For } from 'solid-js'\n * import { useQuery } from '@tanstack/solid-query'\n *\n * function Posts() {\n * // `postsQuery.data` is never `undefined`, thanks to `initialData` — even if a refetch fails, so the\n * // list stays visible alongside the error.\n * const postsQuery = useQuery(() => ({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * initialData: [],\n * }))\n *\n * return (\n * <div>\n * {postsQuery.isError ? <span>Error: {postsQuery.error.message}</span> : null}\n * <ul>\n * <For each={postsQuery.data}>{(post) => <li>{post.title}</li>}</For>\n * </ul>\n * </div>\n * )\n * }\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: () => QueryClient,\n): DefinedUseQueryResult<TData, TError>\nexport function useQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: Accessor<QueryClient>,\n) {\n return useBaseQuery(\n createMemo(() => options()),\n QueryObserver,\n queryClient,\n )\n}\n","import { InfiniteQueryObserver } from '@tanstack/query-core'\nimport { createMemo } from 'solid-js'\nimport { useBaseQuery } from './useBaseQuery'\nimport type {\n DefaultError,\n InfiniteData,\n QueryKey,\n QueryObserver,\n} from '@tanstack/query-core'\nimport type { QueryClient } from './QueryClient'\nimport type {\n DefinedUseInfiniteQueryResult,\n UseInfiniteQueryOptions,\n UseInfiniteQueryResult,\n} from './types'\nimport type { Accessor } from 'solid-js'\nimport type {\n DefinedInitialDataInfiniteOptions,\n UndefinedInitialDataInfiniteOptions,\n} from './infiniteQueryOptions'\n\n/**\n * The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of\n * `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`.\n *\n * This overload is selected when `initialData` is set.\n *\n * @remarks Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default\n * refetch behavior, resulting in outdated data. Make sure to call these functions only in response to user\n * actions, or add conditions like `hasNextPage && !isFetching`.\n * @see {@link infiniteQueryOptions} to share these options between `useInfiniteQuery` and imperative APIs like `queryClient.infiniteQuery`.\n * @param options - An accessor returning the {@link DefinedInitialDataInfiniteOptions} to use — everything you\n * can pass to `useInfiniteQuery`, with `initialData` set.\n * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns The same properties as `useQuery`, with the addition of `fetchNextPage`, `fetchPreviousPage`,\n * `hasNextPage`, `hasPreviousPage`, `isFetchingNextPage`, and `isFetchingPreviousPage`. `data.pages` and\n * `data.pageParams` are also added, as long as a `select` doesn't change `TData` away from its default\n * `InfiniteData<TQueryFnData>` shape.\n *\n * @example\n * ```tsx\n * import { For } from 'solid-js'\n * import { useInfiniteQuery } from '@tanstack/solid-query'\n *\n * function Projects() {\n * // `projectsQuery.data` is never `undefined`, thanks to `initialData` — even if a refetch fails, so the\n * // list stays visible alongside the error.\n * const projectsQuery = useInfiniteQuery(() => ({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * initialData: { pages: [], pageParams: [] },\n * }))\n *\n * return (\n * <div>\n * {projectsQuery.isError ? <span>Error: {projectsQuery.error.message}</span> : null}\n * <ul>\n * <For each={projectsQuery.data.pages}>\n * {(page) => <For each={page.projects}>{(p) => <li>{p.name}</li>}</For>}\n * </For>\n * </ul>\n * </div>\n * )\n * }\n * ```\n */\nexport function useInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n queryClient?: Accessor<QueryClient>,\n): DefinedUseInfiniteQueryResult<TData, TError>\n\n/**\n * The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of\n * `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`.\n *\n * @remarks Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default\n * refetch behavior, resulting in outdated data. Make sure to call these functions only in response to user\n * actions, or add conditions like `hasNextPage && !isFetching`.\n * @see {@link infiniteQueryOptions} to share these options between `useInfiniteQuery` and imperative APIs like `queryClient.infiniteQuery`.\n * @param options - An accessor returning the {@link UndefinedInitialDataInfiniteOptions} to use — everything\n * you can pass to `useInfiniteQuery`.\n * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns The same properties as `useQuery`, with the addition of `fetchNextPage`, `fetchPreviousPage`,\n * `hasNextPage`, `hasPreviousPage`, `isFetchingNextPage`, and `isFetchingPreviousPage`. `data.pages` and\n * `data.pageParams` are also added, as long as a `select` doesn't change `TData` away from its default\n * `InfiniteData<TQueryFnData>` shape.\n *\n * @example\n * Fetching the next page from a \"Load More\" button click:\n * ```tsx\n * import { For, Match, Switch } from 'solid-js'\n * import { useInfiniteQuery } from '@tanstack/solid-query'\n *\n * function Projects() {\n * const projectsQuery = useInfiniteQuery(() => ({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * }))\n *\n * return (\n * <Switch>\n * <Match when={projectsQuery.isPending}>Loading...</Match>\n * <Match when={projectsQuery.isError}>Error: {projectsQuery.error.message}</Match>\n * <Match when={projectsQuery.isSuccess}>\n * <ul>\n * <For each={projectsQuery.data.pages}>\n * {(page) => <For each={page.projects}>{(p) => <li>{p.name}</li>}</For>}\n * </For>\n * </ul>\n * <button\n * onClick={() => projectsQuery.fetchNextPage()}\n * disabled={!projectsQuery.hasNextPage || projectsQuery.isFetching}\n * >\n * {projectsQuery.isFetchingNextPage\n * ? 'Loading more...'\n * : projectsQuery.hasNextPage\n * ? 'Load More'\n * : 'Nothing more to load'}\n * </button>\n * </Match>\n * </Switch>\n * )\n * }\n * ```\n *\n * @example\n * Fetching the next page automatically as the user scrolls, using an `IntersectionObserver` on a\n * sentinel element after the list:\n * ```tsx\n * import { For, Match, Switch, createEffect, onCleanup } from 'solid-js'\n * import { useInfiniteQuery } from '@tanstack/solid-query'\n *\n * function Projects() {\n * const projectsQuery = useInfiniteQuery(() => ({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * }))\n *\n * let sentinelRef: HTMLDivElement | undefined\n *\n * createEffect(() => {\n * if (sentinelRef == null || !projectsQuery.hasNextPage || projectsQuery.isFetching) return\n *\n * const observer = new IntersectionObserver(([entry]) => {\n * if (entry?.isIntersecting) projectsQuery.fetchNextPage()\n * })\n * observer.observe(sentinelRef)\n *\n * onCleanup(() => observer.disconnect())\n * })\n *\n * return (\n * <Switch>\n * <Match when={projectsQuery.isPending}>Loading...</Match>\n * <Match when={projectsQuery.isError}>Error: {projectsQuery.error.message}</Match>\n * <Match when={projectsQuery.isSuccess}>\n * <ul>\n * <For each={projectsQuery.data.pages}>\n * {(page) => <For each={page.projects}>{(p) => <li>{p.name}</li>}</For>}\n * </For>\n * </ul>\n * <div ref={sentinelRef}>{projectsQuery.isFetchingNextPage ? 'Loading more...' : null}</div>\n * </Match>\n * </Switch>\n * )\n * }\n * ```\n */\nexport function useInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n queryClient?: Accessor<QueryClient>,\n): UseInfiniteQueryResult<TData, TError>\n\nexport function useInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n queryClient?: Accessor<QueryClient>,\n): UseInfiniteQueryResult<TData, TError> {\n return useBaseQuery(\n createMemo(() => options()),\n InfiniteQueryObserver as typeof QueryObserver,\n queryClient,\n ) as UseInfiniteQueryResult<TData, TError>\n}\n","import { MutationObserver, noop, shouldThrowError } from '@tanstack/query-core'\nimport { createComputed, createMemo, on, onCleanup } from 'solid-js'\nimport { createStore } from 'solid-js/store'\nimport { useQueryClientResolver } from './QueryClientProvider'\nimport type { DefaultError } from '@tanstack/query-core'\nimport type { QueryClient } from './QueryClient'\nimport type {\n UseMutateFunction,\n UseMutationOptions,\n UseMutationResult,\n} from './types'\nimport type { Accessor } from 'solid-js'\n\n/**\n * Unlike queries, mutations are typically used to create/update/delete data or perform server side-effects.\n * `useMutation` is the primitive for that.\n *\n * @param options - An accessor returning the {@link UseMutationOptions} to use.\n * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns `mutate`/`mutateAsync` also accept per-call `onSuccess`/`onError`/`onSettled` callbacks as a second\n * argument, useful for triggering call-site side effects (e.g. navigation) without coupling them to the shared\n * mutation definition. Hook-level callbacks (passed to `options`) fire for every mutation; per-call callbacks\n * fire only for the latest call you've made, and only while the component is still mounted — unmounting before\n * the mutation settles removes the subscription and prevents them from firing.\n *\n * @example\n * ```tsx\n * import { useMutation, useQueryClient } from '@tanstack/solid-query'\n *\n * function TodoItem(props: { id: number }) {\n * const queryClient = useQueryClient()\n *\n * const deleteTodoMutation = useMutation(() => ({\n * mutationFn: deleteTodo,\n * onSuccess: () => {\n * queryClient.invalidateQueries({ queryKey: ['todos'] })\n * },\n * }))\n *\n * return (\n * <button onClick={() => deleteTodoMutation.mutate({ id: props.id })} disabled={deleteTodoMutation.isPending}>\n * Delete\n * </button>\n * )\n * }\n * ```\n *\n * @example\n * Rendering the mutation's own state, rather than just firing it off:\n * ```tsx\n * import { Match, Switch } from 'solid-js'\n * import { useMutation, useQueryClient } from '@tanstack/solid-query'\n *\n * function AddTodo() {\n * const queryClient = useQueryClient()\n *\n * const addMutation = useMutation(() => ({\n * mutationFn: addTodo,\n * onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),\n * }))\n *\n * return (\n * <Switch fallback={<button onClick={() => addMutation.mutate('Item')}>Add</button>}>\n * <Match when={addMutation.isPending}>Adding todo...</Match>\n * <Match when={addMutation.isError}>\n * <div>An error occurred: {addMutation.error?.message}</div>\n * <button onClick={() => addMutation.mutate('Item')}>Add</button>\n * </Match>\n * </Switch>\n * )\n * }\n * ```\n *\n * @example\n * Optimistic update via `onMutate`, rolling back on `onError`:\n * ```tsx\n * import { useMutation, useQueryClient } from '@tanstack/solid-query'\n *\n * function AddTodo() {\n * const queryClient = useQueryClient()\n *\n * const addMutation = useMutation(() => ({\n * mutationFn: addTodo,\n * onMutate: async (newTodo) => {\n * await queryClient.cancelQueries({ queryKey: ['todos'] })\n * const previousTodos = queryClient.getQueryData<Array<string>>(['todos'])\n *\n * queryClient.setQueryData<Array<string>>(['todos'], (old) => [\n * ...(old ?? []),\n * newTodo,\n * ])\n *\n * // Passed to `onError` as `onMutateResult` if the mutation fails.\n * return { previousTodos }\n * },\n * onError: (_err, _newTodo, onMutateResult) => {\n * queryClient.setQueryData(['todos'], onMutateResult?.previousTodos)\n * },\n * onSettled: () => {\n * queryClient.invalidateQueries({ queryKey: ['todos'] })\n * },\n * }))\n *\n * return (\n * <button onClick={() => addMutation.mutate('Item')}>Add</button>\n * )\n * }\n * ```\n *\n * @example\n * Callbacks passed per call to `mutate` only fire for the last call — `mutateAsync` gives you a\n * promise per call instead, so you can wait for all of them when they succeed:\n * ```tsx\n * import { useMutation, useQueryClient } from '@tanstack/solid-query'\n *\n * function AddTodos() {\n * const queryClient = useQueryClient()\n *\n * const addMutation = useMutation(() => ({\n * mutationFn: addTodo,\n * onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),\n * }))\n *\n * async function handleAddAll(todos: Array<string>) {\n * try {\n * await Promise.all(todos.map((todo) => addMutation.mutateAsync(todo)))\n * } catch (error) {\n * console.error('Failed to add todos:', error)\n * }\n * }\n *\n * return (\n * <button onClick={() => handleAddAll(['Todo 1', 'Todo 2', 'Todo 3'])}>\n * Add all\n * </button>\n * )\n * }\n * ```\n *\n * @example\n * If some of the mutations above can fail independently of the others, and you want to know which ones\n * did — rather than losing that information the moment the first one rejects — swap `Promise.all` for\n * `Promise.allSettled`:\n * ```tsx\n * import { useMutation, useQueryClient } from '@tanstack/solid-query'\n *\n * function AddTodos() {\n * const queryClient = useQueryClient()\n *\n * const addMutation = useMutation(() => ({\n * mutationFn: addTodo,\n * onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),\n * }))\n *\n * async function handleAddAll(todos: Array<string>) {\n * const addResults = await Promise.allSettled(\n * todos.map((todo) => addMutation.mutateAsync(todo)),\n * )\n *\n * addResults.forEach((addResult, index) => {\n * if (addResult.status === 'rejected') {\n * console.error(`Failed to add \"${todos[index]}\":`, addResult.reason)\n * }\n * })\n * }\n *\n * return (\n * <button onClick={() => handleAddAll(['Todo 1', 'Todo 2', 'Todo 3'])}>\n * Add all\n * </button>\n * )\n * }\n * ```\n */\nexport function useMutation<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n>(\n options: UseMutationOptions<TData, TError, TVariables, TOnMutateResult>,\n queryClient?: Accessor<QueryClient>,\n): UseMutationResult<TData, TError, TVariables, TOnMutateResult> {\n const resolveClient = useQueryClientResolver(queryClient)\n const client = createMemo(() => resolveClient())\n\n const observer = new MutationObserver<\n TData,\n TError,\n TVariables,\n TOnMutateResult\n >(client(), options())\n\n const mutate: UseMutateFunction<\n TData,\n TError,\n TVariables,\n TOnMutateResult\n > = (...args) => {\n observer.mutate(args[0] as TVariables, args[1]).catch(noop)\n }\n\n const [state, setState] = createStore<\n UseMutationResult<TData, TError, TVariables, TOnMutateResult>\n >({\n ...observer.getCurrentResult(),\n mutate,\n mutateAsync: observer.getCurrentResult().mutate,\n })\n\n createComputed(() => {\n observer.setOptions(options())\n })\n\n createComputed(\n on(\n () => state.status,\n () => {\n if (\n state.isError &&\n shouldThrowError(observer.options.throwOnError, [state.error])\n ) {\n throw state.error\n }\n },\n ),\n )\n\n const unsubscribe = observer.subscribe((result) => {\n setState({\n ...result,\n mutate,\n mutateAsync: result.mutate,\n })\n })\n\n onCleanup(unsubscribe)\n\n return state\n}\n","import { QueriesObserver, noop } from '@tanstack/query-core'\nimport { createStore, unwrap } from 'solid-js/store'\nimport {\n batch,\n createComputed,\n createMemo,\n createRenderEffect,\n createResource,\n mergeProps,\n on,\n onCleanup,\n onMount,\n} from 'solid-js'\nimport { useQueryClientResolver } from './QueryClientProvider'\nimport { useIsRestoring } from './isRestoring'\nimport type { QueryOptions, UseQueryResult } from './types'\nimport type { Accessor } from 'solid-js'\nimport type { QueryClient } from './QueryClient'\nimport type {\n DefaultError,\n OmitKeyof,\n QueriesObserverOptions,\n QueriesPlaceholderDataFunction,\n QueryFunction,\n QueryKey,\n QueryObserverOptions,\n QueryObserverResult,\n ThrowOnError,\n} from '@tanstack/query-core'\n\n// This defines the `UseQueryOptions` that are accepted in `QueriesOptions` & `GetOptions`.\n// `placeholderData` function does not have a parameter\ntype UseQueryOptionsForUseQueries<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = OmitKeyof<\n QueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n 'placeholderData' | 'suspense'\n> & {\n placeholderData?: TQueryFnData | QueriesPlaceholderDataFunction<TQueryFnData>\n /**\n * @deprecated The `suspense` option has been deprecated in v5 and will be removed in the next major version.\n * The `data` property on useQueries is a plain object and not a SolidJS Resource.\n * It will not suspend when the data is loading.\n * Setting `suspense` to `true` will be a no-op.\n */\n suspense?: boolean\n}\n\n// Avoid TS depth-limit error in case of large array literal\ntype MAXIMUM_DEPTH = 20\n\n// Widen the type of the symbol to enable type inference even if skipToken is not immutable.\ntype SkipTokenForUseQueries = symbol\n\ntype GetOptions<T> =\n // Part 1: responsible for applying explicit type parameter to function arguments, if object { queryFnData: TQueryFnData, error: TError, data: TData }\n T extends {\n queryFnData: infer TQueryFnData\n error?: infer TError\n data: infer TData\n }\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError, TData>\n : T extends { queryFnData: infer TQueryFnData; error?: infer TError }\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError>\n : T extends { data: infer TData; error?: infer TError }\n ? UseQueryOptionsForUseQueries<unknown, TError, TData>\n : // Part 2: responsible for applying explicit type parameter to function arguments, if tuple [TQueryFnData, TError, TData]\n T extends [infer TQueryFnData, infer TError, infer TData]\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError, TData>\n : T extends [infer TQueryFnData, infer TError]\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError>\n : T extends [infer TQueryFnData]\n ? UseQueryOptionsForUseQueries<TQueryFnData>\n : // Part 3: responsible for inferring and enforcing type if no explicit parameter was provided\n T extends {\n queryFn?:\n | QueryFunction<infer TQueryFnData, infer TQueryKey>\n | SkipTokenForUseQueries\n select?: (data: any) => infer TData\n throwOnError?: ThrowOnError<any, infer TError, any, any>\n }\n ? UseQueryOptionsForUseQueries<\n TQueryFnData,\n unknown extends TError ? DefaultError : TError,\n unknown extends TData ? TQueryFnData : TData,\n TQueryKey\n >\n : // Fallback\n UseQueryOptionsForUseQueries\n\ntype GetResults<T> =\n // Part 1: responsible for mapping explicit type parameter to function result, if object\n T extends { queryFnData: any; error?: infer TError; data: infer TData }\n ? UseQueryResult<TData, TError>\n : T extends { queryFnData: infer TQueryFnData; error?: infer TError }\n ? UseQueryResult<TQueryFnData, TError>\n : T extends { data: infer TData; error?: infer TError }\n ? UseQueryResult<TData, TError>\n : // Part 2: responsible for mapping explicit type parameter to function result, if tuple\n T extends [any, infer TError, infer TData]\n ? UseQueryResult<TData, TError>\n : T extends [infer TQueryFnData, infer TError]\n ? UseQueryResult<TQueryFnData, TError>\n : T extends [infer TQueryFnData]\n ? UseQueryResult<TQueryFnData>\n : // Part 3: responsible for mapping inferred type to results, if no explicit parameter was provided\n T extends {\n queryFn?:\n | QueryFunction<infer TQueryFnData, any>\n | SkipTokenForUseQueries\n select?: (data: any) => infer TData\n throwOnError?: ThrowOnError<any, infer TError, any, any>\n }\n ? UseQueryResult<\n unknown extends TData ? TQueryFnData : TData,\n unknown extends TError ? DefaultError : TError\n >\n : // Fallback\n UseQueryResult\n\n/**\n * QueriesOptions reducer recursively unwraps function arguments to infer/enforce type param\n */\ntype QueriesOptions<\n T extends Array<any>,\n TResult extends Array<any> = [],\n TDepth extends ReadonlyArray<number> = [],\n> = TDepth['length'] extends MAXIMUM_DEPTH\n ? Array<UseQueryOptionsForUseQueries>\n : T extends []\n ? []\n : T extends [infer Head]\n ? [...TResult, GetOptions<Head>]\n : T extends [infer Head, ...infer Tail]\n ? QueriesOptions<\n [...Tail],\n [...TResult, GetOptions<Head>],\n [...TDepth, 1]\n >\n : ReadonlyArray<unknown> extends T\n ? T\n : // If T is *some* array but we couldn't assign unknown[] to it, then it must hold some known/homogeneous type!\n // use this to infer the param types in the case of Array.map() argument\n T extends Array<\n UseQueryOptionsForUseQueries<\n infer TQueryFnData,\n infer TError,\n infer TData,\n infer TQueryKey\n >\n >\n ? Array<\n UseQueryOptionsForUseQueries<\n TQueryFnData,\n TError,\n TData,\n TQueryKey\n >\n >\n : // Fallback\n Array<UseQueryOptionsForUseQueries>\n\n/**\n * QueriesResults reducer recursively maps type param to results\n */\ntype QueriesResults<\n T extends Array<any>,\n TResult extends Array<any> = [],\n TDepth extends ReadonlyArray<number> = [],\n> = TDepth['length'] extends MAXIMUM_DEPTH\n ? Array<UseQueryResult>\n : T extends []\n ? []\n : T extends [infer Head]\n ? [...TResult, GetResults<Head>]\n : T extends [infer Head, ...infer Tail]\n ? QueriesResults<\n [...Tail],\n [...TResult, GetResults<Head>],\n [...TDepth, 1]\n >\n : { [K in keyof T]: GetResults<T[K]> }\n\n/**\n * The `useQueries` primitive can be used to fetch a variable number of queries.\n *\n * The `queries` key accepts an array with query option objects mostly identical to `useQuery` — see\n * `placeholderData` below for the one difference. A custom `QueryClient` is supplied once, as `useQueries`'\n * own top-level second argument, rather than per query.\n *\n * Having the same query key more than once in the array of query objects may cause some data to be shared\n * between queries. To avoid this, consider de-duplicating the queries and map the results back to the desired\n * structure.\n *\n * The `combine` option can be used to combine the results of the queries into a single value. The result will\n * be structurally shared to be as referentially stable as possible.\n *\n * `placeholderData` is supported here too, but unlike `useQuery`, it doesn't receive information from\n * previously rendered queries, because the number of queries can differ between renders.\n * @param queriesOptions - An accessor returning the `queries` array to run, and an optional `combine`\n * function.\n * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns The combined result. Without `combine`, this is an array with all the query results, in the same\n * order as the input. When `combine` is provided, this is the value returned by `combine` instead.\n *\n * @example\n * ```tsx\n * import { For } from 'solid-js'\n * import { useQueries } from '@tanstack/solid-query'\n *\n * function Posts(props: { ids: Array<number> }) {\n * const postQueries = useQueries(() => ({\n * queries: props.ids.map((id) => ({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * staleTime: Infinity,\n * })),\n * }))\n *\n * return (\n * <ul>\n * <For each={postQueries}>\n * {(postQuery) => {\n * if (postQuery.isPending) return <li>Loading...</li>\n * if (postQuery.isError) return <li>Error: {postQuery.error.message}</li>\n * return <li>{postQuery.data.title}</li>\n * }}\n * </For>\n * </ul>\n * )\n * }\n * ```\n *\n * @example\n * Combining results into a single value:\n * ```tsx\n * import { For, Match, Switch } from 'solid-js'\n * import { useQueries } from '@tanstack/solid-query'\n *\n * function Posts(props: { ids: Array<number> }) {\n * const combinedPostsQuery = useQueries(() => ({\n * queries: props.ids.map((id) => ({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })),\n * combine: (postQueries) => {\n * return {\n * data: postQueries.map((postQuery) => postQuery.data),\n * isPending: postQueries.some((postQuery) => postQuery.isPending),\n * isError: postQueries.some((postQuery) => postQuery.isError),\n * }\n * },\n * }))\n *\n * return (\n * <Switch\n * fallback={\n * <ul>\n * <For each={combinedPostsQuery.data}>{(post) => <li>{post?.title}</li>}</For>\n * </ul>\n * }\n * >\n * <Match when={combinedPostsQuery.isPending}>Loading...</Match>\n * <Match when={combinedPostsQuery.isError}>Error loading posts</Match>\n * </Switch>\n * )\n * }\n * ```\n */\nexport function useQueries<\n T extends Array<any>,\n TCombinedResult extends QueriesResults<T> = QueriesResults<T>,\n>(\n queriesOptions: Accessor<{\n queries:\n | readonly [...QueriesOptions<T>]\n | readonly [...{ [K in keyof T]: GetOptions<T[K]> }]\n combine?: (result: QueriesResults<T>) => TCombinedResult\n }>,\n queryClient?: Accessor<QueryClient>,\n): TCombinedResult {\n const resolveClient = useQueryClientResolver(queryClient)\n const client = createMemo(() => resolveClient())\n const isRestoring = useIsRestoring()\n\n const defaultedQueries = createMemo(() =>\n queriesOptions().queries.map((options) =>\n mergeProps(\n client().defaultQueryOptions(options as QueryObserverOptions),\n {\n get _optimisticResults() {\n return isRestoring() ? 'isRestoring' : 'optimistic'\n },\n },\n ),\n ),\n )\n\n const observer = new QueriesObserver(\n client(),\n defaultedQueries(),\n queriesOptions().combine\n ? ({\n combine: queriesOptions().combine,\n } as QueriesObserverOptions<TCombinedResult>)\n : undefined,\n )\n\n const [state, setState] = createStore<TCombinedResult>(\n observer.getOptimisticResult(\n defaultedQueries(),\n (queriesOptions() as QueriesObserverOptions<TCombinedResult>).combine,\n )[1](),\n )\n\n createRenderEffect(\n on(\n () => queriesOptions().queries.length,\n () =>\n setState(\n observer.getOptimisticResult(\n defaultedQueries(),\n (queriesOptions() as QueriesObserverOptions<TCombinedResult>)\n .combine,\n )[1](),\n ),\n ),\n )\n\n const dataResources = createMemo(\n on(\n () => state.length,\n () =>\n state.map((queryRes) => {\n const dataPromise = () =>\n new Promise((resolve) => {\n if (queryRes.isFetching && queryRes.isLoading) return\n resolve(unwrap(queryRes.data))\n })\n return createResource(dataPromise)\n }),\n ),\n )\n\n batch(() => {\n const dataResources_ = dataResources()\n for (let index = 0; index < dataResources_.length; index++) {\n const dataResource = dataResources_[index]!\n dataResource[1].mutate(() => unwrap(state[index]!.data))\n dataResource[1].refetch()\n }\n })\n\n let taskQueue: Array<() => void> = []\n const subscribeToObserver = () =>\n observer.subscribe((result) => {\n taskQueue.push(() => {\n batch(() => {\n const dataResources_ = dataResources()\n for (let index = 0; index < dataResources_.length; index++) {\n const dataResource = dataResources_[index]!\n const unwrappedResult = { ...unwrap(result[index]) }\n // @ts-expect-error typescript pedantry regarding the possible range of index\n setState(index, unwrap(unwrappedResult))\n dataResource[1].mutate(() => unwrap(state[index]!.data))\n dataResource[1].refetch()\n }\n })\n })\n\n queueMicrotask(() => {\n const taskToRun = taskQueue.pop()\n if (taskToRun) taskToRun()\n taskQueue = []\n })\n })\n\n let unsubscribe: () => void = noop\n createComputed<() => void>((cleanup) => {\n cleanup?.()\n unsubscribe = isRestoring() ? noop : subscribeToObserver()\n // cleanup needs to be scheduled after synchronous effects take place\n return () => queueMicrotask(unsubscribe)\n })\n onCleanup(unsubscribe)\n\n onMount(() => {\n observer.setQueries(\n defaultedQueries(),\n queriesOptions().combine\n ? ({\n combine: queriesOptions().combine,\n } as QueriesObserverOptions<TCombinedResult>)\n : undefined,\n )\n })\n\n createComputed(() => {\n observer.setQueries(\n defaultedQueries(),\n queriesOptions().combine\n ? ({\n combine: queriesOptions().combine,\n } as QueriesObserverOptions<TCombinedResult>)\n : undefined,\n )\n })\n\n const handler = (index: number) => ({\n get(target: QueryObserverResult, prop: keyof QueryObserverResult): any {\n if (prop === 'data') {\n return dataResources()[index]![0]()\n }\n return Reflect.get(target, prop)\n },\n })\n\n const getProxies = () =>\n state.map((s, index) => {\n return new Proxy(s, handler(index))\n })\n\n const [proxyState, setProxyState] = createStore(getProxies())\n createRenderEffect(() => setProxyState(getProxies()))\n\n return proxyState as TCombinedResult\n}\n","import { QueryClient as QueryCoreClient } from '@tanstack/query-core'\nimport type {\n DefaultOptions as CoreDefaultOptions,\n DefaultError,\n OmitKeyof,\n QueryClientConfig as QueryCoreClientConfig,\n InfiniteQueryObserverOptions as QueryCoreInfiniteQueryObserverOptions,\n QueryObserverOptions as QueryCoreObserverOptions,\n QueryKey,\n} from '@tanstack/query-core'\n\n/**\n * The core `QueryObserverOptions`, with Solid's `reconcile` option added.\n *\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryData - The type of the data actually held in the query cache.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page, when this type\n * is shared with an infinite query's observer options. Defaults to `never` for regular queries.\n */\nexport interface QueryObserverOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = never,\n> extends OmitKeyof<\n QueryCoreObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey,\n TPageParam\n >,\n 'structuralSharing'\n> {\n /**\n * Set this to a reconciliation key to enable reconciliation between query results.\n * Set this to `false` to disable reconciliation between query results.\n * 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.\n * Defaults reconciliation to false.\n */\n reconcile?:\n | string\n | false\n | ((oldData: TData | undefined, newData: TData) => TData)\n}\n\n/**\n * The core `InfiniteQueryObserverOptions`, with Solid's `reconcile` option added.\n *\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport interface InfiniteQueryObserverOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> extends OmitKeyof<\n QueryCoreInfiniteQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n 'structuralSharing'\n> {\n /**\n * Set this to a reconciliation key to enable reconciliation between query results.\n * Set this to `false` to disable reconciliation between query results.\n * 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.\n * Defaults reconciliation to false.\n */\n reconcile?:\n | string\n | false\n | ((oldData: TData | undefined, newData: TData) => TData)\n}\n\n/**\n * The default options a `QueryClient` applies to every query, with Solid's `reconcile` option added to\n * `queries`.\n *\n * @template TError - The default type of errors thrown by queries and mutations using this `QueryClient`.\n */\nexport interface DefaultOptions<\n TError = DefaultError,\n> extends CoreDefaultOptions<TError> {\n queries?: OmitKeyof<QueryObserverOptions<unknown, TError>, 'queryKey'>\n}\n\n/**\n * The config accepted by `new QueryClient(config)`, with Solid's extended {@link DefaultOptions}.\n */\nexport interface QueryClientConfig extends QueryCoreClientConfig {\n defaultOptions?: DefaultOptions\n}\n\n/**\n * The core `@tanstack/query-core` `QueryClient`, typed so its `defaultOptions.queries` accepts Solid's\n * `reconcile` option.\n */\nexport class QueryClient extends QueryCoreClient {\n constructor(config: QueryClientConfig = {}) {\n super(config)\n }\n}\n","import type {\n DefaultError,\n QueryKey,\n QueryKeyWithDataTag,\n} from '@tanstack/query-core'\nimport type { QueryOptions } from './types'\nimport type { Accessor } from 'solid-js'\n\n/**\n * The options accepted by the `queryOptions` overload selected when no `initialData` is set — `data` may be\n * `undefined` while the query is `pending`. `queryOptions` itself accepts and returns a plain object (its\n * parameter type is `ReturnType<UndefinedInitialDataOptions<...>>`, i.e. this `Accessor` called); Solid's\n * reactivity applies where the result is consumed instead, e.g. `useQuery(() => options)`.\n *\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type UndefinedInitialDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = Accessor<\n QueryOptions<TQueryFnData, TError, TData, TQueryKey> & {\n initialData?: undefined\n }\n>\n\n/**\n * The options accepted by the `queryOptions` overload selected when `initialData` is set — `data` is never\n * `undefined`.\n *\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type DefinedInitialDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = Accessor<\n QueryOptions<TQueryFnData, TError, TData, TQueryKey> & {\n initialData: TQueryFnData | (() => TQueryFnData)\n }\n>\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can\n * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and\n * is the query key to generate options for.\n *\n * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined`.\n *\n * @see {@link useQuery} to run a query with these options.\n * @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData` set.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n *\n * @example\n * ```tsx\n * import { For } from 'solid-js'\n * import { queryOptions, useQuery } from '@tanstack/solid-query'\n *\n * const postsOptions = queryOptions({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * initialData: [],\n * })\n *\n * function Posts() {\n * // `postsQuery.data` is `Post[]`, never `undefined`, thanks to `initialData` — even if a refetch fails,\n * // so the list stays visible alongside the error.\n * const postsQuery = useQuery(() => postsOptions)\n *\n * return (\n * <div>\n * {postsQuery.isError ? <span>Error: {postsQuery.error.message}</span> : null}\n * <ul>\n * <For each={postsQuery.data}>{(post) => <li>{post.title}</li>}</For>\n * </ul>\n * </div>\n * )\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: ReturnType<\n DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>\n >,\n): ReturnType<\n DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>\n> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can\n * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and\n * is the query key to generate options for.\n *\n * @see {@link useQuery} to run a query with these options.\n * @param options - The {@link UndefinedInitialDataOptions} to use — everything you can pass to `useQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n *\n * @example\n * A parameterized factory, so the same options object can be reused per `id`:\n * ```tsx\n * import { Match, Switch } from 'solid-js'\n * import { queryOptions, useQuery } from '@tanstack/solid-query'\n *\n * const postOptions = (id: string) =>\n * queryOptions({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })\n *\n * function Post(props: { id: string }) {\n * const postQuery = useQuery(() => postOptions(props.id))\n *\n * return (\n * <Switch>\n * <Match when={postQuery.isPending}>Loading...</Match>\n * <Match when={postQuery.isError}>Error: {postQuery.error.message}</Match>\n * <Match when={postQuery.isSuccess}>\n * <h1>{postQuery.data.title}</h1>\n * </Match>\n * </Switch>\n * )\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: ReturnType<\n UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>\n >,\n): ReturnType<\n UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>\n> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\nexport function queryOptions(options: unknown) {\n return options\n}\n","import { createEffect, createMemo, createSignal, onCleanup } from 'solid-js'\nimport { useQueryClientResolver } from './QueryClientProvider'\nimport type { QueryFilters } from '@tanstack/query-core'\nimport type { QueryClient } from './QueryClient'\nimport type { Accessor } from 'solid-js'\n\n/**\n * The `useIsFetching` primitive returns the `number` of the queries that your application is loading or fetching\n * in the background (useful for app-wide loading indicators).\n *\n * @param filters - An accessor returning the {@link QueryFilters} to narrow down the matched queries.\n * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns An accessor for the `number` of the queries that your application is currently loading or fetching\n * in the background.\n *\n * @example\n * ```tsx\n * import { useIsFetching } from '@tanstack/solid-query'\n *\n * function GlobalLoadingIndicator() {\n * // How many queries matching the posts prefix are fetching?\n * const isFetchingPosts = useIsFetching(() => ({ queryKey: ['posts'] }))\n *\n * return isFetchingPosts() > 0 ? <span>Loading posts...</span> : null\n * }\n * ```\n */\nexport function useIsFetching(\n filters?: Accessor<QueryFilters>,\n queryClient?: Accessor<QueryClient>,\n): Accessor<number> {\n const resolveClient = useQueryClientResolver(queryClient)\n const client = createMemo(() => resolveClient())\n const queryCache = createMemo(() => client().getQueryCache())\n\n const [fetches, setFetches] = createSignal(client().isFetching(filters?.()))\n\n createEffect(() => {\n setFetches(client().isFetching(filters?.()))\n\n const unsubscribe = queryCache().subscribe(() => {\n setFetches(client().isFetching(filters?.()))\n })\n\n onCleanup(unsubscribe)\n })\n\n return fetches\n}\n","import type {\n DefaultError,\n InfiniteData,\n NonUndefinedGuard,\n QueryKey,\n QueryKeyWithDataTag,\n} from '@tanstack/query-core'\nimport type { InfiniteQueryOptions } from './types'\nimport type { Accessor } from 'solid-js'\n\n/**\n * The options accepted by the `infiniteQueryOptions` overload selected when no `initialData` is set — `data`\n * may be `undefined` while the query is `pending`. `infiniteQueryOptions` itself accepts and returns a plain\n * object (its parameter type is `ReturnType<UndefinedInitialDataInfiniteOptions<...>>`, i.e. this `Accessor`\n * called); Solid's reactivity applies where the result is consumed instead, e.g.\n * `useInfiniteQuery(() => options)`.\n *\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,\n * the shape of all fetched pages plus their page params.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport type UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = Accessor<\n InfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & {\n initialData?: undefined\n }\n>\n\n/**\n * The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is set — `data` is\n * never `undefined`.\n *\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,\n * the shape of all fetched pages plus their page params.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport type DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n // should we handle page param correctly\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = Accessor<\n InfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & {\n initialData:\n | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n | (() => NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>)\n }\n>\n\n/**\n * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.\n * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.\n * `options.queryKey` is required and is the query key to generate options for.\n *\n * This overload is selected when `initialData` is set.\n *\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\n * @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`, with `initialData` set.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n *\n * @example\n * ```tsx\n * import { For } from 'solid-js'\n * import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/solid-query'\n *\n * const projectsOptions = infiniteQueryOptions({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * initialData: { pages: [], pageParams: [] },\n * })\n *\n * function Projects() {\n * // `projectsQuery.data` is never `undefined`, thanks to `initialData` — even if a refetch fails, so the\n * // list stays visible alongside the error.\n * const projectsQuery = useInfiniteQuery(() => projectsOptions)\n *\n * return (\n * <div>\n * {projectsQuery.isError ? <span>Error: {projectsQuery.error.message}</span> : null}\n * <ul>\n * <For each={projectsQuery.data.pages}>\n * {(page) => <For each={page.projects}>{(p) => <li>{p.name}</li>}</For>}\n * </For>\n * </ul>\n * </div>\n * )\n * }\n * ```\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: ReturnType<\n DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >\n >,\n): ReturnType<\n DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >\n> &\n QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n\n/**\n * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.\n * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.\n * `options.queryKey` is required and is the query key to generate options for.\n *\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\n * @param options - The {@link UndefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n *\n * @example\n * A parameterized factory, so the same options object can be reused per `postId`:\n * ```tsx\n * import { For, Match, Switch } from 'solid-js'\n * import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/solid-query'\n *\n * const commentsOptions = (postId: string) =>\n * infiniteQueryOptions({\n * queryKey: ['post', postId, 'comments'],\n * queryFn: ({ pageParam }) => fetchComments(postId, pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n *\n * function Comments(props: { postId: string }) {\n * const commentsQuery = useInfiniteQuery(() => commentsOptions(props.postId))\n *\n * return (\n * <Switch>\n * <Match when={commentsQuery.isPending}>Loading...</Match>\n * <Match when={commentsQuery.isError}>Error: {commentsQuery.error.message}</Match>\n * <Match when={commentsQuery.isSuccess}>\n * <ul>\n * <For each={commentsQuery.data.pages}>\n * {(page) => <For each={page.comments}>{(c) => <li>{c.text}</li>}</For>}\n * </For>\n * </ul>\n * </Match>\n * </Switch>\n * )\n * }\n * ```\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: ReturnType<\n UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >\n >,\n): ReturnType<\n UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >\n> &\n QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n\nexport function infiniteQueryOptions(options: unknown) {\n return options\n}\n","import type { DefaultError, WithRequired } from '@tanstack/query-core'\nimport type { MutationOptions } from './types'\n\n/**\n * You can generally pass everything to `mutationOptions` that you can also pass to `useMutation`. A\n * `mutationKey` is required on this overload so the mutation can be looked up later, e.g. with\n * `useMutationState`.\n *\n * @see {@link useMutation} to run the mutation these options describe.\n * @param options - The mutation options to use, identical to what you'd pass to `useMutation`, with a\n * required `mutationKey`.\n * @returns The same options object, unchanged.\n *\n * @example\n * Looking the mutation up elsewhere via its `mutationKey`, e.g. for a global \"saving…\" indicator:\n * ```tsx\n * import { mutationOptions, useMutationState } from '@tanstack/solid-query'\n *\n * const createPostOptions = mutationOptions({\n * mutationKey: ['posts', 'create'],\n * mutationFn: createPost,\n * })\n *\n * function SavingIndicator() {\n * const isCreatingPost = useMutationState(() => ({\n * filters: { mutationKey: createPostOptions.mutationKey, status: 'pending' },\n * }))\n *\n * return isCreatingPost().length > 0 ? <span>Saving…</span> : null\n * }\n * ```\n */\nexport function mutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n>(\n options: WithRequired<\n MutationOptions<TData, TError, TVariables, TOnMutateResult>,\n 'mutationKey'\n >,\n): WithRequired<\n MutationOptions<TData, TError, TVariables, TOnMutateResult>,\n 'mutationKey'\n>\n/**\n * You can generally pass everything to `mutationOptions` that you can also pass to `useMutation`. No\n * `mutationKey` is required on this overload — use this when you don't need to target the mutation via a\n * `mutationKey` filter later (e.g. with `useMutationState`); it can still be observed through other filters,\n * such as `status`.\n *\n * @see {@link useMutation} to run the mutation these options describe.\n * @param options - The mutation options to use, identical to what you'd pass to `useMutation`, without a\n * `mutationKey`.\n * @returns The same options object, unchanged.\n * @remarks See the other overload's example for looking a mutation up via `useMutationState`.\n *\n * @example\n * ```tsx\n * import { mutationOptions, useMutation } from '@tanstack/solid-query'\n *\n * const createPostOptions = mutationOptions({\n * mutationFn: createPost,\n * })\n *\n * function CreatePost() {\n * const createPostMutation = useMutation(() => createPostOptions)\n * return <button onClick={() => createPostMutation.mutate({ title: 'Hello' })}>Create</button>\n * }\n * ```\n */\nexport function mutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n>(\n options: Omit<\n MutationOptions<TData, TError, TVariables, TOnMutateResult>,\n 'mutationKey'\n >,\n): Omit<\n MutationOptions<TData, TError, TVariables, TOnMutateResult>,\n 'mutationKey'\n>\nexport function mutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n>(\n options: MutationOptions<TData, TError, TVariables, TOnMutateResult>,\n): MutationOptions<TData, TError, TVariables, TOnMutateResult> {\n return options\n}\n","import { createEffect, createMemo, createSignal, onCleanup } from 'solid-js'\nimport { useQueryClientResolver } from './QueryClientProvider'\nimport type { MutationFilters } from '@tanstack/query-core'\nimport type { QueryClient } from './QueryClient'\nimport type { Accessor } from 'solid-js'\n\n/**\n * The `useIsMutating` primitive returns the `number` of mutations that your application currently has `pending`\n * (useful for app-wide loading indicators).\n *\n * @param filters - An accessor returning the {@link MutationFilters} to narrow down the matched mutations.\n * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns An accessor for the `number` of the mutations that your application currently has `pending`.\n *\n * @example\n * ```tsx\n * import { useIsMutating } from '@tanstack/solid-query'\n *\n * function PostsMutatingIndicator() {\n * // How many mutations matching the posts prefix are in progress?\n * const isMutatingPosts = useIsMutating(() => ({ mutationKey: ['posts'] }))\n *\n * return isMutatingPosts() > 0 ? <span>Saving posts...</span> : null\n * }\n * ```\n */\nexport function useIsMutating(\n filters?: Accessor<MutationFilters>,\n queryClient?: Accessor<QueryClient>,\n): Accessor<number> {\n const resolveClient = useQueryClientResolver(queryClient)\n const client = createMemo(() => resolveClient())\n const mutationCache = createMemo(() => client().getMutationCache())\n\n const [mutations, setMutations] = createSignal(\n client().isMutating(filters?.()),\n )\n\n createEffect(() => {\n setMutations(client().isMutating(filters?.()))\n\n const unsubscribe = mutationCache().subscribe(() => {\n setMutations(client().isMutating(filters?.()))\n })\n\n onCleanup(unsubscribe)\n })\n\n return mutations\n}\n","import { createEffect, createMemo, createSignal, onCleanup } from 'solid-js'\nimport { replaceEqualDeep } from '@tanstack/query-core'\nimport { useQueryClientResolver } from './QueryClientProvider'\nimport type {\n Mutation,\n MutationCache,\n MutationFilters,\n MutationState,\n} from '@tanstack/query-core'\nimport type { Accessor } from 'solid-js'\nimport type { QueryClient } from './QueryClient'\n\ntype MutationTypeFromResult<TResult> = [TResult] extends [\n MutationState<\n infer TData,\n infer TError,\n infer TVariables,\n infer TOnMutateResult\n >,\n]\n ? Mutation<TData, TError, TVariables, TOnMutateResult>\n : Mutation\n\ntype MutationStateOptions<\n TResult = MutationState,\n TMutation extends Mutation<any, any, any, any> =\n MutationTypeFromResult<TResult>,\n> = {\n filters?: MutationFilters\n select?: (mutation: TMutation) => TResult\n}\n\nfunction getResult<\n TResult = MutationState,\n TMutation extends Mutation<any, any, any, any> =\n MutationTypeFromResult<TResult>,\n>(\n mutationCache: MutationCache,\n options: MutationStateOptions<TResult, TMutation>,\n): Array<TResult> {\n return mutationCache\n .findAll(options.filters)\n .map(\n (mutation): TResult =>\n (options.select\n ? options.select(mutation as TMutation)\n : mutation.state) as TResult,\n )\n}\n\n/**\n * `useMutationState` is a primitive that gives you access to all mutations in the `MutationCache`. You can pass\n * `filters` ({@link MutationFilters}) to narrow down your mutations, and `select` to transform the mutation\n * state.\n *\n * @param options - An accessor returning the `filters` to narrow down matched mutations, and an optional\n * `select` to transform the mutation state.\n * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns An accessor for an array of whatever `select` returns for each matching mutation.\n *\n * @example\n * Get all variables of all running mutations:\n * ```tsx\n * import { useMutationState } from '@tanstack/solid-query'\n *\n * function PendingPosts() {\n * const pendingVariables = useMutationState(() => ({\n * filters: { status: 'pending' },\n * select: (mutation) => mutation.state.variables,\n * }))\n *\n * return <>{pendingVariables().length} posts saving...</>\n * }\n * ```\n *\n * @example\n * Get all data for specific mutations via the `mutationKey`:\n * ```tsx\n * import { useMutation, useMutationState } from '@tanstack/solid-query'\n *\n * const mutationKey = ['posts']\n *\n * function Posts() {\n * // Some mutation that we want to get the state for\n * const createPostsMutation = useMutation(() => ({\n * mutationKey,\n * mutationFn: createPosts,\n * }))\n *\n * const savedPosts = useMutationState(() => ({\n * // this mutation key needs to match the mutation key of the given mutation (see above)\n * filters: { mutationKey, status: 'success' },\n * select: (mutation) => mutation.state.data,\n * }))\n *\n * return (\n * <button onClick={() => createPostsMutation.mutate(['New Post'])}>\n * Create post ({savedPosts().length} saved so far)\n * </button>\n * )\n * }\n * ```\n *\n * @example\n * Access the latest successful mutation data via the `mutationKey`. Each invocation of `mutate` adds a new\n * entry to the mutation cache for `gcTime` milliseconds — with the `status: 'success'` filter below, check the\n * last item that `useMutationState` returns to get the latest successful invocation:\n * ```tsx\n * import { useMutationState } from '@tanstack/solid-query'\n *\n * function LatestPost() {\n * const savedPosts = useMutationState(() => ({\n * filters: { mutationKey: ['posts'], status: 'success' },\n * select: (mutation) => mutation.state.data,\n * }))\n *\n * const latestPost = () => savedPosts()[savedPosts().length - 1]\n *\n * return <span>{latestPost()?.title}</span>\n * }\n * ```\n */\nexport function useMutationState<\n TResult = MutationState,\n TMutation extends Mutation<any, any, any, any> =\n MutationTypeFromResult<TResult>,\n>(\n options: Accessor<MutationStateOptions<TResult, TMutation>> = () => ({}),\n queryClient?: Accessor<QueryClient>,\n): Accessor<Array<TResult>> {\n const resolveClient = useQueryClientResolver(queryClient)\n const client = createMemo(() => resolveClient())\n const mutationCache = createMemo(() => client().getMutationCache())\n\n const [result, setResult] = createSignal(\n getResult(mutationCache(), options()),\n )\n\n createEffect(() => {\n const unsubscribe = mutationCache().subscribe(() => {\n const nextResult = replaceEqualDeep(\n result(),\n getResult(mutationCache(), options()),\n )\n if (result() !== nextResult) {\n setResult(nextResult)\n }\n })\n\n onCleanup(unsubscribe)\n })\n\n return result\n}\n","/* istanbul ignore file */\n\nimport { useQuery } from './useQuery'\nimport { useInfiniteQuery } from './useInfiniteQuery'\nimport { useMutation } from './useMutation'\nimport { useQueries } from './useQueries'\n\n// Re-export core\nexport * from '@tanstack/query-core'\n\n// Solid Query\nexport * from './types'\n\nexport type {\n DefinedUseBaseQueryResult,\n DefinedUseInfiniteQueryResult,\n DefinedUseQueryResult,\n InfiniteQueryOptions,\n MutationOptions,\n QueryOptions,\n UseBaseMutationResult,\n UseBaseQueryOptions,\n UseBaseQueryResult,\n UseInfiniteQueryOptions,\n UseInfiniteQueryResult,\n UseMutateAsyncFunction,\n UseMutateFunction,\n UseMutationOptions,\n UseMutationResult,\n UseQueryOptions,\n UseQueryResult,\n // Aliases (create* and use* are both supported)\n UseBaseQueryOptions as CreateBaseQueryOptions,\n UseBaseQueryResult as CreateBaseQueryResult,\n UseInfiniteQueryOptions as CreateInfiniteQueryOptions,\n UseInfiniteQueryResult as CreateInfiniteQueryResult,\n UseMutateAsyncFunction as CreateMutateAsyncFunction,\n UseMutateFunction as CreateMutateFunction,\n UseMutationOptions as CreateMutationOptions,\n UseMutationResult as CreateMutationResult,\n UseBaseMutationResult as CreateBaseMutationResult,\n UseQueryOptions as CreateQueryOptions,\n UseQueryResult as CreateQueryResult,\n DefinedUseBaseQueryResult as DefinedCreateBaseQueryResult,\n DefinedUseInfiniteQueryResult as DefinedCreateInfiniteQueryResult,\n DefinedUseQueryResult as DefinedCreateQueryResult,\n} from './types'\n\nexport { QueryClient } from './QueryClient'\nexport type {\n QueryObserverOptions,\n DefaultOptions,\n QueryClientConfig,\n InfiniteQueryObserverOptions,\n} from './QueryClient'\nexport { useQuery } from './useQuery'\nexport const createQuery = useQuery\nexport { queryOptions } from './queryOptions'\nexport type {\n DefinedInitialDataOptions,\n UndefinedInitialDataOptions,\n} from './queryOptions'\nexport {\n QueryClientContext,\n QueryClientProvider,\n useQueryClient,\n} from './QueryClientProvider'\nexport type { QueryClientProviderProps } from './QueryClientProvider'\nexport { useIsFetching } from './useIsFetching'\nexport { useIsFetching as createIsFetching } from './useIsFetching'\nexport { useInfiniteQuery }\nexport const createInfiniteQuery = useInfiniteQuery\nexport { infiniteQueryOptions } from './infiniteQueryOptions'\nexport type {\n DefinedInitialDataInfiniteOptions,\n UndefinedInitialDataInfiniteOptions,\n} from './infiniteQueryOptions'\nexport { useMutation } from './useMutation'\nexport { mutationOptions } from './mutationOptions'\nexport const createMutation = useMutation\nexport { useIsMutating } from './useIsMutating'\nexport { useIsMutating as createIsMutating } from './useIsMutating'\nexport { useMutationState } from './useMutationState'\nexport { useMutationState as createMutationState } from './useMutationState'\nexport { useQueries } from './useQueries'\nexport const createQueries = useQueries\nexport { useIsRestoring, IsRestoringProvider } from './isRestoring'\n"],"mappings":"qnBAYA,MAAaO,EAAqBP,EAEhCQ,IAAAA,EAAS,EAELC,EACJ,yDAUWC,EAAkBC,GAA8B,CAC3D,GAAIA,EACF,OAAOA,EAET,IAAMC,EAAST,EAAWI,CAAkB,EAE5C,GAAI,CAACK,EACH,MAAUC,MAAMJ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CAAC,CACjC,EAYA,OAVA,MAAmB,CACjB,EAAa,EAAO,CAAC,CAAC,WAAW,IAAU,CAAC,CAAC,EAE7C,IAAM,EAAc,EAAc,CAAC,CAAC,cAAgB,CAClD,EAAa,EAAO,CAAC,CAAC,WAAW,IAAU,CAAC,CAAC,CAC/C,CAAC,EAED,EAAU,CAAW,CACvB,CAAC,EAEM,CACT,CClBA,SAAS,EAKP,EACA,EACgB,CAChB,OAAO,EACJ,QAAQ,EAAQ,OAAO,CAAC,CACxB,IACE,GACE,EAAQ,OACL,EAAQ,OAAO,CAAqB,EACpC,EAAS,KACjB,CACJ,CA2EA,SAAgB,EAKd,OAAqE,CAAC,GACtE,EAC0B,CAC1B,IAAM,EAAgB,EAAuB,CAAW,EAClD,EAAS,MAAiB,EAAc,CAAC,EACzC,EAAgB,MAAiB,EAAO,CAAC,CAAC,iBAAiB,CAAC,EAE5D,CAAC,EAAQ,GAAa,EAC1B,EAAU,EAAc,EAAG,EAAQ,CAAC,CACtC,EAgBA,OAdA,MAAmB,CACjB,IAAM,EAAc,EAAc,CAAC,CAAC,cAAgB,CAClD,IAAM,EAAa,EACjB,EAAO,EACP,EAAU,EAAc,EAAG,EAAQ,CAAC,CACtC,EACI,EAAO,IAAM,GACf,EAAU,CAAU,CAExB,CAAC,EAED,EAAU,CAAW,CACvB,CAAC,EAEM,CACT,CClGA,MAAa,EAAc,EAed,EAAsB,EAQtB,EAAiB,EAMjB,GAAgB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/solid-query",
3
- "version": "5.103.0",
3
+ "version": "5.103.2",
4
4
  "description": "Primitives for managing, caching and syncing asynchronous and remote data in Solid",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -46,7 +46,7 @@
46
46
  "!src/__tests__"
47
47
  ],
48
48
  "dependencies": {
49
- "@tanstack/query-core": "5.103.0"
49
+ "@tanstack/query-core": "5.103.2"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@solidjs/testing-library": "^0.8.10",
@@ -18,7 +18,7 @@ const queryClientContextError =
18
18
  'No QueryClient set, use QueryClientProvider to set one'
19
19
 
20
20
  /**
21
- * The `useQueryClient` hook returns the current `QueryClient` instance.
21
+ * The `useQueryClient` primitive returns the current `QueryClient` instance.
22
22
  *
23
23
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
24
24
  * be used.
@@ -4,7 +4,7 @@ import type { Accessor } from 'solid-js'
4
4
  const IsRestoringContext = createContext<Accessor<boolean>>(() => false)
5
5
 
6
6
  /**
7
- * If you are using `PersistQueryClientProvider`, you can also use the `useIsRestoring` hook alongside it to
7
+ * If you are using `PersistQueryClientProvider`, you can also use the `useIsRestoring` primitive alongside it to
8
8
  * check if a restore is currently in progress. `useQuery` and friends also check this internally to avoid
9
9
  * race conditions between the restore and mounting queries.
10
10
  *
package/src/types.ts CHANGED
@@ -45,7 +45,8 @@ export interface UseBaseQueryOptions<
45
45
  * Only applicable while rendering queries on the server with streaming.
46
46
  * Set `deferStream` to `true` to wait for the query to resolve on the server before flushing the stream.
47
47
  * This can be useful to avoid sending a loading state to the client before the query has resolved.
48
- * Defaults to `false`.
48
+ *
49
+ * @defaultValue false
49
50
  */
50
51
  deferStream?: boolean
51
52
  /**
@@ -170,12 +171,21 @@ export interface InfiniteQueryOptions<
170
171
  >,
171
172
  'queryKey' | 'suspense'
172
173
  > {
174
+ /**
175
+ * The query key to use for this query. Required here, unlike on the options this type extends.
176
+ *
177
+ * The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/solid/guides/query-keys)
178
+ * for more information.
179
+ *
180
+ * The query will automatically update when this key changes (as long as `enabled` is not set to `false`).
181
+ */
173
182
  queryKey: TQueryKey
174
183
  /**
175
184
  * Only applicable while rendering queries on the server with streaming.
176
185
  * Set `deferStream` to `true` to wait for the query to resolve on the server before flushing the stream.
177
186
  * This can be useful to avoid sending a loading state to the client before the query has resolved.
178
- * Defaults to `false`.
187
+ *
188
+ * @defaultValue false
179
189
  */
180
190
  deferStream?: boolean
181
191
  /**
@@ -5,7 +5,7 @@ import type { QueryClient } from './QueryClient'
5
5
  import type { Accessor } from 'solid-js'
6
6
 
7
7
  /**
8
- * The `useIsFetching` hook returns the `number` of the queries that your application is loading or fetching
8
+ * The `useIsFetching` primitive returns the `number` of the queries that your application is loading or fetching
9
9
  * in the background (useful for app-wide loading indicators).
10
10
  *
11
11
  * @param filters - An accessor returning the {@link QueryFilters} to narrow down the matched queries.
@@ -5,7 +5,7 @@ import type { QueryClient } from './QueryClient'
5
5
  import type { Accessor } from 'solid-js'
6
6
 
7
7
  /**
8
- * The `useIsMutating` hook returns the `number` of mutations that your application currently has `pending`
8
+ * The `useIsMutating` primitive returns the `number` of mutations that your application currently has `pending`
9
9
  * (useful for app-wide loading indicators).
10
10
  *
11
11
  * @param filters - An accessor returning the {@link MutationFilters} to narrow down the matched mutations.
@@ -12,6 +12,9 @@ import type {
12
12
  import type { Accessor } from 'solid-js'
13
13
 
14
14
  /**
15
+ * Unlike queries, mutations are typically used to create/update/delete data or perform server side-effects.
16
+ * `useMutation` is the primitive for that.
17
+ *
15
18
  * @param options - An accessor returning the {@link UseMutationOptions} to use.
16
19
  * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context
17
20
  * will be used.
@@ -49,7 +49,7 @@ function getResult<
49
49
  }
50
50
 
51
51
  /**
52
- * `useMutationState` is a hook that gives you access to all mutations in the `MutationCache`. You can pass
52
+ * `useMutationState` is a primitive that gives you access to all mutations in the `MutationCache`. You can pass
53
53
  * `filters` ({@link MutationFilters}) to narrow down your mutations, and `select` to transform the mutation
54
54
  * state.
55
55
  *
package/src/useQueries.ts CHANGED
@@ -185,7 +185,7 @@ type QueriesResults<
185
185
  : { [K in keyof T]: GetResults<T[K]> }
186
186
 
187
187
  /**
188
- * The `useQueries` hook can be used to fetch a variable number of queries.
188
+ * The `useQueries` primitive can be used to fetch a variable number of queries.
189
189
  *
190
190
  * The `queries` key accepts an array with query option objects mostly identical to `useQuery` — see
191
191
  * `placeholderData` below for the one difference. A custom `QueryClient` is supplied once, as `useQueries`'
package/src/useQuery.ts CHANGED
@@ -15,6 +15,9 @@ import type {
15
15
  } from './queryOptions'
16
16
 
17
17
  /**
18
+ * Subscribes to a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
19
+ * The query runs when the options call for it — `enabled: false` skips the initial fetch.
20
+ *
18
21
  * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.
19
22
  * @param options - An accessor returning the {@link UndefinedInitialDataOptions} to use — everything you can
20
23
  * pass to `useQuery`.
@@ -186,6 +189,9 @@ export function useQuery<
186
189
  ): UseQueryResult<TData, TError>
187
190
 
188
191
  /**
192
+ * Subscribes to a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
193
+ * The query runs when the options call for it — `enabled: false` skips the initial fetch.
194
+ *
189
195
  * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined`.
190
196
  *
191
197
  * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.