@tanstack/solid-query 5.0.0-alpha.51 → 5.0.0-alpha.53
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/lib/QueryClient.cjs +12 -0
- package/build/lib/QueryClient.cjs.map +1 -0
- package/build/lib/QueryClient.js +10 -0
- package/build/lib/QueryClient.js.map +1 -0
- package/build/lib/QueryClientProvider.cjs +35 -0
- package/build/lib/QueryClientProvider.cjs.map +1 -0
- package/build/lib/QueryClientProvider.js +31 -0
- package/build/lib/QueryClientProvider.js.map +1 -0
- package/build/lib/createBaseQuery.cjs +192 -0
- package/build/lib/createBaseQuery.cjs.map +1 -0
- package/build/lib/createBaseQuery.js +190 -0
- package/build/lib/createBaseQuery.js.map +1 -0
- package/build/lib/createInfiniteQuery.cjs +14 -0
- package/build/lib/createInfiniteQuery.cjs.map +1 -0
- package/build/lib/createInfiniteQuery.js +12 -0
- package/build/lib/createInfiniteQuery.js.map +1 -0
- package/build/lib/createMutation.cjs +44 -0
- package/build/lib/createMutation.cjs.map +1 -0
- package/build/lib/createMutation.js +42 -0
- package/build/lib/createMutation.js.map +1 -0
- package/build/lib/createQueries.cjs +52 -0
- package/build/lib/createQueries.cjs.map +1 -0
- package/build/lib/createQueries.js +50 -0
- package/build/lib/createQueries.js.map +1 -0
- package/build/lib/createQuery.cjs +16 -0
- package/build/lib/createQuery.cjs.map +1 -0
- package/build/lib/createQuery.js +13 -0
- package/build/lib/createQuery.js.map +1 -0
- package/build/lib/index.cjs.map +1 -0
- package/build/lib/index.js +11 -0
- package/build/lib/index.js.map +1 -0
- package/build/lib/setBatchUpdatesFn.cjs +7 -0
- package/build/lib/setBatchUpdatesFn.cjs.map +1 -0
- package/build/{source → lib}/setBatchUpdatesFn.js +2 -0
- package/build/lib/setBatchUpdatesFn.js.map +1 -0
- package/build/lib/useIsFetching.cjs +18 -0
- package/build/lib/useIsFetching.cjs.map +1 -0
- package/build/lib/useIsFetching.js +16 -0
- package/build/lib/useIsFetching.js.map +1 -0
- package/build/lib/useIsMutating.cjs +18 -0
- package/build/lib/useIsMutating.cjs.map +1 -0
- package/build/lib/useIsMutating.js +16 -0
- package/build/lib/useIsMutating.js.map +1 -0
- package/build/lib/utils.cjs +12 -0
- package/build/lib/utils.cjs.map +1 -0
- package/build/lib/utils.js +10 -0
- package/build/lib/utils.js.map +1 -0
- package/build/stats-html.html +6177 -0
- package/build/stats.json +605 -0
- package/package.json +6 -14
- package/build/source/QueryClient.js +0 -6
- package/build/source/QueryClientProvider.jsx +0 -21
- package/build/source/__tests__/QueryClientProvider.test.jsx +0 -120
- package/build/source/__tests__/createInfiniteQuery.test.jsx +0 -1360
- package/build/source/__tests__/createMutation.test.jsx +0 -867
- package/build/source/__tests__/createQueries.test.jsx +0 -590
- package/build/source/__tests__/createQuery.test.jsx +0 -4398
- package/build/source/__tests__/createQuery.types.test.jsx +0 -153
- package/build/source/__tests__/suspense.test.jsx +0 -659
- package/build/source/__tests__/transition.test.jsx +0 -42
- package/build/source/__tests__/useIsFetching.test.jsx +0 -190
- package/build/source/__tests__/useIsMutating.test.jsx +0 -196
- package/build/source/__tests__/utils.jsx +0 -50
- package/build/source/createBaseQuery.js +0 -173
- package/build/source/createInfiniteQuery.js +0 -8
- package/build/source/createMutation.js +0 -38
- package/build/source/createQueries.js +0 -38
- package/build/source/createQuery.js +0 -9
- package/build/source/index.js +0 -15
- package/build/source/types.js +0 -2
- package/build/source/useIsFetching.js +0 -12
- package/build/source/useIsMutating.js +0 -12
- package/build/source/utils.js +0 -7
- /package/build/{types → lib}/QueryClient.d.ts +0 -0
- /package/build/{types → lib}/QueryClient.d.ts.map +0 -0
- /package/build/{types → lib}/QueryClientProvider.d.ts +0 -0
- /package/build/{types → lib}/QueryClientProvider.d.ts.map +0 -0
- /package/build/{types → lib}/__tests__/QueryClientProvider.test.d.ts +0 -0
- /package/build/{types → lib}/__tests__/QueryClientProvider.test.d.ts.map +0 -0
- /package/build/{types → lib}/__tests__/createInfiniteQuery.test.d.ts +0 -0
- /package/build/{types → lib}/__tests__/createInfiniteQuery.test.d.ts.map +0 -0
- /package/build/{types → lib}/__tests__/createMutation.test.d.ts +0 -0
- /package/build/{types → lib}/__tests__/createMutation.test.d.ts.map +0 -0
- /package/build/{types → lib}/__tests__/createQueries.test.d.ts +0 -0
- /package/build/{types → lib}/__tests__/createQueries.test.d.ts.map +0 -0
- /package/build/{types → lib}/__tests__/createQuery.test.d.ts +0 -0
- /package/build/{types → lib}/__tests__/createQuery.test.d.ts.map +0 -0
- /package/build/{types → lib}/__tests__/createQuery.types.test.d.ts +0 -0
- /package/build/{types → lib}/__tests__/createQuery.types.test.d.ts.map +0 -0
- /package/build/{types → lib}/__tests__/suspense.test.d.ts +0 -0
- /package/build/{types → lib}/__tests__/suspense.test.d.ts.map +0 -0
- /package/build/{types → lib}/__tests__/transition.test.d.ts +0 -0
- /package/build/{types → lib}/__tests__/transition.test.d.ts.map +0 -0
- /package/build/{types → lib}/__tests__/useIsFetching.test.d.ts +0 -0
- /package/build/{types → lib}/__tests__/useIsFetching.test.d.ts.map +0 -0
- /package/build/{types → lib}/__tests__/useIsMutating.test.d.ts +0 -0
- /package/build/{types → lib}/__tests__/useIsMutating.test.d.ts.map +0 -0
- /package/build/{types → lib}/__tests__/utils.d.ts +0 -0
- /package/build/{types → lib}/__tests__/utils.d.ts.map +0 -0
- /package/build/{types → lib}/createBaseQuery.d.ts +0 -0
- /package/build/{types → lib}/createBaseQuery.d.ts.map +0 -0
- /package/build/{types → lib}/createInfiniteQuery.d.ts +0 -0
- /package/build/{types → lib}/createInfiniteQuery.d.ts.map +0 -0
- /package/build/{types → lib}/createMutation.d.ts +0 -0
- /package/build/{types → lib}/createMutation.d.ts.map +0 -0
- /package/build/{types → lib}/createQueries.d.ts +0 -0
- /package/build/{types → lib}/createQueries.d.ts.map +0 -0
- /package/build/{types → lib}/createQuery.d.ts +0 -0
- /package/build/{types → lib}/createQuery.d.ts.map +0 -0
- /package/build/{types → lib}/index.d.ts +0 -0
- /package/build/{types → lib}/index.d.ts.map +0 -0
- /package/build/{types → lib}/setBatchUpdatesFn.d.ts +0 -0
- /package/build/{types → lib}/setBatchUpdatesFn.d.ts.map +0 -0
- /package/build/{types → lib}/types.d.ts +0 -0
- /package/build/{types → lib}/types.d.ts.map +0 -0
- /package/build/{types → lib}/useIsFetching.d.ts +0 -0
- /package/build/{types → lib}/useIsFetching.d.ts.map +0 -0
- /package/build/{types → lib}/useIsMutating.d.ts +0 -0
- /package/build/{types → lib}/useIsMutating.d.ts.map +0 -0
- /package/build/{types → lib}/utils.d.ts +0 -0
- /package/build/{types → lib}/utils.d.ts.map +0 -0
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { MutationObserver } from '@tanstack/query-core';
|
|
2
|
-
import { useQueryClient } from './QueryClientProvider';
|
|
3
|
-
import { createComputed, onCleanup, on } from 'solid-js';
|
|
4
|
-
import { createStore } from 'solid-js/store';
|
|
5
|
-
import { shouldThrowError } from './utils';
|
|
6
|
-
// HOOK
|
|
7
|
-
export function createMutation(options, queryClient) {
|
|
8
|
-
const client = useQueryClient(queryClient?.());
|
|
9
|
-
const observer = new MutationObserver(client, options());
|
|
10
|
-
const mutate = (variables, mutateOptions) => {
|
|
11
|
-
observer.mutate(variables, mutateOptions).catch(noop);
|
|
12
|
-
};
|
|
13
|
-
const [state, setState] = createStore({
|
|
14
|
-
...observer.getCurrentResult(),
|
|
15
|
-
mutate,
|
|
16
|
-
mutateAsync: observer.getCurrentResult().mutate,
|
|
17
|
-
});
|
|
18
|
-
createComputed(() => {
|
|
19
|
-
observer.setOptions(options());
|
|
20
|
-
});
|
|
21
|
-
createComputed(on(() => state.status, () => {
|
|
22
|
-
if (state.isError &&
|
|
23
|
-
shouldThrowError(observer.options.throwOnError, [state.error])) {
|
|
24
|
-
throw state.error;
|
|
25
|
-
}
|
|
26
|
-
}));
|
|
27
|
-
const unsubscribe = observer.subscribe((result) => {
|
|
28
|
-
setState({
|
|
29
|
-
...result,
|
|
30
|
-
mutate,
|
|
31
|
-
mutateAsync: result.mutate,
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
onCleanup(unsubscribe);
|
|
35
|
-
return state;
|
|
36
|
-
}
|
|
37
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
38
|
-
function noop() { }
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { notifyManager, QueriesObserver } from '@tanstack/query-core';
|
|
2
|
-
import { createComputed, onCleanup } from 'solid-js';
|
|
3
|
-
import { createStore, unwrap } from 'solid-js/store';
|
|
4
|
-
import { useQueryClient } from './QueryClientProvider';
|
|
5
|
-
export function createQueries(queriesOptions, queryClient) {
|
|
6
|
-
const client = useQueryClient(queryClient?.());
|
|
7
|
-
const defaultedQueries = queriesOptions().queries.map((options) => {
|
|
8
|
-
const defaultedOptions = client.defaultQueryOptions(options);
|
|
9
|
-
defaultedOptions._optimisticResults = 'optimistic';
|
|
10
|
-
return defaultedOptions;
|
|
11
|
-
});
|
|
12
|
-
const observer = new QueriesObserver(client, defaultedQueries, queriesOptions().combine
|
|
13
|
-
? {
|
|
14
|
-
combine: queriesOptions().combine,
|
|
15
|
-
}
|
|
16
|
-
: undefined);
|
|
17
|
-
// @ts-expect-error - Types issue with solid-js createStore
|
|
18
|
-
const [state, setState] = createStore(observer.getOptimisticResult(defaultedQueries)[1]());
|
|
19
|
-
const unsubscribe = observer.subscribe((result) => {
|
|
20
|
-
notifyManager.batchCalls(() => {
|
|
21
|
-
setState(unwrap(result));
|
|
22
|
-
})();
|
|
23
|
-
});
|
|
24
|
-
onCleanup(unsubscribe);
|
|
25
|
-
createComputed(() => {
|
|
26
|
-
const updatedQueries = queriesOptions().queries.map((options) => {
|
|
27
|
-
const defaultedOptions = client.defaultQueryOptions(options);
|
|
28
|
-
defaultedOptions._optimisticResults = 'optimistic';
|
|
29
|
-
return defaultedOptions;
|
|
30
|
-
});
|
|
31
|
-
observer.setQueries(updatedQueries, queriesOptions().combine
|
|
32
|
-
? {
|
|
33
|
-
combine: queriesOptions().combine,
|
|
34
|
-
}
|
|
35
|
-
: undefined, { listeners: false });
|
|
36
|
-
});
|
|
37
|
-
return state;
|
|
38
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { QueryObserver } from '@tanstack/query-core';
|
|
2
|
-
import { createMemo } from 'solid-js';
|
|
3
|
-
import { createBaseQuery } from './createBaseQuery';
|
|
4
|
-
export function queryOptions(options) {
|
|
5
|
-
return options;
|
|
6
|
-
}
|
|
7
|
-
export function createQuery(options, queryClient) {
|
|
8
|
-
return createBaseQuery(createMemo(() => options()), QueryObserver, queryClient);
|
|
9
|
-
}
|
package/build/source/index.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/* istanbul ignore file */
|
|
2
|
-
// Side Effects
|
|
3
|
-
import './setBatchUpdatesFn';
|
|
4
|
-
// Re-export core
|
|
5
|
-
export * from '@tanstack/query-core';
|
|
6
|
-
// Solid Query
|
|
7
|
-
export * from './types';
|
|
8
|
-
export { QueryClient } from './QueryClient';
|
|
9
|
-
export { createQuery, queryOptions } from './createQuery';
|
|
10
|
-
export { QueryClientContext, QueryClientProvider, useQueryClient, } from './QueryClientProvider';
|
|
11
|
-
export { useIsFetching } from './useIsFetching';
|
|
12
|
-
export { createInfiniteQuery } from './createInfiniteQuery';
|
|
13
|
-
export { createMutation } from './createMutation';
|
|
14
|
-
export { useIsMutating } from './useIsMutating';
|
|
15
|
-
export { createQueries } from './createQueries';
|
package/build/source/types.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { createMemo, createSignal, onCleanup } from 'solid-js';
|
|
2
|
-
import { useQueryClient } from './QueryClientProvider';
|
|
3
|
-
export function useIsFetching(filters, queryClient) {
|
|
4
|
-
const client = createMemo(() => useQueryClient(queryClient?.()));
|
|
5
|
-
const queryCache = createMemo(() => client().getQueryCache());
|
|
6
|
-
const [fetches, setFetches] = createSignal(client().isFetching(filters?.()));
|
|
7
|
-
const unsubscribe = queryCache().subscribe(() => {
|
|
8
|
-
setFetches(client().isFetching(filters?.()));
|
|
9
|
-
});
|
|
10
|
-
onCleanup(unsubscribe);
|
|
11
|
-
return fetches;
|
|
12
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { useQueryClient } from './QueryClientProvider';
|
|
2
|
-
import { createSignal, onCleanup, createMemo } from 'solid-js';
|
|
3
|
-
export function useIsMutating(filters, queryClient) {
|
|
4
|
-
const client = createMemo(() => useQueryClient(queryClient?.()));
|
|
5
|
-
const mutationCache = createMemo(() => client().getMutationCache());
|
|
6
|
-
const [mutations, setMutations] = createSignal(client().isMutating(filters?.()));
|
|
7
|
-
const unsubscribe = mutationCache().subscribe((_result) => {
|
|
8
|
-
setMutations(client().isMutating(filters?.()));
|
|
9
|
-
});
|
|
10
|
-
onCleanup(unsubscribe);
|
|
11
|
-
return mutations;
|
|
12
|
-
}
|
package/build/source/utils.js
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|