@tramvai/react-query 2.70.0 → 2.72.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.
@@ -0,0 +1,6 @@
1
+ const QUERY_PARAMETERS = '__query_parameters__';
2
+ const isQuery = (arg) => {
3
+ return QUERY_PARAMETERS in arg;
4
+ };
5
+
6
+ export { QUERY_PARAMETERS, isQuery };
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const QUERY_PARAMETERS = '__query_parameters__';
6
+ const isQuery = (arg) => {
7
+ return QUERY_PARAMETERS in arg;
8
+ };
9
+
10
+ exports.QUERY_PARAMETERS = QUERY_PARAMETERS;
11
+ exports.isQuery = isQuery;
package/lib/index.es.js CHANGED
@@ -1,279 +1,7 @@
1
- import identity from '@tinkoff/utils/function/identity';
2
- import { DI_TOKEN } from '@tinkoff/dippy';
3
- import { declareAction } from '@tramvai/core';
4
- import { QUERY_CLIENT_TOKEN } from '@tramvai/module-react-query';
5
- import { CONTEXT_TOKEN } from '@tramvai/tokens-common';
6
- import isArray from '@tinkoff/utils/is/array';
7
- import { useMemo } from 'react';
8
- import { useQuery as useQuery$1, useQueries as useQueries$1, useInfiniteQuery as useInfiniteQuery$1, useMutation as useMutation$1 } from '@tanstack/react-query';
1
+ export { createQuery } from './query/create.es.js';
2
+ export { useQueries, useQuery } from './query/use.es.js';
3
+ export { createInfiniteQuery } from './infiniteQuery/create.es.js';
4
+ export { useInfiniteQuery } from './infiniteQuery/use.es.js';
5
+ export { createMutation } from './mutation/create.es.js';
6
+ export { useMutation } from './mutation/use.es.js';
9
7
  export { useQueryClient } from '@tanstack/react-query';
