@astral/mobx-query 1.10.1 → 1.10.3
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/AuxiliaryQuery/AuxiliaryQuery.js +1 -0
- package/DataStorage/DataStorage.d.ts +1 -0
- package/DataStorage/DataStorage.js +3 -0
- package/InfiniteQuery/InfiniteQuery.js +3 -0
- package/MobxQuery/MobxQuery.d.ts +2 -2
- package/MobxQuery/MobxQuery.js +2 -2
- package/Query/Query.js +3 -0
- package/README.md +41 -41
- package/Sets/MutationSet/MutationSet.d.ts +3 -3
- package/Sets/MutationSet/MutationSet.js +3 -3
- package/node/AuxiliaryQuery/AuxiliaryQuery.js +1 -0
- package/node/DataStorage/DataStorage.d.ts +1 -0
- package/node/DataStorage/DataStorage.js +3 -0
- package/node/InfiniteQuery/InfiniteQuery.js +3 -0
- package/node/MobxQuery/MobxQuery.d.ts +2 -2
- package/node/MobxQuery/MobxQuery.js +2 -2
- package/node/Query/Query.js +3 -0
- package/node/Sets/MutationSet/MutationSet.d.ts +3 -3
- package/node/Sets/MutationSet/MutationSet.js +3 -3
- package/package.json +1 -1
package/MobxQuery/MobxQuery.d.ts
CHANGED
|
@@ -163,8 +163,8 @@ export declare class MobxQuery<TDefaultError = void> {
|
|
|
163
163
|
* Создает набор мутаций для единого интерфейса с query sets
|
|
164
164
|
* @param executor - Функция-исполнитель мутации. Она должна возвращать промис с результатом выполнения мутации.
|
|
165
165
|
* @example
|
|
166
|
-
* const editDocMutationSet = mobxQuery.createMutationSet((params:
|
|
167
|
-
* return
|
|
166
|
+
* const editDocMutationSet = mobxQuery.createMutationSet((params: DocsDTO.EditDocInput) => {
|
|
167
|
+
* return docsEndpoints.editDoc(params);
|
|
168
168
|
* });
|
|
169
169
|
*
|
|
170
170
|
* const editDocMutation = editDocMutationSet.create();
|
package/MobxQuery/MobxQuery.js
CHANGED
|
@@ -205,8 +205,8 @@ export class MobxQuery {
|
|
|
205
205
|
* Создает набор мутаций для единого интерфейса с query sets
|
|
206
206
|
* @param executor - Функция-исполнитель мутации. Она должна возвращать промис с результатом выполнения мутации.
|
|
207
207
|
* @example
|
|
208
|
-
* const editDocMutationSet = mobxQuery.createMutationSet((params:
|
|
209
|
-
* return
|
|
208
|
+
* const editDocMutationSet = mobxQuery.createMutationSet((params: DocsDTO.EditDocInput) => {
|
|
209
|
+
* return docsEndpoints.editDoc(params);
|
|
210
210
|
* });
|
|
211
211
|
*
|
|
212
212
|
* const editDocMutation = editDocMutationSet.create();
|
package/Query/Query.js
CHANGED
package/README.md
CHANGED
|
@@ -86,12 +86,12 @@ export const cacheService = createCacheService();
|
|
|
86
86
|
const docsFetcher = {
|
|
87
87
|
queries: {
|
|
88
88
|
doc: cacheService.createQuerySet((id: string) => ({
|
|
89
|
-
execute: () =>
|
|
89
|
+
execute: () => docsEndpoints.getDoc(id).then(({ data }) => data),
|
|
90
90
|
})),
|
|
91
91
|
},
|
|
92
92
|
infiniteQueries: {
|
|
93
93
|
docList: cacheService.createInfiniteQuerySet(
|
|
94
|
-
(filters: Omit<
|
|
94
|
+
(filters: Omit<DocsDTO.DocListFilters, 'offset' | 'count'>) => ({
|
|
95
95
|
execute: ({ offset, count }) =>
|
|
96
96
|
docsEndpoint
|
|
97
97
|
.getDocList({ offset, count, ...filters })
|
|
@@ -101,7 +101,7 @@ const docsFetcher = {
|
|
|
101
101
|
},
|
|
102
102
|
mutations: {
|
|
103
103
|
editDoc: cacheService.createMutationSet(
|
|
104
|
-
(params:
|
|
104
|
+
(params: DocsDTO.EditDocInput) => docsEndpoints.editDoc(params),
|
|
105
105
|
),
|
|
106
106
|
},
|
|
107
107
|
};
|
|
@@ -186,7 +186,7 @@ class DocManagerStore {
|
|
|
186
186
|
const docsFetcher = {
|
|
187
187
|
queries: {
|
|
188
188
|
doc: mobxQuery.createQuerySet((id: string) => ({
|
|
189
|
-
execute: () =>
|
|
189
|
+
execute: () => docsEndpoints.getDoc(id).then(({ data }) => data),
|
|
190
190
|
})),
|
|
191
191
|
},
|
|
192
192
|
};
|
|
@@ -200,7 +200,7 @@ const docsFetcher = {
|
|
|
200
200
|
const docsFetcher = {
|
|
201
201
|
queries: {
|
|
202
202
|
doc: mobxQuery.createQuerySet((id: string) => ({
|
|
203
|
-
execute: () =>
|
|
203
|
+
execute: () => docsEndpoints.getDoc(id).then(({ data }) => data),
|
|
204
204
|
})),
|
|
205
205
|
},
|
|
206
206
|
};
|
|
@@ -281,7 +281,7 @@ docQuery.isLoading; // true
|
|
|
281
281
|
const docsFetcher = {
|
|
282
282
|
infiniteQueries: {
|
|
283
283
|
docList: mobxQuery.createInfiniteQuerySet(
|
|
284
|
-
(filters: Omit<
|
|
284
|
+
(filters: Omit<DocsDTO.DocListFilters, 'offset' | 'count'>) => ({
|
|
285
285
|
execute: ({ offset, count }) =>
|
|
286
286
|
docsEndpoint
|
|
287
287
|
.getDocList({ offset, count, ...filters })
|
|
@@ -301,7 +301,7 @@ const docsFetcher = {
|
|
|
301
301
|
infiniteQueries: {
|
|
302
302
|
docList: mobxQuery.createInfiniteQuerySet(
|
|
303
303
|
// Omit необходим для того, чтобы не передавать offset и count при вызове запроса из логики. Offset и count будут сформированы и переданы автоматически
|
|
304
|
-
(filters: Omit<
|
|
304
|
+
(filters: Omit<DocsDTO.DocListFilters, 'offset' | 'count'>) => ({
|
|
305
305
|
execute: ({ offset, count }) =>
|
|
306
306
|
docsEndpoint
|
|
307
307
|
.getDocList({ offset, count, ...filters })
|
|
@@ -312,7 +312,7 @@ const docsFetcher = {
|
|
|
312
312
|
},
|
|
313
313
|
};
|
|
314
314
|
|
|
315
|
-
// первым параметром create является - filters: Omit<
|
|
315
|
+
// первым параметром create является - filters: Omit<DocsDTO.DocListFilters, 'offset' | 'count'>
|
|
316
316
|
const docListQuery = docsFetcher.infiniteQueries.docList.create({ search: 'test' });
|
|
317
317
|
```
|
|
318
318
|
|
|
@@ -382,13 +382,13 @@ const docListQuery = docsFetcher.infiniteQueries.docList.createWithConfig(
|
|
|
382
382
|
```ts
|
|
383
383
|
const docsFetcher = {
|
|
384
384
|
mutations: {
|
|
385
|
-
editDoc: mobxQuery.createMutationSet((params:
|
|
385
|
+
editDoc: mobxQuery.createMutationSet((params: DocsDTO.EditDocInput) => docsEndpoints.editDoc(params)),
|
|
386
386
|
},
|
|
387
387
|
};
|
|
388
388
|
|
|
389
389
|
const editDocMutation = docsFetcher.mutations.editDoc.create();
|
|
390
390
|
|
|
391
|
-
// params являются параметрами, указанными при определении mutation -
|
|
391
|
+
// params являются параметрами, указанными при определении mutation - DocsDTO.EditDocInput
|
|
392
392
|
await editDocMutation.async({ params: { id: 'docID', name: 'test' } });
|
|
393
393
|
```
|
|
394
394
|
|
|
@@ -498,7 +498,7 @@ await docQueryWithCache.async(); // запрос не будет выполне
|
|
|
498
498
|
const docFetcher = {
|
|
499
499
|
queries: {
|
|
500
500
|
doc: mobxQuery.createQuerySet((id: string, filters: { search: string }) => ({
|
|
501
|
-
execute: () =>
|
|
501
|
+
execute: () => docsEndpoints.getDoc(id, filters),
|
|
502
502
|
})),
|
|
503
503
|
},
|
|
504
504
|
};
|
|
@@ -552,7 +552,7 @@ docsFetcher.queries.doc.invalidate(); // данные docQuery1 и docQuery2 п
|
|
|
552
552
|
const docsFetcher = {
|
|
553
553
|
queries: {
|
|
554
554
|
doc: mobxQuery.createQuerySet((id: string) => ({
|
|
555
|
-
execute: () =>
|
|
555
|
+
execute: () => docsEndpoints.getDoc(id).then(({ data }) => data),
|
|
556
556
|
})),
|
|
557
557
|
},
|
|
558
558
|
};
|
|
@@ -566,7 +566,7 @@ docsFetcher.queries.doc.invalidate('1'); // документ с id = 1 буде
|
|
|
566
566
|
const docsFetcher = {
|
|
567
567
|
queries: {
|
|
568
568
|
doc: mobxQuery.createQuerySet((id: string, search: string, filters: Filters) => ({
|
|
569
|
-
execute: () =>
|
|
569
|
+
execute: () => docsEndpoints.getDoc(id, search, filters),
|
|
570
570
|
})),
|
|
571
571
|
},
|
|
572
572
|
};
|
|
@@ -580,7 +580,7 @@ docsFetcher.queries.doc.invalidate('1', 'test', { sort: 'asc' });
|
|
|
580
580
|
const docsFetcher = {
|
|
581
581
|
queries: {
|
|
582
582
|
doc: mobxQuery.createQuerySet((id: string, filters: { sort: string; search: string }) => ({
|
|
583
|
-
execute: () =>
|
|
583
|
+
execute: () => docsEndpoints.getDoc(id, filters),
|
|
584
584
|
})),
|
|
585
585
|
},
|
|
586
586
|
};
|
|
@@ -603,7 +603,7 @@ const docsFetcher = {
|
|
|
603
603
|
doc: mobxQuery.createQuerySet(
|
|
604
604
|
(id: string, search: string) => ({
|
|
605
605
|
keys: [id],
|
|
606
|
-
execute: () =>
|
|
606
|
+
execute: () => docsEndpoints.getDoc(id, search),
|
|
607
607
|
}),
|
|
608
608
|
{ name: 'doc' }
|
|
609
609
|
),
|
|
@@ -655,7 +655,7 @@ docQuery.forceUpdate({ name: 'test' });
|
|
|
655
655
|
type Fetcher = {
|
|
656
656
|
queries: Record<string, QuerySet<any[], any>>;
|
|
657
657
|
infiniteQueries: Record<InfiniteQuerySet<any[], any>>;
|
|
658
|
-
mutations: Record<MutationSet<any
|
|
658
|
+
mutations: Record<MutationSet<any, any>>;
|
|
659
659
|
};
|
|
660
660
|
|
|
661
661
|
const mockFetcher = <TFetcher extends Fetcher>(config: DeepPartial<TFetcher>) => config as TFetcher;
|
|
@@ -677,7 +677,7 @@ const createMobxQuery = () => new MobxQuery({
|
|
|
677
677
|
```ts
|
|
678
678
|
export const booksFetcher = {
|
|
679
679
|
queries: {
|
|
680
|
-
bookList: mobxQuery.createQuerySet((params:
|
|
680
|
+
bookList: mobxQuery.createQuerySet((params: BooksDTO.BookListInput) => ({
|
|
681
681
|
execute: () => booksEndpoint.getBookList(params),
|
|
682
682
|
})),
|
|
683
683
|
},
|
|
@@ -765,7 +765,7 @@ describe('BooksListStore', () => {
|
|
|
765
765
|
const createDocQuery = (id: string) =>
|
|
766
766
|
// первый параметр - ключи, по которому в кэше будет храниться ответ запроса
|
|
767
767
|
cacheService.createQuery(['doc', id],
|
|
768
|
-
(params: { id: string }) =>
|
|
768
|
+
(params: { id: string }) => docsEndpoints.getDoc(params.id)
|
|
769
769
|
);
|
|
770
770
|
```
|
|
771
771
|
|
|
@@ -775,7 +775,7 @@ const createDocQuery = (id: string) =>
|
|
|
775
775
|
const createDocQuery = (id: string) =>
|
|
776
776
|
// первый параметр - ключи, по которому в кэше будет храниться ответ запроса
|
|
777
777
|
cacheService.createQuery(['doc', id],
|
|
778
|
-
(params: { id: string }) =>
|
|
778
|
+
(params: { id: string }) => docsEndpoints.getDoc(params.id)
|
|
779
779
|
);
|
|
780
780
|
|
|
781
781
|
const docQuery = createDocQuery('docID');
|
|
@@ -866,7 +866,7 @@ export type Query<TResult = unknown, TError = unknown, TIsBackground = boolean>
|
|
|
866
866
|
const createDocQuery = (id: string) =>
|
|
867
867
|
// первый параметр - ключи, по которому в кэше будет храниться ответ запроса
|
|
868
868
|
cacheService.createQuery(['doc', id],
|
|
869
|
-
(params: { id: string }) =>
|
|
869
|
+
(params: { id: string }) => docsEndpoints.getDoc(params.id)
|
|
870
870
|
);
|
|
871
871
|
|
|
872
872
|
const docQuery = createDocQuery('docID');
|
|
@@ -892,7 +892,7 @@ docQuery.isLoading;
|
|
|
892
892
|
const createDocQuery = (id: string) =>
|
|
893
893
|
// первый параметр - ключи, по которому в кэше будет храниться ответ запроса
|
|
894
894
|
cacheService.createQuery(['doc', id],
|
|
895
|
-
(params: { id: string }) =>
|
|
895
|
+
(params: { id: string }) => docsEndpoints.getDoc(params.id)
|
|
896
896
|
);
|
|
897
897
|
|
|
898
898
|
const docQuery = createDocQuery('docID');
|
|
@@ -913,7 +913,7 @@ const cacheService = new MobxQuery({ enableAutoFetch: true });
|
|
|
913
913
|
const createDocQuery = (id: string) =>
|
|
914
914
|
// первый параметр - ключи, по которому в кэше будет храниться ответ запроса
|
|
915
915
|
cacheService.createQuery(['doc', id],
|
|
916
|
-
(params: { id: string }) =>
|
|
916
|
+
(params: { id: string }) => docsEndpoints.getDoc(params.id)
|
|
917
917
|
);
|
|
918
918
|
|
|
919
919
|
docQuery.data; // триггер запроса данных
|
|
@@ -925,7 +925,7 @@ docQuery.isLoading; // true
|
|
|
925
925
|
```ts
|
|
926
926
|
const createDocQuery = (id: string) =>
|
|
927
927
|
cacheService.createQuery(['doc', id],
|
|
928
|
-
(params: { id: string }) =>
|
|
928
|
+
(params: { id: string }) => docsEndpoints.getDoc(params.id),
|
|
929
929
|
{ enableAutoFetch: true }
|
|
930
930
|
);
|
|
931
931
|
|
|
@@ -943,21 +943,21 @@ docQuery.isLoading; // true
|
|
|
943
943
|
В примере ниже будет создан docList InfiniteQuery. После успешного выполнения запроса данные будут закэшированы.
|
|
944
944
|
|
|
945
945
|
```ts
|
|
946
|
-
const createDocListInfiniteQuery = (filters: Omit<
|
|
946
|
+
const createDocListInfiniteQuery = (filters: Omit<DocsDTO.DocListFilters, 'offset' | 'count'>) =>
|
|
947
947
|
cacheService.createInfiniteQuery(['docList', filters],
|
|
948
|
-
(params: { offset: number; count: number }) =>
|
|
948
|
+
(params: { offset: number; count: number }) => docsEndpoints.getDocList({ offset: params.offset, count: params.count, ...filters })
|
|
949
949
|
);
|
|
950
950
|
```
|
|
951
951
|
|
|
952
952
|
#### Использование InfiniteQuery
|
|
953
953
|
|
|
954
954
|
```ts
|
|
955
|
-
const createDocListInfiniteQuery = (filters: Omit<
|
|
955
|
+
const createDocListInfiniteQuery = (filters: Omit<DocsDTO.DocListFilters, 'offset' | 'count'>) =>
|
|
956
956
|
cacheService.createInfiniteQuery(['docList', filters],
|
|
957
|
-
(params: { offset: number; count: number }) =>
|
|
957
|
+
(params: { offset: number; count: number }) => docsEndpoints.getDocList({ offset: params.offset, count: params.count, ...filters })
|
|
958
958
|
);
|
|
959
959
|
|
|
960
|
-
// первым параметром create является - filters: Omit<
|
|
960
|
+
// первым параметром create является - filters: Omit<DocsDTO.DocListFilters, 'offset' | 'count'>
|
|
961
961
|
const docListQuery = createDocListInfiniteQuery({ search: 'test' });
|
|
962
962
|
```
|
|
963
963
|
|
|
@@ -966,9 +966,9 @@ const docListQuery = createDocListInfiniteQuery({ search: 'test' });
|
|
|
966
966
|
```ts
|
|
967
967
|
import { when } from 'mobx';
|
|
968
968
|
|
|
969
|
-
const createDocListInfiniteQuery = (filters: Omit<
|
|
969
|
+
const createDocListInfiniteQuery = (filters: Omit<DocsDTO.DocListFilters, 'offset' | 'count'>) =>
|
|
970
970
|
cacheService.createInfiniteQuery(['docList', filters],
|
|
971
|
-
(params: { offset: number; count: number }) =>
|
|
971
|
+
(params: { offset: number; count: number }) => docsEndpoints.getDocList({ offset: params.offset, count: params.count, ...filters })
|
|
972
972
|
);
|
|
973
973
|
|
|
974
974
|
const docListQuery = createDocListInfiniteQuery({ search: 'test' });
|
|
@@ -991,9 +991,9 @@ docListQuery.data.length; // 60 записей
|
|
|
991
991
|
```ts
|
|
992
992
|
import { when } from 'mobx';
|
|
993
993
|
|
|
994
|
-
const createDocListInfiniteQuery = (filters: Omit<
|
|
994
|
+
const createDocListInfiniteQuery = (filters: Omit<DocsDTO.DocListFilters, 'offset' | 'count'>) =>
|
|
995
995
|
cacheService.createInfiniteQuery(['docList', filters],
|
|
996
|
-
(params: { offset: number; count: number }) =>
|
|
996
|
+
(params: { offset: number; count: number }) => docsEndpoints.getDocList({ offset: params.offset, count: params.count, ...filters })
|
|
997
997
|
);
|
|
998
998
|
|
|
999
999
|
const docListQuery = createDocListInfiniteQuery({ search: 'test' });
|
|
@@ -1018,9 +1018,9 @@ docListQuery.isEndReached; // true
|
|
|
1018
1018
|
|
|
1019
1019
|
Для изменения конфигурации InfiniteQuery необходимо использовать третий параметр `config`:
|
|
1020
1020
|
```ts
|
|
1021
|
-
const createDocListInfiniteQuery = (filters: Omit<
|
|
1021
|
+
const createDocListInfiniteQuery = (filters: Omit<DocsDTO.DocListFilters, 'offset' | 'count'>) =>
|
|
1022
1022
|
cacheService.createInfiniteQuery(['docList', filters],
|
|
1023
|
-
(params: { offset: number; count: number }) =>
|
|
1023
|
+
(params: { offset: number; count: number }) => docsEndpoints.getDocList({ offset: params.offset, count: params.count, ...filters }),
|
|
1024
1024
|
{ incrementCount: 10 }
|
|
1025
1025
|
);
|
|
1026
1026
|
```
|
|
@@ -1061,12 +1061,12 @@ export type InfiniteQueryConfig = {
|
|
|
1061
1061
|
|
|
1062
1062
|
В примере ниже будет создан `editDoc` mutation, который отправляет данные на сервер для редактирования документа:
|
|
1063
1063
|
```ts
|
|
1064
|
-
const createEditDocMutation = (params:
|
|
1065
|
-
cacheService.createMutation((params:
|
|
1064
|
+
const createEditDocMutation = (params: DocsDTO.EditDocInput) =>
|
|
1065
|
+
cacheService.createMutation((params: DocsDTO.EditDocInput) => docsEndpoints.editDoc(params));
|
|
1066
1066
|
|
|
1067
1067
|
const editDocMutation = createEditDocMutation();
|
|
1068
1068
|
|
|
1069
|
-
// params являются параметрами, указанными при определении mutation -
|
|
1069
|
+
// params являются параметрами, указанными при определении mutation - DocsDTO.EditDocInput
|
|
1070
1070
|
await editDocMutation.async({ params: { id: 'docID', name: 'test' } });
|
|
1071
1071
|
```
|
|
1072
1072
|
|
|
@@ -1142,8 +1142,8 @@ type Mutation<TResult, TError = unknown, TExecutorParams = void> = {
|
|
|
1142
1142
|
|
|
1143
1143
|
Метод `sync` позволяет синхронно запустить запрос:
|
|
1144
1144
|
```ts
|
|
1145
|
-
const createEditDocMutation = (params:
|
|
1146
|
-
cacheService.createMutation((params:
|
|
1145
|
+
const createEditDocMutation = (params: DocsDTO.EditDocInput) =>
|
|
1146
|
+
cacheService.createMutation((params: DocsDTO.EditDocInput) => docsEndpoints.editDoc(params));
|
|
1147
1147
|
|
|
1148
1148
|
const editDocMutation = createEditDocMutation();
|
|
1149
1149
|
|
|
@@ -1166,8 +1166,8 @@ editDocMutation.isLoading;
|
|
|
1166
1166
|
|
|
1167
1167
|
Метод `async` позволяет асинхронно запустить запрос:
|
|
1168
1168
|
```ts
|
|
1169
|
-
const createEditDocMutation = (params:
|
|
1170
|
-
cacheService.createMutation((params:
|
|
1169
|
+
const createEditDocMutation = (params: DocsDTO.EditDocInput) =>
|
|
1170
|
+
cacheService.createMutation((params: DocsDTO.EditDocInput) => docsEndpoints.editDoc(params));
|
|
1171
1171
|
|
|
1172
1172
|
const editDocMutation = createEditDocMutation();
|
|
1173
1173
|
|
|
@@ -5,13 +5,13 @@ import { type Mutation, type MutationExecutor } from '../../Mutation';
|
|
|
5
5
|
* @example
|
|
6
6
|
* const docFetcher = {
|
|
7
7
|
* mutations: {
|
|
8
|
-
* editDoc: mobxQuery.createMutationSet((params:
|
|
9
|
-
* return
|
|
8
|
+
* editDoc: mobxQuery.createMutationSet((params: DocsDTO.EditDocInput) => {
|
|
9
|
+
* return docsEndpoints.editDoc(params);
|
|
10
10
|
* }),
|
|
11
11
|
* },
|
|
12
12
|
* queries: {
|
|
13
13
|
* doc: mobxQuery.createQuerySet((id: string) => ({
|
|
14
|
-
* execute: () =>
|
|
14
|
+
* execute: () => docsEndpoints.getDoc(id).then(({ data }) => data),
|
|
15
15
|
* })),
|
|
16
16
|
* },
|
|
17
17
|
* }
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
* @example
|
|
4
4
|
* const docFetcher = {
|
|
5
5
|
* mutations: {
|
|
6
|
-
* editDoc: mobxQuery.createMutationSet((params:
|
|
7
|
-
* return
|
|
6
|
+
* editDoc: mobxQuery.createMutationSet((params: DocsDTO.EditDocInput) => {
|
|
7
|
+
* return docsEndpoints.editDoc(params);
|
|
8
8
|
* }),
|
|
9
9
|
* },
|
|
10
10
|
* queries: {
|
|
11
11
|
* doc: mobxQuery.createQuerySet((id: string) => ({
|
|
12
|
-
* execute: () =>
|
|
12
|
+
* execute: () => docsEndpoints.getDoc(id).then(({ data }) => data),
|
|
13
13
|
* })),
|
|
14
14
|
* },
|
|
15
15
|
* }
|
|
@@ -163,8 +163,8 @@ export declare class MobxQuery<TDefaultError = void> {
|
|
|
163
163
|
* Создает набор мутаций для единого интерфейса с query sets
|
|
164
164
|
* @param executor - Функция-исполнитель мутации. Она должна возвращать промис с результатом выполнения мутации.
|
|
165
165
|
* @example
|
|
166
|
-
* const editDocMutationSet = mobxQuery.createMutationSet((params:
|
|
167
|
-
* return
|
|
166
|
+
* const editDocMutationSet = mobxQuery.createMutationSet((params: DocsDTO.EditDocInput) => {
|
|
167
|
+
* return docsEndpoints.editDoc(params);
|
|
168
168
|
* });
|
|
169
169
|
*
|
|
170
170
|
* const editDocMutation = editDocMutationSet.create();
|
|
@@ -208,8 +208,8 @@ class MobxQuery {
|
|
|
208
208
|
* Создает набор мутаций для единого интерфейса с query sets
|
|
209
209
|
* @param executor - Функция-исполнитель мутации. Она должна возвращать промис с результатом выполнения мутации.
|
|
210
210
|
* @example
|
|
211
|
-
* const editDocMutationSet = mobxQuery.createMutationSet((params:
|
|
212
|
-
* return
|
|
211
|
+
* const editDocMutationSet = mobxQuery.createMutationSet((params: DocsDTO.EditDocInput) => {
|
|
212
|
+
* return docsEndpoints.editDoc(params);
|
|
213
213
|
* });
|
|
214
214
|
*
|
|
215
215
|
* const editDocMutation = editDocMutationSet.create();
|
package/node/Query/Query.js
CHANGED
|
@@ -5,13 +5,13 @@ import { type Mutation, type MutationExecutor } from '../../Mutation';
|
|
|
5
5
|
* @example
|
|
6
6
|
* const docFetcher = {
|
|
7
7
|
* mutations: {
|
|
8
|
-
* editDoc: mobxQuery.createMutationSet((params:
|
|
9
|
-
* return
|
|
8
|
+
* editDoc: mobxQuery.createMutationSet((params: DocsDTO.EditDocInput) => {
|
|
9
|
+
* return docsEndpoints.editDoc(params);
|
|
10
10
|
* }),
|
|
11
11
|
* },
|
|
12
12
|
* queries: {
|
|
13
13
|
* doc: mobxQuery.createQuerySet((id: string) => ({
|
|
14
|
-
* execute: () =>
|
|
14
|
+
* execute: () => docsEndpoints.getDoc(id).then(({ data }) => data),
|
|
15
15
|
* })),
|
|
16
16
|
* },
|
|
17
17
|
* }
|
|
@@ -6,13 +6,13 @@ exports.MutationSet = void 0;
|
|
|
6
6
|
* @example
|
|
7
7
|
* const docFetcher = {
|
|
8
8
|
* mutations: {
|
|
9
|
-
* editDoc: mobxQuery.createMutationSet((params:
|
|
10
|
-
* return
|
|
9
|
+
* editDoc: mobxQuery.createMutationSet((params: DocsDTO.EditDocInput) => {
|
|
10
|
+
* return docsEndpoints.editDoc(params);
|
|
11
11
|
* }),
|
|
12
12
|
* },
|
|
13
13
|
* queries: {
|
|
14
14
|
* doc: mobxQuery.createQuerySet((id: string) => ({
|
|
15
|
-
* execute: () =>
|
|
15
|
+
* execute: () => docsEndpoints.getDoc(id).then(({ data }) => data),
|
|
16
16
|
* })),
|
|
17
17
|
* },
|
|
18
18
|
* }
|