@tanstack/solid-query 5.0.0-rc.1 → 5.0.0-rc.16

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
@@ -83,7 +83,7 @@ function createBaseQuery(options, Observer, queryClient) {
83
83
  const client = solidJs.createMemo(() => exports.useQueryClient(queryClient?.()));
84
84
  const isRestoring = exports.useIsRestoring();
85
85
  const defaultedOptions = solidJs.createMemo(
86
- () => solidJs.mergeProps(client().defaultQueryOptions(options()), {
86
+ () => solidJs.mergeProps(client()?.defaultQueryOptions(options()) || {}, {
87
87
  get _optimisticResults() {
88
88
  return isRestoring() ? "isRestoring" : "optimistic";
89
89
  },
@@ -124,7 +124,7 @@ function createBaseQuery(options, Observer, queryClient) {
124
124
  return reconcileFn(
125
125
  store,
126
126
  result,
127
- reconcileOptions === void 0 ? "id" : reconcileOptions
127
+ reconcileOptions === void 0 ? false : reconcileOptions
128
128
  );
129
129
  });
130
130
  if (queryResource()?.data && result.data && !queryResource.loading && isRestoring())
package/build/dev.js CHANGED
@@ -82,7 +82,7 @@ function createBaseQuery(options, Observer, queryClient) {
82
82
  const client = createMemo(() => useQueryClient(queryClient?.()));
83
83
  const isRestoring = useIsRestoring();
84
84
  const defaultedOptions = createMemo(
85
- () => mergeProps(client().defaultQueryOptions(options()), {
85
+ () => mergeProps(client()?.defaultQueryOptions(options()) || {}, {
86
86
  get _optimisticResults() {
87
87
  return isRestoring() ? "isRestoring" : "optimistic";
88
88
  },
@@ -123,7 +123,7 @@ function createBaseQuery(options, Observer, queryClient) {
123
123
  return reconcileFn(
124
124
  store,
125
125
  result,
126
- reconcileOptions === void 0 ? "id" : reconcileOptions
126
+ reconcileOptions === void 0 ? false : reconcileOptions
127
127
  );
128
128
  });
129
129
  if (queryResource()?.data && result.data && !queryResource.loading && isRestoring())
package/build/index.cjs CHANGED
@@ -83,7 +83,7 @@ function createBaseQuery(options, Observer, queryClient) {
83
83
  const client = solidJs.createMemo(() => exports.useQueryClient(queryClient?.()));
84
84
  const isRestoring = exports.useIsRestoring();
85
85
  const defaultedOptions = solidJs.createMemo(
86
- () => solidJs.mergeProps(client().defaultQueryOptions(options()), {
86
+ () => solidJs.mergeProps(client()?.defaultQueryOptions(options()) || {}, {
87
87
  get _optimisticResults() {
88
88
  return isRestoring() ? "isRestoring" : "optimistic";
89
89
  },
@@ -124,7 +124,7 @@ function createBaseQuery(options, Observer, queryClient) {
124
124
  return reconcileFn(
125
125
  store,
126
126
  result,
127
- reconcileOptions === void 0 ? "id" : reconcileOptions
127
+ reconcileOptions === void 0 ? false : reconcileOptions
128
128
  );
129
129
  });
130
130
  if (queryResource()?.data && result.data && !queryResource.loading && isRestoring())
package/build/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { DefaultError, QueryKey, QueryObserverOptions as QueryObserverOptions$1, InfiniteQueryObserverOptions as InfiniteQueryObserverOptions$1, DefaultOptions as DefaultOptions$1, QueryClientConfig as QueryClientConfig$1, QueryClient as QueryClient$1, WithRequired, QueryObserverResult, DefinedQueryObserverResult, InfiniteQueryObserverResult, MutationObserverOptions, MutateFunction, MutationObserverResult, QueryFilters, InfiniteData, MutationFilters, QueriesPlaceholderDataFunction, QueryFunction } from '@tanstack/query-core';
1
+ import { DefaultError, QueryKey, QueryObserverOptions as QueryObserverOptions$1, InfiniteQueryObserverOptions as InfiniteQueryObserverOptions$1, DefaultOptions as DefaultOptions$1, QueryClientConfig as QueryClientConfig$1, QueryClient as QueryClient$1, WithRequired, QueryObserverResult, DefinedQueryObserverResult, InfiniteQueryObserverResult, MutationObserverOptions, MutateFunction, MutationObserverResult, QueryFilters, InfiniteData, MutationFilters, QueriesPlaceholderDataFunction, QueryFunction, ThrowOnError } from '@tanstack/query-core';
2
2
  export * from '@tanstack/query-core';
3
3
  import * as solid_js from 'solid-js';
4
4
  import { JSX, Accessor } from 'solid-js';
@@ -9,7 +9,7 @@ interface QueryObserverOptions<TQueryFnData = unknown, TError = DefaultError, TD
9
9
  * Set this to a reconciliation key to enable reconciliation between query results.
10
10
  * Set this to `false` to disable reconciliation between query results.
11
11
  * 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.
12
- * Defaults reconciliation key to `id`.
12
+ * Defaults reconciliation to false.
13
13
  */
14
14
  reconcile?: string | false | ((oldData: TData | undefined, newData: TData) => TData);
15
15
  }
@@ -18,7 +18,7 @@ interface InfiniteQueryObserverOptions<TQueryFnData = unknown, TError = DefaultE
18
18
  * Set this to a reconciliation key to enable reconciliation between query results.
19
19
  * Set this to `false` to disable reconciliation between query results.
20
20
  * 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.
21
- * Defaults reconciliation key to `id`.
21
+ * Defaults reconciliation to false.
22
22
  */
23
23
  reconcile?: string | false | ((oldData: TData | undefined, newData: TData) => TData);
24
24
  }
@@ -108,9 +108,11 @@ type GetOptions<T> = T extends {
108
108
  } ? CreateQueryOptionsForCreateQueries<unknown, TError, TData> : T extends [infer TQueryFnData, infer TError, infer TData] ? CreateQueryOptionsForCreateQueries<TQueryFnData, TError, TData> : T extends [infer TQueryFnData, infer TError] ? CreateQueryOptionsForCreateQueries<TQueryFnData, TError> : T extends [infer TQueryFnData] ? CreateQueryOptionsForCreateQueries<TQueryFnData> : T extends {
109
109
  queryFn?: QueryFunction<infer TQueryFnData, infer TQueryKey>;
110
110
  select: (data: any) => infer TData;
111
- } ? CreateQueryOptionsForCreateQueries<TQueryFnData, Error, TData, TQueryKey> : T extends {
111
+ throwOnError?: ThrowOnError<any, infer TError, any, any>;
112
+ } ? CreateQueryOptionsForCreateQueries<TQueryFnData, TError, TData, TQueryKey> : T extends {
112
113
  queryFn?: QueryFunction<infer TQueryFnData, infer TQueryKey>;
113
- } ? CreateQueryOptionsForCreateQueries<TQueryFnData, Error, TQueryFnData, TQueryKey> : CreateQueryOptionsForCreateQueries;
114
+ throwOnError?: ThrowOnError<any, infer TError, any, any>;
115
+ } ? CreateQueryOptionsForCreateQueries<TQueryFnData, TError, TQueryFnData, TQueryKey> : CreateQueryOptionsForCreateQueries;
114
116
  type GetResults<T> = T extends {
115
117
  queryFnData: any;
116
118
  error?: infer TError;
@@ -124,9 +126,11 @@ type GetResults<T> = T extends {
124
126
  } ? CreateQueryResult<TData, TError> : T extends [any, infer TError, infer TData] ? CreateQueryResult<TData, TError> : T extends [infer TQueryFnData, infer TError] ? CreateQueryResult<TQueryFnData, TError> : T extends [infer TQueryFnData] ? CreateQueryResult<TQueryFnData> : T extends {
125
127
  queryFn?: QueryFunction<unknown, any>;
126
128
  select: (data: any) => infer TData;
127
- } ? CreateQueryResult<TData> : T extends {
129
+ throwOnError?: ThrowOnError<any, infer TError, any, any>;
130
+ } ? CreateQueryResult<TData, unknown extends TError ? DefaultError : TError> : T extends {
128
131
  queryFn?: QueryFunction<infer TQueryFnData, any>;
129
- } ? CreateQueryResult<TQueryFnData> : CreateQueryResult;
132
+ throwOnError?: ThrowOnError<any, infer TError, any, any>;
133
+ } ? CreateQueryResult<TQueryFnData, unknown extends TError ? DefaultError : TError> : CreateQueryResult;
130
134
  /**
131
135
  * QueriesOptions reducer recursively unwraps function arguments to infer/enforce type param
132
136
  */
package/build/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { DefaultError, QueryKey, QueryObserverOptions as QueryObserverOptions$1, InfiniteQueryObserverOptions as InfiniteQueryObserverOptions$1, DefaultOptions as DefaultOptions$1, QueryClientConfig as QueryClientConfig$1, QueryClient as QueryClient$1, WithRequired, QueryObserverResult, DefinedQueryObserverResult, InfiniteQueryObserverResult, MutationObserverOptions, MutateFunction, MutationObserverResult, QueryFilters, InfiniteData, MutationFilters, QueriesPlaceholderDataFunction, QueryFunction } from '@tanstack/query-core';
1
+ import { DefaultError, QueryKey, QueryObserverOptions as QueryObserverOptions$1, InfiniteQueryObserverOptions as InfiniteQueryObserverOptions$1, DefaultOptions as DefaultOptions$1, QueryClientConfig as QueryClientConfig$1, QueryClient as QueryClient$1, WithRequired, QueryObserverResult, DefinedQueryObserverResult, InfiniteQueryObserverResult, MutationObserverOptions, MutateFunction, MutationObserverResult, QueryFilters, InfiniteData, MutationFilters, QueriesPlaceholderDataFunction, QueryFunction, ThrowOnError } from '@tanstack/query-core';
2
2
  export * from '@tanstack/query-core';
3
3
  import * as solid_js from 'solid-js';
4
4
  import { JSX, Accessor } from 'solid-js';
@@ -9,7 +9,7 @@ interface QueryObserverOptions<TQueryFnData = unknown, TError = DefaultError, TD
9
9
  * Set this to a reconciliation key to enable reconciliation between query results.
10
10
  * Set this to `false` to disable reconciliation between query results.
11
11
  * 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.
12
- * Defaults reconciliation key to `id`.
12
+ * Defaults reconciliation to false.
13
13
  */
14
14
  reconcile?: string | false | ((oldData: TData | undefined, newData: TData) => TData);
15
15
  }
@@ -18,7 +18,7 @@ interface InfiniteQueryObserverOptions<TQueryFnData = unknown, TError = DefaultE
18
18
  * Set this to a reconciliation key to enable reconciliation between query results.
19
19
  * Set this to `false` to disable reconciliation between query results.
20
20
  * 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.
21
- * Defaults reconciliation key to `id`.
21
+ * Defaults reconciliation to false.
22
22
  */
23
23
  reconcile?: string | false | ((oldData: TData | undefined, newData: TData) => TData);
24
24
  }
@@ -108,9 +108,11 @@ type GetOptions<T> = T extends {
108
108
  } ? CreateQueryOptionsForCreateQueries<unknown, TError, TData> : T extends [infer TQueryFnData, infer TError, infer TData] ? CreateQueryOptionsForCreateQueries<TQueryFnData, TError, TData> : T extends [infer TQueryFnData, infer TError] ? CreateQueryOptionsForCreateQueries<TQueryFnData, TError> : T extends [infer TQueryFnData] ? CreateQueryOptionsForCreateQueries<TQueryFnData> : T extends {
109
109
  queryFn?: QueryFunction<infer TQueryFnData, infer TQueryKey>;
110
110
  select: (data: any) => infer TData;
111
- } ? CreateQueryOptionsForCreateQueries<TQueryFnData, Error, TData, TQueryKey> : T extends {
111
+ throwOnError?: ThrowOnError<any, infer TError, any, any>;
112
+ } ? CreateQueryOptionsForCreateQueries<TQueryFnData, TError, TData, TQueryKey> : T extends {
112
113
  queryFn?: QueryFunction<infer TQueryFnData, infer TQueryKey>;
113
- } ? CreateQueryOptionsForCreateQueries<TQueryFnData, Error, TQueryFnData, TQueryKey> : CreateQueryOptionsForCreateQueries;
114
+ throwOnError?: ThrowOnError<any, infer TError, any, any>;
115
+ } ? CreateQueryOptionsForCreateQueries<TQueryFnData, TError, TQueryFnData, TQueryKey> : CreateQueryOptionsForCreateQueries;
114
116
  type GetResults<T> = T extends {
115
117
  queryFnData: any;
116
118
  error?: infer TError;
@@ -124,9 +126,11 @@ type GetResults<T> = T extends {
124
126
  } ? CreateQueryResult<TData, TError> : T extends [any, infer TError, infer TData] ? CreateQueryResult<TData, TError> : T extends [infer TQueryFnData, infer TError] ? CreateQueryResult<TQueryFnData, TError> : T extends [infer TQueryFnData] ? CreateQueryResult<TQueryFnData> : T extends {
125
127
  queryFn?: QueryFunction<unknown, any>;
126
128
  select: (data: any) => infer TData;
127
- } ? CreateQueryResult<TData> : T extends {
129
+ throwOnError?: ThrowOnError<any, infer TError, any, any>;
130
+ } ? CreateQueryResult<TData, unknown extends TError ? DefaultError : TError> : T extends {
128
131
  queryFn?: QueryFunction<infer TQueryFnData, any>;
129
- } ? CreateQueryResult<TQueryFnData> : CreateQueryResult;
132
+ throwOnError?: ThrowOnError<any, infer TError, any, any>;
133
+ } ? CreateQueryResult<TQueryFnData, unknown extends TError ? DefaultError : TError> : CreateQueryResult;
130
134
  /**
131
135
  * QueriesOptions reducer recursively unwraps function arguments to infer/enforce type param
132
136
  */
package/build/index.js CHANGED
@@ -82,7 +82,7 @@ function createBaseQuery(options, Observer, queryClient) {
82
82
  const client = createMemo(() => useQueryClient(queryClient?.()));
83
83
  const isRestoring = useIsRestoring();
84
84
  const defaultedOptions = createMemo(
85
- () => mergeProps(client().defaultQueryOptions(options()), {
85
+ () => mergeProps(client()?.defaultQueryOptions(options()) || {}, {
86
86
  get _optimisticResults() {
87
87
  return isRestoring() ? "isRestoring" : "optimistic";
88
88
  },
@@ -123,7 +123,7 @@ function createBaseQuery(options, Observer, queryClient) {
123
123
  return reconcileFn(
124
124
  store,
125
125
  result,
126
- reconcileOptions === void 0 ? "id" : reconcileOptions
126
+ reconcileOptions === void 0 ? false : reconcileOptions
127
127
  );
128
128
  });
129
129
  if (queryResource()?.data && result.data && !queryResource.loading && isRestoring())
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/solid-query",
3
- "version": "5.0.0-rc.1",
3
+ "version": "5.0.0-rc.16",
4
4
  "description": "Primitives for managing, caching and syncing asynchronous and remote data in Solid",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -48,7 +48,7 @@
48
48
  ],
49
49
  "dependencies": {
50
50
  "solid-js": "^1.7.8",
51
- "@tanstack/query-core": "5.0.0-rc.1"
51
+ "@tanstack/query-core": "5.0.0-rc.12"
52
52
  },
53
53
  "devDependencies": {
54
54
  "tsup-preset-solid": "^2.0.1",
@@ -30,7 +30,7 @@ export interface QueryObserverOptions<
30
30
  * Set this to a reconciliation key to enable reconciliation between query results.
31
31
  * Set this to `false` to disable reconciliation between query results.
32
32
  * 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.
33
- * Defaults reconciliation key to `id`.
33
+ * Defaults reconciliation to false.
34
34
  */
35
35
  reconcile?:
36
36
  | string
@@ -60,7 +60,7 @@ export interface InfiniteQueryObserverOptions<
60
60
  * Set this to a reconciliation key to enable reconciliation between query results.
61
61
  * Set this to `false` to disable reconciliation between query results.
62
62
  * 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.
63
- * Defaults reconciliation key to `id`.
63
+ * Defaults reconciliation to false.
64
64
  */
65
65
  reconcile?:
66
66
  | string
@@ -1046,6 +1046,7 @@ describe('createQuery', () => {
1046
1046
  count++
1047
1047
  return count === 1 ? result1 : result2
1048
1048
  },
1049
+ reconcile: 'id',
1049
1050
  }))
1050
1051
 
1051
1052
  createRenderEffect(() => {
@@ -3714,7 +3715,7 @@ describe('createQuery', () => {
3714
3715
  await sleep(10)
3715
3716
  return count++
3716
3717
  },
3717
- refetchInterval: (data = 0) => (data < 2 ? 10 : false),
3718
+ refetchInterval: ({ state: { data = 0 } }) => (data < 2 ? 10 : false),
3718
3719
  }))
3719
3720
 
3720
3721
  createRenderEffect(() => {
@@ -5711,11 +5712,11 @@ describe('createQuery', () => {
5711
5712
  <div>data: {state.data}</div>
5712
5713
  <div>dataUpdatedAt: {state.dataUpdatedAt}</div>
5713
5714
  <button
5714
- onClick={() =>
5715
+ onClick={() => {
5715
5716
  queryClient.setQueryData(key, 'newData', {
5716
5717
  updatedAt: 100,
5717
5718
  })
5718
- }
5719
+ }}
5719
5720
  >
5720
5721
  setQueryData
5721
5722
  </button>
@@ -111,7 +111,7 @@ export function createBaseQuery<
111
111
  const isRestoring = useIsRestoring()
112
112
 
113
113
  const defaultedOptions = createMemo(() =>
114
- mergeProps(client().defaultQueryOptions(options()), {
114
+ mergeProps(client()?.defaultQueryOptions(options()) || {}, {
115
115
  get _optimisticResults() {
116
116
  return isRestoring() ? 'isRestoring' : 'optimistic'
117
117
  },
@@ -167,7 +167,7 @@ export function createBaseQuery<
167
167
  return reconcileFn(
168
168
  store,
169
169
  result,
170
- reconcileOptions === undefined ? 'id' : reconcileOptions,
170
+ reconcileOptions === undefined ? false : reconcileOptions,
171
171
  )
172
172
  })
173
173
  // If the query has data we dont suspend but instead mutate the resource
@@ -23,6 +23,7 @@ import type {
23
23
  QueryFunction,
24
24
  QueryKey,
25
25
  QueryObserverResult,
26
+ ThrowOnError,
26
27
  } from '@tanstack/query-core'
27
28
 
28
29
  // This defines the `UseQueryOptions` that are accepted in `QueriesOptions` & `GetOptions`.
@@ -65,12 +66,16 @@ type GetOptions<T> =
65
66
  T extends {
66
67
  queryFn?: QueryFunction<infer TQueryFnData, infer TQueryKey>
67
68
  select: (data: any) => infer TData
69
+ throwOnError?: ThrowOnError<any, infer TError, any, any>
70
+ }
71
+ ? CreateQueryOptionsForCreateQueries<TQueryFnData, TError, TData, TQueryKey>
72
+ : T extends {
73
+ queryFn?: QueryFunction<infer TQueryFnData, infer TQueryKey>
74
+ throwOnError?: ThrowOnError<any, infer TError, any, any>
68
75
  }
69
- ? CreateQueryOptionsForCreateQueries<TQueryFnData, Error, TData, TQueryKey>
70
- : T extends { queryFn?: QueryFunction<infer TQueryFnData, infer TQueryKey> }
71
76
  ? CreateQueryOptionsForCreateQueries<
72
77
  TQueryFnData,
73
- Error,
78
+ TError,
74
79
  TQueryFnData,
75
80
  TQueryKey
76
81
  >
@@ -96,10 +101,17 @@ type GetResults<T> =
96
101
  T extends {
97
102
  queryFn?: QueryFunction<unknown, any>
98
103
  select: (data: any) => infer TData
104
+ throwOnError?: ThrowOnError<any, infer TError, any, any>
99
105
  }
100
- ? CreateQueryResult<TData>
101
- : T extends { queryFn?: QueryFunction<infer TQueryFnData, any> }
102
- ? CreateQueryResult<TQueryFnData>
106
+ ? CreateQueryResult<TData, unknown extends TError ? DefaultError : TError>
107
+ : T extends {
108
+ queryFn?: QueryFunction<infer TQueryFnData, any>
109
+ throwOnError?: ThrowOnError<any, infer TError, any, any>
110
+ }
111
+ ? CreateQueryResult<
112
+ TQueryFnData,
113
+ unknown extends TError ? DefaultError : TError
114
+ >
103
115
  : // Fallback
104
116
  CreateQueryResult
105
117