10
- import { useShallowEqual } from '@tinkoff/react-hooks';
11
- import { useDiContainer } from '@tramvai/react';
12
-
13
- const QUERY_PARAMETERS = '__query_parameters__';
14
- const isQuery = (arg) => {
15
- return QUERY_PARAMETERS in arg;
16
- };
17
-
18
- const normalizeKey = (key) => {
19
- if (isArray(key)) {
20
- return key;
21
- }
22
- return [key];
23
- };
24
-
25
- const isActionContext = (diOrContext) => {
26
- return 'di' in diOrContext;
27
- };
28
- // @TODO: v3: leave only di container in next major
29
- const resolveDI = (diOrContext) => {
30
- if (isActionContext(diOrContext)) {
31
- return diOrContext.di;
32
- }
33
- return diOrContext;
34
- };
35
-
36
- const convertToRawQuery$1 = (query, di, options) => {
37
- const { key = identity, fn, deps = {}, conditions, queryOptions } = query[QUERY_PARAMETERS];
38
- const resolvedDeps = di.getOfDeps(deps);
39
- const ctx = { deps: resolvedDeps };
40
- const rawQueryKey = typeof key === 'function' ? key.call(ctx, options) : key;
41
- const queryKey = normalizeKey(rawQueryKey);
42
- const actionWrapper = declareAction({
43
- name: 'queryExecution',
44
- async fn() {
45
- return fn.call(ctx, options, ctx.deps);
46
- },
47
- deps,
48
- conditions,
49
- conditionsFailResult: 'reject',
50
- });
51
- return {
52
- ...queryOptions,
53
- queryKey,
54
- tramvaiOptions: {
55
- conditions,
56
- },
57
- queryFn: () => {
58
- const context = di.get(CONTEXT_TOKEN);
59
- return context.executeAction(actionWrapper);
60
- },
61
- };
62
- };
63
- const createQuery = (queryParameters) => {
64
- const { queryOptions, conditions } = queryParameters;
65
- const query = {
66
- [QUERY_PARAMETERS]: queryParameters,
67
- fork: (options) => {
68
- return createQuery({
69
- ...queryParameters,
70
- queryOptions: {
71
- ...queryOptions,
72
- ...options,
73
- },
74
- });
75
- },
76
- raw: (diOrContext, options) => {
77
- return convertToRawQuery$1(query, resolveDI(diOrContext), options);
78
- },
79
- prefetchAction: (options) => {
80
- return declareAction({
81
- name: 'queryPrefetch',
82
- fn() {
83
- return this.deps.queryClient.prefetchQuery(convertToRawQuery$1(query, this.deps.di, options));
84
- },
85
- deps: {
86
- di: DI_TOKEN,
87
- queryClient: QUERY_CLIENT_TOKEN,
88
- },
89
- conditions,
90
- });
91
- },
92
- fetchAction: (options) => {
93
- return declareAction({
94
- name: 'queryFetch',
95
- fn() {
96
- return this.deps.queryClient.fetchQuery(convertToRawQuery$1(query, this.deps.di, options));
97
- },
98
- deps: {
99
- di: DI_TOKEN,
100
- queryClient: QUERY_CLIENT_TOKEN,
101
- },
102
- conditions,
103
- });
104
- },
105
- };
106
- return query;
107
- };
108
-
109
- function useQuery(query, options) {
110
- const di = useDiContainer();
111
- const resultQuery = useMemo(() => {
112
- if (isQuery(query)) {
113
- return query.raw(di, options);
114
- }
115
- return query;
116
- }, [query, di, options]);
117
- return useQuery$1(resultQuery);
118
- }
119
- function useQueries(queries) {
120
- const di = useDiContainer();
121
- const memoQueries = useShallowEqual(queries);
122
- const resultQueries = useMemo(() => {
123
- return memoQueries.map((query) => {
124
- if (isQuery(query)) {
125
- return query.raw(di);
126
- }
127
- return query;
128
- });
129
- }, [memoQueries, di]);
130
- return useQueries$1({ queries: resultQueries });
131
- }
132
-
133
- const convertToRawQuery = (query, di, options) => {
134
- const { key = identity, fn, getNextPageParam, getPreviousPageParam, deps = {}, conditions, infiniteQueryOptions, } = query[QUERY_PARAMETERS];
135
- const resolvedDeps = di.getOfDeps(deps);
136
- const ctx = { deps: resolvedDeps };
137
- const rawQueryKey = typeof key === 'function' ? key.call(ctx, options) : key;
138
- const queryKey = normalizeKey(rawQueryKey);
139
- const actionWrapper = declareAction({
140
- name: 'infiniteQueryExecution',
141
- async fn(pageParam) {
142
- return fn.call(ctx, options, pageParam, ctx.deps);
143
- },
144
- conditionsFailResult: 'reject',
145
- deps,
146
- conditions,
147
- });
148
- return {
149
- ...infiniteQueryOptions,
150
- getNextPageParam,
151
- getPreviousPageParam,
152
- queryKey,
153
- tramvaiOptions: {
154
- conditions,
155
- },
156
- queryFn: ({ pageParam }) => {
157
- const context = di.get(CONTEXT_TOKEN);
158
- return context.executeAction(actionWrapper, pageParam);
159
- },
160
- };
161
- };
162
- const createInfiniteQuery = (queryParameters) => {
163
- const { infiniteQueryOptions, conditions } = queryParameters;
164
- const query = {
165
- [QUERY_PARAMETERS]: queryParameters,
166
- fork: (options) => {
167
- return createInfiniteQuery({
168
- ...queryParameters,
169
- infiniteQueryOptions: {
170
- ...infiniteQueryOptions,
171
- ...options,
172
- },
173
- });
174
- },
175
- raw: (diOrContext, options) => {
176
- return convertToRawQuery(query, resolveDI(diOrContext), options);
177
- },
178
- prefetchAction: (options) => {
179
- return declareAction({
180
- name: 'infiniteQueryPrefetch',
181
- fn() {
182
- return this.deps.queryClient.prefetchInfiniteQuery(convertToRawQuery(query, this.deps.di, options));
183
- },
184
- deps: {
185
- di: DI_TOKEN,
186
- queryClient: QUERY_CLIENT_TOKEN,
187
- },
188
- conditions,
189
- });
190
- },
191
- fetchAction: (options) => {
192
- return declareAction({
193
- name: 'infiniteQueryFetch',
194
- fn() {
195
- return this.deps.queryClient.fetchInfiniteQuery(convertToRawQuery(query, this.deps.di, options));
196
- },
197
- deps: {
198
- di: DI_TOKEN,
199
- queryClient: QUERY_CLIENT_TOKEN,
200
- },
201
- conditions,
202
- });
203
- },
204
- };
205
- return query;
206
- };
207
-
208
- function useInfiniteQuery(query, options) {
209
- const di = useDiContainer();
210
- const resultQuery = useMemo(() => {
211
- if (isQuery(query)) {
212
- return query.raw(di, options);
213
- }
214
- return query;
215
- }, [query, di, options]);
216
- return useInfiniteQuery$1(resultQuery);
217
- }
218
-
219
- const MUTATION_PARAMETERS = '__mutations_parameters__';
220
- const isMutation = (arg) => {
221
- return MUTATION_PARAMETERS in arg;
222
- };
223
-
224
- const convertToRawMutation = (mutation, di, options) => {
225
- const { key = identity, fn, deps = {}, conditions, mutationOptions, } = mutation[MUTATION_PARAMETERS];
226
- const resolvedDeps = di.getOfDeps(deps);
227
- const ctx = { deps: resolvedDeps };
228
- const rawMutationKey = typeof key === 'function' ? key.call(ctx, options) : key;
229
- const mutationKey = normalizeKey(rawMutationKey);
230
- const actionWrapper = declareAction({
231
- name: 'mutationExecution',
232
- async fn(variables) {
233
- return fn.call(ctx, options, variables, ctx.deps);
234
- },
235
- deps,
236
- conditions,
237
- conditionsFailResult: 'reject',
238
- });
239
- return {
240
- ...mutationOptions,
241
- mutationKey,
242
- mutationFn: (variables) => {
243
- const context = di.get(CONTEXT_TOKEN);
244
- return context.executeAction(actionWrapper, variables);
245
- },
246
- };
247
- };
248
- const createMutation = (mutationParameters) => {
249
- const { mutationOptions } = mutationParameters;
250
- const mutation = {
251
- [MUTATION_PARAMETERS]: mutationParameters,
252
- fork: (options) => {
253
- return createMutation({
254
- ...mutationParameters,
255
- mutationOptions: {
256
- ...mutationOptions,
257
- ...options,
258
- },
259
- });
260
- },
261
- raw: (diOrContext, options) => {
262
- return convertToRawMutation(mutation, resolveDI(diOrContext), options);
263
- },
264
- };
265
- return mutation;
266
- };
267
-
268
- const useMutation = (mutation, options) => {
269
- const di = useDiContainer();
270
- const resultMutation = useMemo(() => {
271
- if (isMutation(mutation)) {
272
- return mutation.raw(di, options);
273
- }
274
- return mutation;
275
- }, [mutation, di, options]);
276
- return useMutation$1(resultMutation);
277
- };
278
-
279
- export { createInfiniteQuery, createMutation, createQuery, useInfiniteQuery, useMutation, useQueries, useQuery };
package/lib/index.js CHANGED
@@ -2,296 +2,24 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var identity = require('@tinkoff/utils/function/identity');
6
- var dippy = require('@tinkoff/dippy');
7
- var core = require('@tramvai/core');
8
- var moduleReactQuery = require('@tramvai/module-react-query');
9
- var tokensCommon = require('@tramvai/tokens-common');
10
- var isArray = require('@tinkoff/utils/is/array');
11
- var react$1 = require('react');
5
+ var create = require('./query/create.js');
6
+ var use = require('./query/use.js');
7
+ var create$1 = require('./infiniteQuery/create.js');
8
+ var use$1 = require('./infiniteQuery/use.js');
9
+ var create$2 = require('./mutation/create.js');
10
+ var use$2 = require('./mutation/use.js');
12
11
  var reactQuery = require('@tanstack/react-query');
