@tanstack/solid-query 5.107.1 → 5.108.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/types.ts CHANGED
@@ -13,11 +13,11 @@ import type {
13
13
  QueryKey,
14
14
  QueryObserverResult,
15
15
  } from '@tanstack/query-core'
16
+ import type { Accessor } from 'solid-js'
16
17
  import type {
17
18
  InfiniteQueryObserverOptions,
18
19
  QueryObserverOptions,
19
20
  } from './QueryClient'
20
- import type { Accessor } from 'solid-js'
21
21
 
22
22
  /**
23
23
  * The options accepted by `useQuery`. Extends {@link QueryObserverOptions} from `@tanstack/query-core` with
@@ -2,7 +2,6 @@
2
2
  // in solid-js/web package. I'll create a GitHub issue with them to see
3
3
  // why that happens.
4
4
  import { hydrate, notifyManager, shouldThrowError } from '@tanstack/query-core'
5
- import { isServer } from 'solid-js/web'
6
5
  import {
7
6
  createComputed,
8
7
  createMemo,
@@ -12,17 +11,18 @@ import {
12
11
  onCleanup,
13
12
  } from 'solid-js'
14
13
  import { createStore, reconcile, unwrap } from 'solid-js/store'
14
+ import { isServer } from 'solid-js/web'
15
15
  import { useQueryClientResolver } from './QueryClientProvider'
16
16
  import { useIsRestoring } from './isRestoring'
17
- import type { UseBaseQueryOptions } from './types'
18
- import type { Accessor, Signal } from 'solid-js'
19
- import type { QueryClient } from './QueryClient'
20
17
  import type {
21
18
  Query,
22
19
  QueryKey,
23
20
  QueryObserver,
24
21
  QueryObserverResult,
25
22
  } from '@tanstack/query-core'
23
+ import type { Accessor, Signal } from 'solid-js'
24
+ import type { QueryClient } from './QueryClient'
25
+ import type { UseBaseQueryOptions } from './types'
26
26
 
27
27
  /**
28
28
  * Applies the `reconcile` option when writing a new observer result into the store.
@@ -7,17 +7,17 @@ import type {
7
7
  QueryKey,
8
8
  QueryObserver,
9
9
  } from '@tanstack/query-core'
10
+ import type { Accessor } from 'solid-js'
10
11
  import type { QueryClient } from './QueryClient'
12
+ import type {
13
+ DefinedInitialDataInfiniteOptions,
14
+ UndefinedInitialDataInfiniteOptions,
15
+ } from './infiniteQueryOptions'
11
16
  import type {
12
17
  DefinedUseInfiniteQueryResult,
13
18
  UseInfiniteQueryOptions,
14
19
  UseInfiniteQueryResult,
15
20
  } from './types'
16
- import type { Accessor } from 'solid-js'
17
- import type {
18
- DefinedInitialDataInfiniteOptions,
19
- UndefinedInitialDataInfiniteOptions,
20
- } from './infiniteQueryOptions'
21
21
 
22
22
  /**
23
23
  * The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of
@@ -1,8 +1,8 @@
1
1
  import { createEffect, createMemo, createSignal, onCleanup } from 'solid-js'
2
2
  import { useQueryClientResolver } from './QueryClientProvider'
3
3
  import type { QueryFilters } from '@tanstack/query-core'
4
- import type { QueryClient } from './QueryClient'
5
4
  import type { Accessor } from 'solid-js'
5
+ import type { QueryClient } from './QueryClient'
6
6
 
7
7
  /**
8
8
  * The `useIsFetching` primitive returns the `number` of the queries that your application is loading or fetching
@@ -1,8 +1,8 @@
1
1
  import { createEffect, createMemo, createSignal, onCleanup } from 'solid-js'
2
2
  import { useQueryClientResolver } from './QueryClientProvider'
3
3
  import type { MutationFilters } from '@tanstack/query-core'
4
- import type { QueryClient } from './QueryClient'
5
4
  import type { Accessor } from 'solid-js'
5
+ import type { QueryClient } from './QueryClient'
6
6
 
7
7
  /**
8
8
  * The `useIsMutating` primitive returns the `number` of mutations that your application currently has `pending`
@@ -3,13 +3,13 @@ import { createComputed, createMemo, on, onCleanup } from 'solid-js'
3
3
  import { createStore } from 'solid-js/store'
4
4
  import { useQueryClientResolver } from './QueryClientProvider'
5
5
  import type { DefaultError } from '@tanstack/query-core'
6
+ import type { Accessor } from 'solid-js'
6
7
  import type { QueryClient } from './QueryClient'
7
8
  import type {
8
9
  UseMutateFunction,
9
10
  UseMutationOptions,
10
11
  UseMutationResult,
11
12
  } from './types'
12
- import type { Accessor } from 'solid-js'
13
13
 
14
14
  /**
15
15
  * Unlike queries, mutations are typically used to create/update/delete data or perform server side-effects.
@@ -1,5 +1,5 @@
1
- import { createEffect, createMemo, createSignal, onCleanup } from 'solid-js'
2
1
  import { replaceEqualDeep } from '@tanstack/query-core'
2
+ import { createEffect, createMemo, createSignal, onCleanup } from 'solid-js'
3
3
  import { useQueryClientResolver } from './QueryClientProvider'
4
4
  import type {
5
5
  Mutation,
package/src/useQueries.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { QueriesObserver, noop } from '@tanstack/query-core'
2
- import { createStore, unwrap } from 'solid-js/store'
3
2
  import {
4
3
  batch,
5
4
  createComputed,
@@ -11,11 +10,9 @@ import {
11
10
  onCleanup,
12
11
  onMount,
13
12
  } from 'solid-js'
13
+ import { createStore, unwrap } from 'solid-js/store'
14
14
  import { useQueryClientResolver } from './QueryClientProvider'
15
15
  import { useIsRestoring } from './isRestoring'
16
- import type { QueryOptions, UseQueryResult } from './types'
17
- import type { Accessor } from 'solid-js'
18
- import type { QueryClient } from './QueryClient'
19
16
  import type {
20
17
  DefaultError,
21
18
  OmitKeyof,
@@ -27,6 +24,9 @@ import type {
27
24
  QueryObserverResult,
28
25
  ThrowOnError,
29
26
  } from '@tanstack/query-core'
27
+ import type { Accessor } from 'solid-js'
28
+ import type { QueryClient } from './QueryClient'
29
+ import type { QueryOptions, UseQueryResult } from './types'
30
30
 
31
31
  // This defines the `UseQueryOptions` that are accepted in `QueriesOptions` & `GetOptions`.
32
32
  // `placeholderData` function does not have a parameter
package/src/useQuery.ts CHANGED
@@ -2,32 +2,33 @@ import { QueryObserver } from '@tanstack/query-core'
2
2
  import { createMemo } from 'solid-js'
3
3
  import { useBaseQuery } from './useBaseQuery'
4
4
  import type { DefaultError, QueryKey } from '@tanstack/query-core'
5
- import type { QueryClient } from './QueryClient'
6
5
  import type { Accessor } from 'solid-js'
6
+ import type { QueryClient } from './QueryClient'
7
+ import type {
8
+ DefinedInitialDataOptions,
9
+ UndefinedInitialDataOptions,
10
+ } from './queryOptions'
7
11
  import type {
8
12
  DefinedUseQueryResult,
9
13
  UseQueryOptions,
10
14
  UseQueryResult,
11
15
  } from './types'
12
- import type {
13
- DefinedInitialDataOptions,
14
- UndefinedInitialDataOptions,
15
- } from './queryOptions'
16
16
 
17
17
  /**
18
18
  * Subscribes to a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
19
19
  * The query runs when the options call for it — `enabled: false` skips the initial fetch.
20
20
  *
21
- * This overload is selected when `initialData` is known to be defined, so the resulting `data` is never
22
- * `undefined` (unless a `select` changes `TData` to include `undefined`).
21
+ * This overload is selected when `initialData` is known to be defined, so the resulting `data` is typed as never
22
+ * `undefined` (unless a `select` changes `TData` to include `undefined`). At runtime, `data` is still `undefined`
23
+ * if `select` throws on its first call.
23
24
  * @param options - An accessor returning the {@link DefinedInitialDataOptions} to use — everything you can
24
25
  * pass to `useQuery`, with `initialData` known to be defined.
25
26
  * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context
26
27
  * will be used.
27
- * @returns The current query result, as a Solid store, typed so that `status` is `success` — or `error` if a
28
- * fetch attempt fails while keeping the existing data (`status` never resolves to `pending` in this overload's
29
- * type, since `initialData` guarantees data upfront). `isSuccess`/`isError` are derived booleans for
30
- * convenience.
28
+ * @returns The current query result, as a Solid store, typed so that `status` is `success` or `error`
29
+ * (`status` never resolves to `pending` in this overload's type, since `initialData` guarantees data upfront).
30
+ * `status` is `error` if the query has an error from a fetch that failed after its retries or if `select`
31
+ * threw, and `success` otherwise. `isSuccess`/`isError` are derived booleans for convenience.
31
32
  * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.
32
33
  * @example
33
34
  * ```tsx
@@ -71,8 +72,9 @@ export function useQuery<
71
72
  * pass to `useQuery`.
72
73
  * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context
73
74
  * will be used.
74
- * @returns The current query result, as a Solid store. `status` is `pending` if there is no cached data to
75
- * display, `error` if the last fetch attempt failed, or `success` if the query has data to display.
75
+ * @returns The current query result, as a Solid store. `status` is `error` if the query has an error from
76
+ * a fetch that failed after its retries or if `select` threw, `success` if the query has cached data
77
+ * (even if `select` returns `undefined`) or data from `placeholderData`, and `pending` otherwise.
76
78
  * `isPending`/`isSuccess`/`isError` are derived booleans for convenience.
77
79
  * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.
78
80
  * @example