@tanstack/solid-query 5.0.0-alpha.52 → 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.
Files changed (75) hide show
  1. package/build/stats-html.html +1 -1
  2. package/build/stats.json +147 -147
  3. package/package.json +5 -10
  4. package/build/source/QueryClient.js +0 -6
  5. package/build/source/QueryClientProvider.jsx +0 -21
  6. package/build/source/__tests__/QueryClientProvider.test.jsx +0 -120
  7. package/build/source/__tests__/createInfiniteQuery.test.jsx +0 -1360
  8. package/build/source/__tests__/createMutation.test.jsx +0 -867
  9. package/build/source/__tests__/createQueries.test.jsx +0 -590
  10. package/build/source/__tests__/createQuery.test.jsx +0 -4398
  11. package/build/source/__tests__/createQuery.types.test.jsx +0 -153
  12. package/build/source/__tests__/suspense.test.jsx +0 -659
  13. package/build/source/__tests__/transition.test.jsx +0 -42
  14. package/build/source/__tests__/useIsFetching.test.jsx +0 -190
  15. package/build/source/__tests__/useIsMutating.test.jsx +0 -196
  16. package/build/source/__tests__/utils.jsx +0 -50
  17. package/build/source/createBaseQuery.js +0 -173
  18. package/build/source/createInfiniteQuery.js +0 -8
  19. package/build/source/createMutation.js +0 -38
  20. package/build/source/createQueries.js +0 -38
  21. package/build/source/createQuery.js +0 -9
  22. package/build/source/index.js +0 -15
  23. package/build/source/setBatchUpdatesFn.js +0 -3
  24. package/build/source/types.js +0 -2
  25. package/build/source/useIsFetching.js +0 -12
  26. package/build/source/useIsMutating.js +0 -12
  27. package/build/source/utils.js +0 -7
  28. /package/build/{types → lib}/QueryClient.d.ts +0 -0
  29. /package/build/{types → lib}/QueryClient.d.ts.map +0 -0
  30. /package/build/{types → lib}/QueryClientProvider.d.ts +0 -0
  31. /package/build/{types → lib}/QueryClientProvider.d.ts.map +0 -0
  32. /package/build/{types → lib}/__tests__/QueryClientProvider.test.d.ts +0 -0
  33. /package/build/{types → lib}/__tests__/QueryClientProvider.test.d.ts.map +0 -0
  34. /package/build/{types → lib}/__tests__/createInfiniteQuery.test.d.ts +0 -0
  35. /package/build/{types → lib}/__tests__/createInfiniteQuery.test.d.ts.map +0 -0
  36. /package/build/{types → lib}/__tests__/createMutation.test.d.ts +0 -0
  37. /package/build/{types → lib}/__tests__/createMutation.test.d.ts.map +0 -0
  38. /package/build/{types → lib}/__tests__/createQueries.test.d.ts +0 -0
  39. /package/build/{types → lib}/__tests__/createQueries.test.d.ts.map +0 -0
  40. /package/build/{types → lib}/__tests__/createQuery.test.d.ts +0 -0
  41. /package/build/{types → lib}/__tests__/createQuery.test.d.ts.map +0 -0
  42. /package/build/{types → lib}/__tests__/createQuery.types.test.d.ts +0 -0
  43. /package/build/{types → lib}/__tests__/createQuery.types.test.d.ts.map +0 -0
  44. /package/build/{types → lib}/__tests__/suspense.test.d.ts +0 -0
  45. /package/build/{types → lib}/__tests__/suspense.test.d.ts.map +0 -0
  46. /package/build/{types → lib}/__tests__/transition.test.d.ts +0 -0
  47. /package/build/{types → lib}/__tests__/transition.test.d.ts.map +0 -0
  48. /package/build/{types → lib}/__tests__/useIsFetching.test.d.ts +0 -0
  49. /package/build/{types → lib}/__tests__/useIsFetching.test.d.ts.map +0 -0
  50. /package/build/{types → lib}/__tests__/useIsMutating.test.d.ts +0 -0
  51. /package/build/{types → lib}/__tests__/useIsMutating.test.d.ts.map +0 -0
  52. /package/build/{types → lib}/__tests__/utils.d.ts +0 -0
  53. /package/build/{types → lib}/__tests__/utils.d.ts.map +0 -0
  54. /package/build/{types → lib}/createBaseQuery.d.ts +0 -0
  55. /package/build/{types → lib}/createBaseQuery.d.ts.map +0 -0
  56. /package/build/{types → lib}/createInfiniteQuery.d.ts +0 -0
  57. /package/build/{types → lib}/createInfiniteQuery.d.ts.map +0 -0
  58. /package/build/{types → lib}/createMutation.d.ts +0 -0
  59. /package/build/{types → lib}/createMutation.d.ts.map +0 -0
  60. /package/build/{types → lib}/createQueries.d.ts +0 -0
  61. /package/build/{types → lib}/createQueries.d.ts.map +0 -0
  62. /package/build/{types → lib}/createQuery.d.ts +0 -0
  63. /package/build/{types → lib}/createQuery.d.ts.map +0 -0
  64. /package/build/{types → lib}/index.d.ts +0 -0
  65. /package/build/{types → lib}/index.d.ts.map +0 -0
  66. /package/build/{types → lib}/setBatchUpdatesFn.d.ts +0 -0
  67. /package/build/{types → lib}/setBatchUpdatesFn.d.ts.map +0 -0
  68. /package/build/{types → lib}/types.d.ts +0 -0
  69. /package/build/{types → lib}/types.d.ts.map +0 -0
  70. /package/build/{types → lib}/useIsFetching.d.ts +0 -0
  71. /package/build/{types → lib}/useIsFetching.d.ts.map +0 -0
  72. /package/build/{types → lib}/useIsMutating.d.ts +0 -0
  73. /package/build/{types → lib}/useIsMutating.d.ts.map +0 -0
  74. /package/build/{types → lib}/utils.d.ts +0 -0
  75. /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
- }
@@ -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';
@@ -1,3 +0,0 @@
1
- import { notifyManager } from '@tanstack/query-core';
2
- import { batch } from 'solid-js';
3
- notifyManager.setBatchNotifyFunction(batch);
@@ -1,2 +0,0 @@
1
- /* istanbul ignore file */
2
- export {};
@@ -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
- }
@@ -1,7 +0,0 @@
1
- export function shouldThrowError(throwError, params) {
2
- // Allow throwError function to override throwing behavior on a per-error basis
3
- if (typeof throwError === 'function') {
4
- return throwError(...params);
5
- }
6
- return !!throwError;
7
- }
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