13
- var reactHooks = require('@tinkoff/react-hooks');
14
- var react = require('@tramvai/react');
15
12
 
16
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
17
13
 
18
- var identity__default = /*#__PURE__*/_interopDefaultLegacy(identity);
19
- var isArray__default = /*#__PURE__*/_interopDefaultLegacy(isArray);
20
-
21
- const QUERY_PARAMETERS = '__query_parameters__';
22
- const isQuery = (arg) => {
23
- return QUERY_PARAMETERS in arg;
24
- };
25
-
26
- const normalizeKey = (key) => {
27
- if (isArray__default["default"](key)) {
28
- return key;
29
- }
30
- return [key];
31
- };
32
-
33
- const isActionContext = (diOrContext) => {
34
- return 'di' in diOrContext;
35
- };
36
- // @TODO: v3: leave only di container in next major
37
- const resolveDI = (diOrContext) => {
38
- if (isActionContext(diOrContext)) {
39
- return diOrContext.di;
40
- }
41
- return diOrContext;
42
- };
43
-
44
- const convertToRawQuery$1 = (query, di, options) => {
45
- const { key = identity__default["default"], fn, deps = {}, conditions, queryOptions } = query[QUERY_PARAMETERS];
46
- const resolvedDeps = di.getOfDeps(deps);
47
- const ctx = { deps: resolvedDeps };
48
- const rawQueryKey = typeof key === 'function' ? key.call(ctx, options) : key;
49
- const queryKey = normalizeKey(rawQueryKey);
50
- const actionWrapper = core.declareAction({
51
- name: 'queryExecution',
52
- async fn() {
53
- return fn.call(ctx, options, ctx.deps);
54
- },
55
- deps,
56
- conditions,
57
- conditionsFailResult: 'reject',
58
- });
59
- return {
60
- ...queryOptions,
61
- queryKey,
62
- tramvaiOptions: {
63
- conditions,
64
- },
65
- queryFn: () => {
66
- const context = di.get(tokensCommon.CONTEXT_TOKEN);
67
- return context.executeAction(actionWrapper);
68
- },
69
- };
70
- };
71
- const createQuery = (queryParameters) => {
72
- const { queryOptions, conditions } = queryParameters;
73
- const query = {
74
- [QUERY_PARAMETERS]: queryParameters,
75
- fork: (options) => {
76
- return createQuery({
77
- ...queryParameters,
78
- queryOptions: {
79
- ...queryOptions,
80
- ...options,
81
- },
82
- });
83
- },
84
- raw: (diOrContext, options) => {
85
- return convertToRawQuery$1(query, resolveDI(diOrContext), options);
86
- },
87
- prefetchAction: (options) => {
88
- return core.declareAction({
89
- name: 'queryPrefetch',
90
- fn() {
91
- return this.deps.queryClient.prefetchQuery(convertToRawQuery$1(query, this.deps.di, options));
92
- },
93
- deps: {
94
- di: dippy.DI_TOKEN,
95
- queryClient: moduleReactQuery.QUERY_CLIENT_TOKEN,
96
- },
97
- conditions,
98
- });
99
- },
100
- fetchAction: (options) => {
101
- return core.declareAction({
102
- name: 'queryFetch',
103
- fn() {
104
- return this.deps.queryClient.fetchQuery(convertToRawQuery$1(query, this.deps.di, options));
105
- },
106
- deps: {
107
- di: dippy.DI_TOKEN,
108
- queryClient: moduleReactQuery.QUERY_CLIENT_TOKEN,
109
- },
110
- conditions,
111
- });
112
- },
113
- };
114
- return query;
115
- };
116
-
117
- function useQuery(query, options) {
118
- const di = react.useDiContainer();
119
- const resultQuery = react$1.useMemo(() => {
120
- if (isQuery(query)) {
121
- return query.raw(di, options);
122
- }
123
- return query;
124
- }, [query, di, options]);
125
- return reactQuery.useQuery(resultQuery);
126
- }
127
- function useQueries(queries) {
128
- const di = react.useDiContainer();
129
- const memoQueries = reactHooks.useShallowEqual(queries);
130
- const resultQueries = react$1.useMemo(() => {
131
- return memoQueries.map((query) => {
132
- if (isQuery(query)) {
133
- return query.raw(di);
134
- }
135
- return query;
136
- });
137
- }, [memoQueries, di]);
138
- return reactQuery.useQueries({ queries: resultQueries });
139
- }
140
-
141
- const convertToRawQuery = (query, di, options) => {
142
- const { key = identity__default["default"], fn, getNextPageParam, getPreviousPageParam, deps = {}, conditions, infiniteQueryOptions, } = query[QUERY_PARAMETERS];
143
- const resolvedDeps = di.getOfDeps(deps);
144
- const ctx = { deps: resolvedDeps };
145
- const rawQueryKey = typeof key === 'function' ? key.call(ctx, options) : key;
146
- const queryKey = normalizeKey(rawQueryKey);
147
- const actionWrapper = core.declareAction({
148
- name: 'infiniteQueryExecution',
149
- async fn(pageParam) {
150
- return fn.call(ctx, options, pageParam, ctx.deps);
151
- },
152
- conditionsFailResult: 'reject',
153
- deps,
154
- conditions,
155
- });
156
- return {
157
- ...infiniteQueryOptions,
158
- getNextPageParam,
159
- getPreviousPageParam,
160
- queryKey,
161
- tramvaiOptions: {
162
- conditions,
163
- },
164
- queryFn: ({ pageParam }) => {
165
- const context = di.get(tokensCommon.CONTEXT_TOKEN);
166
- return context.executeAction(actionWrapper, pageParam);
167
- },
168
- };
169
- };
170
- const createInfiniteQuery = (queryParameters) => {
171
- const { infiniteQueryOptions, conditions } = queryParameters;
172
- const query = {
173
- [QUERY_PARAMETERS]: queryParameters,
174
- fork: (options) => {
175
- return createInfiniteQuery({
176
- ...queryParameters,
177
- infiniteQueryOptions: {
178
- ...infiniteQueryOptions,
179
- ...options,
180
- },
181
- });
182
- },
183
- raw: (diOrContext, options) => {
184
- return convertToRawQuery(query, resolveDI(diOrContext), options);
185
- },
186
- prefetchAction: (options) => {
187
- return core.declareAction({
188
- name: 'infiniteQueryPrefetch',
189
- fn() {
190
- return this.deps.queryClient.prefetchInfiniteQuery(convertToRawQuery(query, this.deps.di, options));
191
- },
192
- deps: {
193
- di: dippy.DI_TOKEN,
194
- queryClient: moduleReactQuery.QUERY_CLIENT_TOKEN,
195
- },
196
- conditions,
197
- });
198
- },
199
- fetchAction: (options) => {
200
- return core.declareAction({
201
- name: 'infiniteQueryFetch',
202
- fn() {
203
- return this.deps.queryClient.fetchInfiniteQuery(convertToRawQuery(query, this.deps.di, options));
204
- },
205
- deps: {
206
- di: dippy.DI_TOKEN,
207
- queryClient: moduleReactQuery.QUERY_CLIENT_TOKEN,
208
- },
209
- conditions,
210
- });
211
- },
212
- };
213
- return query;
214
- };
215
-
216
- function useInfiniteQuery(query, options) {
217
- const di = react.useDiContainer();
218
- const resultQuery = react$1.useMemo(() => {
219
- if (isQuery(query)) {
220
- return query.raw(di, options);
221
- }
222
- return query;
223
- }, [query, di, options]);
224
- return reactQuery.useInfiniteQuery(resultQuery);
225
- }
226
-
227
- const MUTATION_PARAMETERS = '__mutations_parameters__';
228
- const isMutation = (arg) => {
229
- return MUTATION_PARAMETERS in arg;
230
- };
231
-
232
- const convertToRawMutation = (mutation, di, options) => {
233
- const { key = identity__default["default"], fn, deps = {}, conditions, mutationOptions, } = mutation[MUTATION_PARAMETERS];
234
- const resolvedDeps = di.getOfDeps(deps);
235
- const ctx = { deps: resolvedDeps };
236
- const rawMutationKey = typeof key === 'function' ? key.call(ctx, options) : key;
237
- const mutationKey = normalizeKey(rawMutationKey);
238
- const actionWrapper = core.declareAction({
239
- name: 'mutationExecution',
240
- async fn(variables) {
241
- return fn.call(ctx, options, variables, ctx.deps);
242
- },
243
- deps,
244
- conditions,
245
- conditionsFailResult: 'reject',
246
- });
247
- return {
248
- ...mutationOptions,
249
- mutationKey,
250
- mutationFn: (variables) => {
251
- const context = di.get(tokensCommon.CONTEXT_TOKEN);
252
- return context.executeAction(actionWrapper, variables);
253
- },
254
- };
255
- };
256
- const createMutation = (mutationParameters) => {
257
- const { mutationOptions } = mutationParameters;
258
- const mutation = {
259
- [MUTATION_PARAMETERS]: mutationParameters,
260
- fork: (options) => {
261
- return createMutation({
262
- ...mutationParameters,
263
- mutationOptions: {
264
- ...mutationOptions,
265
- ...options,
266
- },
267
- });
268
- },
269
- raw: (diOrContext, options) => {
270
- return convertToRawMutation(mutation, resolveDI(diOrContext), options);
271
- },
272
- };
273
- return mutation;
274
- };
275
-
276
- const useMutation = (mutation, options) => {
277
- const di = react.useDiContainer();
278
- const resultMutation = react$1.useMemo(() => {
279
- if (isMutation(mutation)) {
280
- return mutation.raw(di, options);
281
- }
282
- return mutation;
283
- }, [mutation, di, options]);
284
- return reactQuery.useMutation(resultMutation);
285
- };
286
14
 
