@tanstack/solid-query 5.28.6 → 5.28.9
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 +5 -5
- package/build/dev.js +5 -5
- package/build/index.cjs +5 -5
- package/build/index.d.cts +8 -8
- package/build/index.d.ts +8 -8
- package/build/index.js +5 -5
- package/package.json +2 -2
- package/src/QueryClient.ts +4 -3
- package/src/__tests__/createQuery.test.tsx +7 -4
- package/src/createBaseQuery.ts +5 -5
- package/src/createQueries.ts +5 -4
- package/src/types.ts +3 -2
package/build/dev.cjs
CHANGED
|
@@ -99,6 +99,7 @@ function createBaseQuery(options, Observer, queryClient) {
|
|
|
99
99
|
}
|
|
100
100
|
return defaultOptions;
|
|
101
101
|
});
|
|
102
|
+
const initialOptions = defaultedOptions();
|
|
102
103
|
const [observer, setObserver] = solidJs.createSignal(
|
|
103
104
|
new Observer(client(), defaultedOptions())
|
|
104
105
|
);
|
|
@@ -188,13 +189,12 @@ function createBaseQuery(options, Observer, queryClient) {
|
|
|
188
189
|
* Note that this is only invoked on the client, for queries that were originally run on the server.
|
|
189
190
|
*/
|
|
190
191
|
onHydrated(_k, info) {
|
|
191
|
-
const defaultOptions = defaultedOptions();
|
|
192
192
|
if (info.value) {
|
|
193
193
|
queryCore.hydrate(client(), {
|
|
194
194
|
queries: [
|
|
195
195
|
{
|
|
196
|
-
queryKey:
|
|
197
|
-
queryHash:
|
|
196
|
+
queryKey: initialOptions.queryKey,
|
|
197
|
+
queryHash: initialOptions.queryHash,
|
|
198
198
|
state: info.value
|
|
199
199
|
}
|
|
200
200
|
]
|
|
@@ -202,8 +202,8 @@ function createBaseQuery(options, Observer, queryClient) {
|
|
|
202
202
|
}
|
|
203
203
|
if (unsubscribe)
|
|
204
204
|
return;
|
|
205
|
-
const newOptions = { ...
|
|
206
|
-
if (
|
|
205
|
+
const newOptions = { ...initialOptions };
|
|
206
|
+
if (initialOptions.staleTime || !initialOptions.initialData) {
|
|
207
207
|
newOptions.refetchOnMount = false;
|
|
208
208
|
}
|
|
209
209
|
observer().setOptions(newOptions);
|
package/build/dev.js
CHANGED
|
@@ -98,6 +98,7 @@ function createBaseQuery(options, Observer, queryClient) {
|
|
|
98
98
|
}
|
|
99
99
|
return defaultOptions;
|
|
100
100
|
});
|
|
101
|
+
const initialOptions = defaultedOptions();
|
|
101
102
|
const [observer, setObserver] = createSignal(
|
|
102
103
|
new Observer(client(), defaultedOptions())
|
|
103
104
|
);
|
|
@@ -187,13 +188,12 @@ function createBaseQuery(options, Observer, queryClient) {
|
|
|
187
188
|
* Note that this is only invoked on the client, for queries that were originally run on the server.
|
|
188
189
|
*/
|
|
189
190
|
onHydrated(_k, info) {
|
|
190
|
-
const defaultOptions = defaultedOptions();
|
|
191
191
|
if (info.value) {
|
|
192
192
|
hydrate(client(), {
|
|
193
193
|
queries: [
|
|
194
194
|
{
|
|
195
|
-
queryKey:
|
|
196
|
-
queryHash:
|
|
195
|
+
queryKey: initialOptions.queryKey,
|
|
196
|
+
queryHash: initialOptions.queryHash,
|
|
197
197
|
state: info.value
|
|
198
198
|
}
|
|
199
199
|
]
|
|
@@ -201,8 +201,8 @@ function createBaseQuery(options, Observer, queryClient) {
|
|
|
201
201
|
}
|
|
202
202
|
if (unsubscribe)
|
|
203
203
|
return;
|
|
204
|
-
const newOptions = { ...
|
|
205
|
-
if (
|
|
204
|
+
const newOptions = { ...initialOptions };
|
|
205
|
+
if (initialOptions.staleTime || !initialOptions.initialData) {
|
|
206
206
|
newOptions.refetchOnMount = false;
|
|
207
207
|
}
|
|
208
208
|
observer().setOptions(newOptions);
|
package/build/index.cjs
CHANGED
|
@@ -99,6 +99,7 @@ function createBaseQuery(options, Observer, queryClient) {
|
|
|
99
99
|
}
|
|
100
100
|
return defaultOptions;
|
|
101
101
|
});
|
|
102
|
+
const initialOptions = defaultedOptions();
|
|
102
103
|
const [observer, setObserver] = solidJs.createSignal(
|
|
103
104
|
new Observer(client(), defaultedOptions())
|
|
104
105
|
);
|
|
@@ -188,13 +189,12 @@ function createBaseQuery(options, Observer, queryClient) {
|
|
|
188
189
|
* Note that this is only invoked on the client, for queries that were originally run on the server.
|
|
189
190
|
*/
|
|
190
191
|
onHydrated(_k, info) {
|
|
191
|
-
const defaultOptions = defaultedOptions();
|
|
192
192
|
if (info.value) {
|
|
193
193
|
queryCore.hydrate(client(), {
|
|
194
194
|
queries: [
|
|
195
195
|
{
|
|
196
|
-
queryKey:
|
|
197
|
-
queryHash:
|
|
196
|
+
queryKey: initialOptions.queryKey,
|
|
197
|
+
queryHash: initialOptions.queryHash,
|
|
198
198
|
state: info.value
|
|
199
199
|
}
|
|
200
200
|
]
|
|
@@ -202,8 +202,8 @@ function createBaseQuery(options, Observer, queryClient) {
|
|
|
202
202
|
}
|
|
203
203
|
if (unsubscribe)
|
|
204
204
|
return;
|
|
205
|
-
const newOptions = { ...
|
|
206
|
-
if (
|
|
205
|
+
const newOptions = { ...initialOptions };
|
|
206
|
+
if (initialOptions.staleTime || !initialOptions.initialData) {
|
|
207
207
|
newOptions.refetchOnMount = false;
|
|
208
208
|
}
|
|
209
209
|
observer().setOptions(newOptions);
|
package/build/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { DefaultError, QueryKey, QueryObserverOptions as QueryObserverOptions$1, InfiniteQueryObserverOptions as InfiniteQueryObserverOptions$1, DefaultOptions as DefaultOptions$1, QueryClientConfig as QueryClientConfig$1, QueryClient as QueryClient$1, QueryObserverResult, DefinedQueryObserverResult, InfiniteQueryObserverResult, MutationObserverOptions, MutateFunction, MutationObserverResult, QueryFilters, InfiniteData, MutationFilters, MutationState, Mutation, QueriesPlaceholderDataFunction, QueryFunction, SkipToken, ThrowOnError } from '@tanstack/query-core';
|
|
1
|
+
import { DefaultError, QueryKey, OmitKeyof, QueryObserverOptions as QueryObserverOptions$1, InfiniteQueryObserverOptions as InfiniteQueryObserverOptions$1, DefaultOptions as DefaultOptions$1, QueryClientConfig as QueryClientConfig$1, QueryClient as QueryClient$1, QueryObserverResult, DefinedQueryObserverResult, InfiniteQueryObserverResult, MutationObserverOptions, MutateFunction, MutationObserverResult, QueryFilters, InfiniteData, MutationFilters, MutationState, Mutation, QueriesPlaceholderDataFunction, QueryFunction, SkipToken, 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';
|
|
5
5
|
|
|
6
|
-
interface QueryObserverOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = never> extends
|
|
6
|
+
interface QueryObserverOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = never> extends OmitKeyof<QueryObserverOptions$1<TQueryFnData, TError, TData, TQueryData, TQueryKey, TPageParam>, 'structuralSharing'> {
|
|
7
7
|
/**
|
|
8
8
|
* Set this to a reconciliation key to enable reconciliation between query results.
|
|
9
9
|
* Set this to `false` to disable reconciliation between query results.
|
|
@@ -12,7 +12,7 @@ interface QueryObserverOptions<TQueryFnData = unknown, TError = DefaultError, TD
|
|
|
12
12
|
*/
|
|
13
13
|
reconcile?: string | false | ((oldData: TData | undefined, newData: TData) => TData);
|
|
14
14
|
}
|
|
15
|
-
interface InfiniteQueryObserverOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> extends
|
|
15
|
+
interface InfiniteQueryObserverOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> extends OmitKeyof<InfiniteQueryObserverOptions$1<TQueryFnData, TError, TData, TQueryData, TQueryKey, TPageParam>, 'structuralSharing'> {
|
|
16
16
|
/**
|
|
17
17
|
* Set this to a reconciliation key to enable reconciliation between query results.
|
|
18
18
|
* Set this to `false` to disable reconciliation between query results.
|
|
@@ -22,7 +22,7 @@ interface InfiniteQueryObserverOptions<TQueryFnData = unknown, TError = DefaultE
|
|
|
22
22
|
reconcile?: string | false | ((oldData: TData | undefined, newData: TData) => TData);
|
|
23
23
|
}
|
|
24
24
|
interface DefaultOptions<TError = DefaultError> extends DefaultOptions$1<TError> {
|
|
25
|
-
queries?:
|
|
25
|
+
queries?: OmitKeyof<QueryObserverOptions<unknown, TError>, 'queryKey'>;
|
|
26
26
|
}
|
|
27
27
|
interface QueryClientConfig extends QueryClientConfig$1 {
|
|
28
28
|
defaultOptions?: DefaultOptions;
|
|
@@ -42,13 +42,13 @@ type CreateBaseQueryResult<TData = unknown, TError = DefaultError> = QueryObserv
|
|
|
42
42
|
type CreateQueryResult<TData = unknown, TError = DefaultError> = CreateBaseQueryResult<TData, TError>;
|
|
43
43
|
type DefinedCreateBaseQueryResult<TData = unknown, TError = DefaultError> = DefinedQueryObserverResult<TData, TError>;
|
|
44
44
|
type DefinedCreateQueryResult<TData = unknown, TError = DefaultError> = DefinedCreateBaseQueryResult<TData, TError>;
|
|
45
|
-
interface SolidInfiniteQueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> extends
|
|
45
|
+
interface SolidInfiniteQueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> extends OmitKeyof<InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey, TPageParam>, 'queryKey'> {
|
|
46
46
|
queryKey: TQueryKey;
|
|
47
47
|
deferStream?: boolean;
|
|
48
48
|
}
|
|
49
49
|
type CreateInfiniteQueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = FunctionedParams<SolidInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey, TPageParam>>;
|
|
50
50
|
type CreateInfiniteQueryResult<TData = unknown, TError = DefaultError> = InfiniteQueryObserverResult<TData, TError>;
|
|
51
|
-
interface SolidMutationOptions<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown> extends
|
|
51
|
+
interface SolidMutationOptions<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown> extends OmitKeyof<MutationObserverOptions<TData, TError, TVariables, TContext>, '_defaulted'> {
|
|
52
52
|
}
|
|
53
53
|
type CreateMutationOptions<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown> = FunctionedParams<SolidMutationOptions<TData, TError, TVariables, TContext>>;
|
|
54
54
|
type CreateMutateFunction<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown> = (...args: Parameters<MutateFunction<TData, TError, TVariables, TContext>>) => void;
|
|
@@ -96,7 +96,7 @@ type MutationStateOptions<TResult = MutationState> = {
|
|
|
96
96
|
};
|
|
97
97
|
declare function useMutationState<TResult = MutationState>(options?: Accessor<MutationStateOptions<TResult>>, queryClient?: Accessor<QueryClient>): Accessor<Array<TResult>>;
|
|
98
98
|
|
|
99
|
-
type CreateQueryOptionsForCreateQueries<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> =
|
|
99
|
+
type CreateQueryOptionsForCreateQueries<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = OmitKeyof<SolidQueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'placeholderData'> & {
|
|
100
100
|
placeholderData?: TQueryFnData | QueriesPlaceholderDataFunction<TQueryFnData>;
|
|
101
101
|
};
|
|
102
102
|
type MAXIMUM_DEPTH = 20;
|
|
@@ -147,7 +147,7 @@ type QueriesOptions<T extends Array<any>, TResult extends Array<any> = [], TDept
|
|
|
147
147
|
], [
|
|
148
148
|
...TDepth,
|
|
149
149
|
1
|
|
150
|
-
]> :
|
|
150
|
+
]> : ReadonlyArray<unknown> extends T ? T : T extends Array<CreateQueryOptionsForCreateQueries<infer TQueryFnData, infer TError, infer TData, infer TQueryKey>> ? Array<CreateQueryOptionsForCreateQueries<TQueryFnData, TError, TData, TQueryKey>> : Array<CreateQueryOptionsForCreateQueries>;
|
|
151
151
|
/**
|
|
152
152
|
* QueriesResults reducer recursively maps type param to results
|
|
153
153
|
*/
|
package/build/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { DefaultError, QueryKey, QueryObserverOptions as QueryObserverOptions$1, InfiniteQueryObserverOptions as InfiniteQueryObserverOptions$1, DefaultOptions as DefaultOptions$1, QueryClientConfig as QueryClientConfig$1, QueryClient as QueryClient$1, QueryObserverResult, DefinedQueryObserverResult, InfiniteQueryObserverResult, MutationObserverOptions, MutateFunction, MutationObserverResult, QueryFilters, InfiniteData, MutationFilters, MutationState, Mutation, QueriesPlaceholderDataFunction, QueryFunction, SkipToken, ThrowOnError } from '@tanstack/query-core';
|
|
1
|
+
import { DefaultError, QueryKey, OmitKeyof, QueryObserverOptions as QueryObserverOptions$1, InfiniteQueryObserverOptions as InfiniteQueryObserverOptions$1, DefaultOptions as DefaultOptions$1, QueryClientConfig as QueryClientConfig$1, QueryClient as QueryClient$1, QueryObserverResult, DefinedQueryObserverResult, InfiniteQueryObserverResult, MutationObserverOptions, MutateFunction, MutationObserverResult, QueryFilters, InfiniteData, MutationFilters, MutationState, Mutation, QueriesPlaceholderDataFunction, QueryFunction, SkipToken, 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';
|
|
5
5
|
|
|
6
|
-
interface QueryObserverOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = never> extends
|
|
6
|
+
interface QueryObserverOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = never> extends OmitKeyof<QueryObserverOptions$1<TQueryFnData, TError, TData, TQueryData, TQueryKey, TPageParam>, 'structuralSharing'> {
|
|
7
7
|
/**
|
|
8
8
|
* Set this to a reconciliation key to enable reconciliation between query results.
|
|
9
9
|
* Set this to `false` to disable reconciliation between query results.
|
|
@@ -12,7 +12,7 @@ interface QueryObserverOptions<TQueryFnData = unknown, TError = DefaultError, TD
|
|
|
12
12
|
*/
|
|
13
13
|
reconcile?: string | false | ((oldData: TData | undefined, newData: TData) => TData);
|
|
14
14
|
}
|
|
15
|
-
interface InfiniteQueryObserverOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> extends
|
|
15
|
+
interface InfiniteQueryObserverOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> extends OmitKeyof<InfiniteQueryObserverOptions$1<TQueryFnData, TError, TData, TQueryData, TQueryKey, TPageParam>, 'structuralSharing'> {
|
|
16
16
|
/**
|
|
17
17
|
* Set this to a reconciliation key to enable reconciliation between query results.
|
|
18
18
|
* Set this to `false` to disable reconciliation between query results.
|
|
@@ -22,7 +22,7 @@ interface InfiniteQueryObserverOptions<TQueryFnData = unknown, TError = DefaultE
|
|
|
22
22
|
reconcile?: string | false | ((oldData: TData | undefined, newData: TData) => TData);
|
|
23
23
|
}
|
|
24
24
|
interface DefaultOptions<TError = DefaultError> extends DefaultOptions$1<TError> {
|
|
25
|
-
queries?:
|
|
25
|
+
queries?: OmitKeyof<QueryObserverOptions<unknown, TError>, 'queryKey'>;
|
|
26
26
|
}
|
|
27
27
|
interface QueryClientConfig extends QueryClientConfig$1 {
|
|
28
28
|
defaultOptions?: DefaultOptions;
|
|
@@ -42,13 +42,13 @@ type CreateBaseQueryResult<TData = unknown, TError = DefaultError> = QueryObserv
|
|
|
42
42
|
type CreateQueryResult<TData = unknown, TError = DefaultError> = CreateBaseQueryResult<TData, TError>;
|
|
43
43
|
type DefinedCreateBaseQueryResult<TData = unknown, TError = DefaultError> = DefinedQueryObserverResult<TData, TError>;
|
|
44
44
|
type DefinedCreateQueryResult<TData = unknown, TError = DefaultError> = DefinedCreateBaseQueryResult<TData, TError>;
|
|
45
|
-
interface SolidInfiniteQueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> extends
|
|
45
|
+
interface SolidInfiniteQueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> extends OmitKeyof<InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey, TPageParam>, 'queryKey'> {
|
|
46
46
|
queryKey: TQueryKey;
|
|
47
47
|
deferStream?: boolean;
|
|
48
48
|
}
|
|
49
49
|
type CreateInfiniteQueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = FunctionedParams<SolidInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey, TPageParam>>;
|
|
50
50
|
type CreateInfiniteQueryResult<TData = unknown, TError = DefaultError> = InfiniteQueryObserverResult<TData, TError>;
|
|
51
|
-
interface SolidMutationOptions<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown> extends
|
|
51
|
+
interface SolidMutationOptions<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown> extends OmitKeyof<MutationObserverOptions<TData, TError, TVariables, TContext>, '_defaulted'> {
|
|
52
52
|
}
|
|
53
53
|
type CreateMutationOptions<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown> = FunctionedParams<SolidMutationOptions<TData, TError, TVariables, TContext>>;
|
|
54
54
|
type CreateMutateFunction<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown> = (...args: Parameters<MutateFunction<TData, TError, TVariables, TContext>>) => void;
|
|
@@ -96,7 +96,7 @@ type MutationStateOptions<TResult = MutationState> = {
|
|
|
96
96
|
};
|
|
97
97
|
declare function useMutationState<TResult = MutationState>(options?: Accessor<MutationStateOptions<TResult>>, queryClient?: Accessor<QueryClient>): Accessor<Array<TResult>>;
|
|
98
98
|
|
|
99
|
-
type CreateQueryOptionsForCreateQueries<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> =
|
|
99
|
+
type CreateQueryOptionsForCreateQueries<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = OmitKeyof<SolidQueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'placeholderData'> & {
|
|
100
100
|
placeholderData?: TQueryFnData | QueriesPlaceholderDataFunction<TQueryFnData>;
|
|
101
101
|
};
|
|
102
102
|
type MAXIMUM_DEPTH = 20;
|
|
@@ -147,7 +147,7 @@ type QueriesOptions<T extends Array<any>, TResult extends Array<any> = [], TDept
|
|
|
147
147
|
], [
|
|
148
148
|
...TDepth,
|
|
149
149
|
1
|
|
150
|
-
]> :
|
|
150
|
+
]> : ReadonlyArray<unknown> extends T ? T : T extends Array<CreateQueryOptionsForCreateQueries<infer TQueryFnData, infer TError, infer TData, infer TQueryKey>> ? Array<CreateQueryOptionsForCreateQueries<TQueryFnData, TError, TData, TQueryKey>> : Array<CreateQueryOptionsForCreateQueries>;
|
|
151
151
|
/**
|
|
152
152
|
* QueriesResults reducer recursively maps type param to results
|
|
153
153
|
*/
|
package/build/index.js
CHANGED
|
@@ -98,6 +98,7 @@ function createBaseQuery(options, Observer, queryClient) {
|
|
|
98
98
|
}
|
|
99
99
|
return defaultOptions;
|
|
100
100
|
});
|
|
101
|
+
const initialOptions = defaultedOptions();
|
|
101
102
|
const [observer, setObserver] = createSignal(
|
|
102
103
|
new Observer(client(), defaultedOptions())
|
|
103
104
|
);
|
|
@@ -187,13 +188,12 @@ function createBaseQuery(options, Observer, queryClient) {
|
|
|
187
188
|
* Note that this is only invoked on the client, for queries that were originally run on the server.
|
|
188
189
|
*/
|
|
189
190
|
onHydrated(_k, info) {
|
|
190
|
-
const defaultOptions = defaultedOptions();
|
|
191
191
|
if (info.value) {
|
|
192
192
|
hydrate(client(), {
|
|
193
193
|
queries: [
|
|
194
194
|
{
|
|
195
|
-
queryKey:
|
|
196
|
-
queryHash:
|
|
195
|
+
queryKey: initialOptions.queryKey,
|
|
196
|
+
queryHash: initialOptions.queryHash,
|
|
197
197
|
state: info.value
|
|
198
198
|
}
|
|
199
199
|
]
|
|
@@ -201,8 +201,8 @@ function createBaseQuery(options, Observer, queryClient) {
|
|
|
201
201
|
}
|
|
202
202
|
if (unsubscribe)
|
|
203
203
|
return;
|
|
204
|
-
const newOptions = { ...
|
|
205
|
-
if (
|
|
204
|
+
const newOptions = { ...initialOptions };
|
|
205
|
+
if (initialOptions.staleTime || !initialOptions.initialData) {
|
|
206
206
|
newOptions.refetchOnMount = false;
|
|
207
207
|
}
|
|
208
208
|
observer().setOptions(newOptions);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/solid-query",
|
|
3
|
-
"version": "5.28.
|
|
3
|
+
"version": "5.28.9",
|
|
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.8.14",
|
|
51
|
-
"@tanstack/query-core": "5.28.
|
|
51
|
+
"@tanstack/query-core": "5.28.9"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"tsup-preset-solid": "^2.2.0",
|
package/src/QueryClient.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { QueryClient as QueryCoreClient } from '@tanstack/query-core'
|
|
|
2
2
|
import type {
|
|
3
3
|
DefaultOptions as CoreDefaultOptions,
|
|
4
4
|
DefaultError,
|
|
5
|
+
OmitKeyof,
|
|
5
6
|
QueryClientConfig as QueryCoreClientConfig,
|
|
6
7
|
InfiniteQueryObserverOptions as QueryCoreInfiniteQueryObserverOptions,
|
|
7
8
|
QueryObserverOptions as QueryCoreObserverOptions,
|
|
@@ -15,7 +16,7 @@ export interface QueryObserverOptions<
|
|
|
15
16
|
TQueryData = TQueryFnData,
|
|
16
17
|
TQueryKey extends QueryKey = QueryKey,
|
|
17
18
|
TPageParam = never,
|
|
18
|
-
> extends
|
|
19
|
+
> extends OmitKeyof<
|
|
19
20
|
QueryCoreObserverOptions<
|
|
20
21
|
TQueryFnData,
|
|
21
22
|
TError,
|
|
@@ -45,7 +46,7 @@ export interface InfiniteQueryObserverOptions<
|
|
|
45
46
|
TQueryData = TQueryFnData,
|
|
46
47
|
TQueryKey extends QueryKey = QueryKey,
|
|
47
48
|
TPageParam = unknown,
|
|
48
|
-
> extends
|
|
49
|
+
> extends OmitKeyof<
|
|
49
50
|
QueryCoreInfiniteQueryObserverOptions<
|
|
50
51
|
TQueryFnData,
|
|
51
52
|
TError,
|
|
@@ -70,7 +71,7 @@ export interface InfiniteQueryObserverOptions<
|
|
|
70
71
|
|
|
71
72
|
export interface DefaultOptions<TError = DefaultError>
|
|
72
73
|
extends CoreDefaultOptions<TError> {
|
|
73
|
-
queries?:
|
|
74
|
+
queries?: OmitKeyof<QueryObserverOptions<unknown, TError>, 'queryKey'>
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
export interface QueryClientConfig extends QueryCoreClientConfig {
|
|
@@ -30,6 +30,7 @@ import type {
|
|
|
30
30
|
CreateQueryOptions,
|
|
31
31
|
CreateQueryResult,
|
|
32
32
|
DefinedCreateQueryResult,
|
|
33
|
+
OmitKeyof,
|
|
33
34
|
QueryFunction,
|
|
34
35
|
} from '..'
|
|
35
36
|
import type { Mock } from 'vitest'
|
|
@@ -163,9 +164,10 @@ describe('createQuery', () => {
|
|
|
163
164
|
token: string,
|
|
164
165
|
// return type must be wrapped with TQueryFnReturn
|
|
165
166
|
) => Promise<TQueryFnData>,
|
|
166
|
-
options?:
|
|
167
|
+
options?: OmitKeyof<
|
|
167
168
|
CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey>,
|
|
168
|
-
'queryKey' | 'queryFn' | 'initialData'
|
|
169
|
+
'queryKey' | 'queryFn' | 'initialData',
|
|
170
|
+
'safely'
|
|
169
171
|
>,
|
|
170
172
|
) =>
|
|
171
173
|
createQuery(() => ({
|
|
@@ -185,9 +187,10 @@ describe('createQuery', () => {
|
|
|
185
187
|
>(
|
|
186
188
|
qk: TQueryKey,
|
|
187
189
|
fetcher: () => Promise<TQueryFnData>,
|
|
188
|
-
options?:
|
|
190
|
+
options?: OmitKeyof<
|
|
189
191
|
CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey>,
|
|
190
|
-
'queryKey' | 'queryFn' | 'initialData'
|
|
192
|
+
'queryKey' | 'queryFn' | 'initialData',
|
|
193
|
+
'safely'
|
|
191
194
|
>,
|
|
192
195
|
) => createQuery(() => ({ queryKey: qk, queryFn: fetcher, ...options }))
|
|
193
196
|
const testFuncStyle = useWrappedFuncStyleQuery([''], async () => true)
|
package/src/createBaseQuery.ts
CHANGED
|
@@ -138,6 +138,7 @@ export function createBaseQuery<
|
|
|
138
138
|
}
|
|
139
139
|
return defaultOptions
|
|
140
140
|
})
|
|
141
|
+
const initialOptions = defaultedOptions()
|
|
141
142
|
|
|
142
143
|
const [observer, setObserver] = createSignal(
|
|
143
144
|
new Observer(client(), defaultedOptions()),
|
|
@@ -254,13 +255,12 @@ export function createBaseQuery<
|
|
|
254
255
|
* Note that this is only invoked on the client, for queries that were originally run on the server.
|
|
255
256
|
*/
|
|
256
257
|
onHydrated(_k, info) {
|
|
257
|
-
const defaultOptions = defaultedOptions()
|
|
258
258
|
if (info.value) {
|
|
259
259
|
hydrate(client(), {
|
|
260
260
|
queries: [
|
|
261
261
|
{
|
|
262
|
-
queryKey:
|
|
263
|
-
queryHash:
|
|
262
|
+
queryKey: initialOptions.queryKey,
|
|
263
|
+
queryHash: initialOptions.queryHash,
|
|
264
264
|
state: info.value,
|
|
265
265
|
},
|
|
266
266
|
],
|
|
@@ -272,8 +272,8 @@ export function createBaseQuery<
|
|
|
272
272
|
* Do not refetch query on mount if query was fetched on server,
|
|
273
273
|
* even if `staleTime` is not set.
|
|
274
274
|
*/
|
|
275
|
-
const newOptions = { ...
|
|
276
|
-
if (
|
|
275
|
+
const newOptions = { ...initialOptions }
|
|
276
|
+
if (initialOptions.staleTime || !initialOptions.initialData) {
|
|
277
277
|
newOptions.refetchOnMount = false
|
|
278
278
|
}
|
|
279
279
|
// Setting the options as an immutable object to prevent
|
package/src/createQueries.ts
CHANGED
|
@@ -18,6 +18,7 @@ import type { Accessor } from 'solid-js'
|
|
|
18
18
|
import type { QueryClient } from './QueryClient'
|
|
19
19
|
import type {
|
|
20
20
|
DefaultError,
|
|
21
|
+
OmitKeyof,
|
|
21
22
|
QueriesObserverOptions,
|
|
22
23
|
QueriesPlaceholderDataFunction,
|
|
23
24
|
QueryFunction,
|
|
@@ -34,7 +35,7 @@ type CreateQueryOptionsForCreateQueries<
|
|
|
34
35
|
TError = DefaultError,
|
|
35
36
|
TData = TQueryFnData,
|
|
36
37
|
TQueryKey extends QueryKey = QueryKey,
|
|
37
|
-
> =
|
|
38
|
+
> = OmitKeyof<
|
|
38
39
|
SolidQueryOptions<TQueryFnData, TError, TData, TQueryKey>,
|
|
39
40
|
'placeholderData'
|
|
40
41
|
> & {
|
|
@@ -147,7 +148,7 @@ type QueriesOptions<
|
|
|
147
148
|
[...TResult, GetOptions<Head>],
|
|
148
149
|
[...TDepth, 1]
|
|
149
150
|
>
|
|
150
|
-
:
|
|
151
|
+
: ReadonlyArray<unknown> extends T
|
|
151
152
|
? T
|
|
152
153
|
: // If T is *some* array but we couldn't assign unknown[] to it, then it must hold some known/homogenous type!
|
|
153
154
|
// use this to infer the param types in the case of Array.map() argument
|
|
@@ -220,7 +221,7 @@ export function createQueries<
|
|
|
220
221
|
const client = createMemo(() => useQueryClient(queryClient?.()))
|
|
221
222
|
const isRestoring = useIsRestoring()
|
|
222
223
|
|
|
223
|
-
const defaultedQueries = createMemo(() =>
|
|
224
|
+
const defaultedQueries: QueriesOptions<any> = createMemo(() =>
|
|
224
225
|
queriesOptions().queries.map((options) =>
|
|
225
226
|
mergeProps(client().defaultQueryOptions(options), {
|
|
226
227
|
get _optimisticResults() {
|
|
@@ -293,7 +294,7 @@ export function createQueries<
|
|
|
293
294
|
const dataResources_ = dataResources()
|
|
294
295
|
for (let index = 0; index < dataResources_.length; index++) {
|
|
295
296
|
const dataResource = dataResources_[index]!
|
|
296
|
-
const unwrappedResult = { ...unwrap(result[index]
|
|
297
|
+
const unwrappedResult = { ...unwrap(result[index]) }
|
|
297
298
|
// @ts-expect-error typescript pedantry regarding the possible range of index
|
|
298
299
|
setState(index, unwrap(unwrappedResult))
|
|
299
300
|
dataResource[1].mutate(() => unwrap(state[index]!.data))
|
package/src/types.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type {
|
|
|
7
7
|
MutateFunction,
|
|
8
8
|
MutationObserverOptions,
|
|
9
9
|
MutationObserverResult,
|
|
10
|
+
OmitKeyof,
|
|
10
11
|
QueryKey,
|
|
11
12
|
QueryObserverResult,
|
|
12
13
|
} from '@tanstack/query-core'
|
|
@@ -83,7 +84,7 @@ export interface SolidInfiniteQueryOptions<
|
|
|
83
84
|
TQueryData = TQueryFnData,
|
|
84
85
|
TQueryKey extends QueryKey = QueryKey,
|
|
85
86
|
TPageParam = unknown,
|
|
86
|
-
> extends
|
|
87
|
+
> extends OmitKeyof<
|
|
87
88
|
InfiniteQueryObserverOptions<
|
|
88
89
|
TQueryFnData,
|
|
89
90
|
TError,
|
|
@@ -126,7 +127,7 @@ export interface SolidMutationOptions<
|
|
|
126
127
|
TError = DefaultError,
|
|
127
128
|
TVariables = void,
|
|
128
129
|
TContext = unknown,
|
|
129
|
-
> extends
|
|
130
|
+
> extends OmitKeyof<
|
|
130
131
|
MutationObserverOptions<TData, TError, TVariables, TContext>,
|
|
131
132
|
'_defaulted'
|
|
132
133
|
> {}
|