15
+ exports.createQuery = create.createQuery;
16
+ exports.useQueries = use.useQueries;
17
+ exports.useQuery = use.useQuery;
18
+ exports.createInfiniteQuery = create$1.createInfiniteQuery;
19
+ exports.useInfiniteQuery = use$1.useInfiniteQuery;
20
+ exports.createMutation = create$2.createMutation;
21
+ exports.useMutation = use$2.useMutation;
287
22
  Object.defineProperty(exports, 'useQueryClient', {
288
- enumerable: true,
289
- get: function () { return reactQuery.useQueryClient; }
23
+ enumerable: true,
24
+ get: function () { return reactQuery.useQueryClient; }
290
25
  });
291
- exports.createInfiniteQuery = createInfiniteQuery;
292
- exports.createMutation = createMutation;
293
- exports.createQuery = createQuery;
294
- exports.useInfiniteQuery = useInfiniteQuery;
295
- exports.useMutation = useMutation;
296
- exports.useQueries = useQueries;
297
- exports.useQuery = useQuery;
@@ -0,0 +1,85 @@
1
+ import identity from '@tinkoff/utils/function/identity';
2
+ import { declareAction } from '@tramvai/core';
3
+ import { QUERY_CLIENT_TOKEN } from '@tramvai/module-react-query';
4
+ import { CONTEXT_TOKEN } from '@tramvai/tokens-common';
5
+ import { DI_TOKEN } from '@tinkoff/dippy';
6
+ import { QUERY_PARAMETERS } from '../baseQuery/types.es.js';
7
+ import { normalizeKey } from '../shared/normalizeKey.es.js';
8
+ import { resolveDI } from '../shared/resolveDI.es.js';
9
+
10
+ const convertToRawQuery = (query, di, options) => {
11
+ const { key = identity, fn, getNextPageParam, getPreviousPageParam, deps = {}, conditions, infiniteQueryOptions, } = query[QUERY_PARAMETERS];
12
+ const resolvedDeps = di.getOfDeps(deps);
13
+ const ctx = { deps: resolvedDeps };
14
+ const rawQueryKey = typeof key === 'function' ? key.call(ctx, options) : key;
15
+ const queryKey = normalizeKey(rawQueryKey);
16
+ const actionWrapper = declareAction({
17
+ name: 'infiniteQueryExecution',
18
+ async fn(pageParam) {
19
+ return fn.call(ctx, options, pageParam, ctx.deps);
20
+ },
21
+ conditionsFailResult: 'reject',
22
+ deps,
23
+ conditions,
24
+ });
25
+ return {
26
+ ...infiniteQueryOptions,
27
+ getNextPageParam,
28
+ getPreviousPageParam,
29
+ queryKey,
30
+ tramvaiOptions: {
31
+ conditions,
32
+ },
33
+ queryFn: ({ pageParam }) => {
34
+ const context = di.get(CONTEXT_TOKEN);
35
+ return context.executeAction(actionWrapper, pageParam);
36
+ },
37
+ };
38
+ };
39
+ const createInfiniteQuery = (queryParameters) => {
40
+ const { infiniteQueryOptions, conditions } = queryParameters;
41
+ const query = {
42
+ [QUERY_PARAMETERS]: queryParameters,
43
+ fork: (options) => {
44
+ return createInfiniteQuery({
45
+ ...queryParameters,
46
+ infiniteQueryOptions: {
47
+ ...infiniteQueryOptions,
48
+ ...options,
49
+ },
50
+ });
51
+ },
52
+ raw: (diOrContext, options) => {
53
+ return convertToRawQuery(query, resolveDI(diOrContext), options);
54
+ },
55
+ prefetchAction: (options) => {
56
+ return declareAction({
57
+ name: 'infiniteQueryPrefetch',
58
+ fn() {
59
+ return this.deps.queryClient.prefetchInfiniteQuery(convertToRawQuery(query, this.deps.di, options));
60
+ },
61
+ deps: {
62
+ di: DI_TOKEN,
63
+ queryClient: QUERY_CLIENT_TOKEN,
64
+ },
65
+ conditions,
66
+ });
67
+ },
68
+ fetchAction: (options) => {
69
+ return declareAction({
70
+ name: 'infiniteQueryFetch',
71
+ fn() {
72
+ return this.deps.queryClient.fetchInfiniteQuery(convertToRawQuery(query, this.deps.di, options));
73
+ },
74
+ deps: {
75
+ di: DI_TOKEN,
76
+ queryClient: QUERY_CLIENT_TOKEN,
77
+ },
78
+ conditions,
79
+ });
80
+ },
81
+ };
82
+ return query;
83
+ };
84
+
85
+ export { createInfiniteQuery };