@dhis2/app-service-data 3.7.0 → 3.9.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.
- package/build/cjs/__tests__/integration.test.js +16 -10
- package/build/cjs/__tests__/mutations.test.js +8 -5
- package/build/cjs/engine/DataEngine.js +14 -12
- package/build/cjs/engine/helpers/resolveDynamicQuery.js +14 -11
- package/build/cjs/engine/helpers/resolveDynamicQuery.test.js +23 -14
- package/build/cjs/engine/helpers/validate.js +6 -4
- package/build/cjs/engine/helpers/validate.test.js +74 -15
- package/build/cjs/engine/types/FetchError.js +6 -5
- package/build/cjs/engine/types/InvalidQueryError.js +1 -1
- package/build/cjs/index.js +10 -10
- package/build/cjs/links/CustomDataLink.js +8 -6
- package/build/cjs/links/CustomDataLink.test.js +2 -2
- package/build/cjs/links/RestAPILink/fetchData.js +3 -2
- package/build/cjs/links/RestAPILink/fetchData.test.js +1 -1
- package/build/cjs/links/RestAPILink/metadataResources.js +1 -1
- package/build/cjs/links/RestAPILink/path.js +5 -1
- package/build/cjs/links/RestAPILink/queryToRequestOptions/multipartFormDataMatchers.js +29 -16
- package/build/cjs/links/RestAPILink/queryToRequestOptions/requestContentType.js +9 -6
- package/build/cjs/links/RestAPILink/queryToRequestOptions/requestContentType.test.js +2 -2
- package/build/cjs/links/RestAPILink/queryToRequestOptions/textPlainMatchers.js +51 -33
- package/build/cjs/links/RestAPILink/queryToRequestOptions/xWwwFormUrlencodedMatchers.js +6 -3
- package/build/cjs/links/RestAPILink/queryToRequestOptions.js +1 -1
- package/build/cjs/links/RestAPILink/queryToRequestOptions.test.js +56 -6
- package/build/cjs/links/RestAPILink/queryToResourcePath.js +14 -6
- package/build/cjs/links/RestAPILink/queryToResourcePath.test.js +16 -16
- package/build/cjs/links/RestAPILink/validateQuery.test.js +12 -12
- package/build/cjs/links/RestAPILink.js +4 -3
- package/build/cjs/react/components/CustomDataProvider.js +7 -6
- package/build/cjs/react/components/DataMutation.js +8 -7
- package/build/cjs/react/components/DataProvider.js +1 -1
- package/build/cjs/react/components/DataQuery.js +9 -8
- package/build/cjs/react/context/defaultContext.test.js +10 -2
- package/build/cjs/react/hooks/stableVariablesHash.js +1 -2
- package/build/cjs/react/hooks/stableVariablesHash.test.js +6 -6
- package/build/cjs/react/hooks/useDataMutation.js +7 -6
- package/build/cjs/react/hooks/useDataMutation.test.js +70 -43
- package/build/cjs/react/hooks/useDataQuery.js +13 -9
- package/build/cjs/react/hooks/useDataQuery.test.js +259 -162
- package/build/cjs/react/hooks/useQueryExecutor.js +11 -9
- package/build/cjs/react/hooks/useQueryExecutor.test.js +16 -12
- package/build/cjs/react/hooks/useStaticInput.js +7 -6
- package/build/cjs/react/hooks/useStaticInput.test.js +44 -25
- package/build/cjs/react/index.js +6 -6
- package/build/es/__tests__/integration.test.js +16 -10
- package/build/es/__tests__/mutations.test.js +8 -5
- package/build/es/engine/DataEngine.js +14 -12
- package/build/es/engine/helpers/resolveDynamicQuery.js +14 -11
- package/build/es/engine/helpers/resolveDynamicQuery.test.js +23 -14
- package/build/es/engine/helpers/validate.js +6 -4
- package/build/es/engine/helpers/validate.test.js +74 -15
- package/build/es/engine/types/FetchError.js +6 -5
- package/build/es/engine/types/InvalidQueryError.js +1 -1
- package/build/es/links/CustomDataLink.js +8 -6
- package/build/es/links/CustomDataLink.test.js +2 -2
- package/build/es/links/RestAPILink/fetchData.js +3 -2
- package/build/es/links/RestAPILink/fetchData.test.js +1 -1
- package/build/es/links/RestAPILink/path.js +5 -1
- package/build/es/links/RestAPILink/queryToRequestOptions/multipartFormDataMatchers.js +28 -15
- package/build/es/links/RestAPILink/queryToRequestOptions/requestContentType.js +8 -5
- package/build/es/links/RestAPILink/queryToRequestOptions/requestContentType.test.js +2 -2
- package/build/es/links/RestAPILink/queryToRequestOptions/textPlainMatchers.js +50 -32
- package/build/es/links/RestAPILink/queryToRequestOptions/xWwwFormUrlencodedMatchers.js +6 -3
- package/build/es/links/RestAPILink/queryToRequestOptions.js +1 -1
- package/build/es/links/RestAPILink/queryToRequestOptions.test.js +56 -6
- package/build/es/links/RestAPILink/queryToResourcePath.js +14 -6
- package/build/es/links/RestAPILink/queryToResourcePath.test.js +16 -16
- package/build/es/links/RestAPILink/validateQuery.test.js +12 -12
- package/build/es/links/RestAPILink.js +4 -3
- package/build/es/react/components/CustomDataProvider.js +7 -6
- package/build/es/react/components/DataMutation.js +8 -7
- package/build/es/react/components/DataQuery.js +9 -8
- package/build/es/react/context/defaultContext.test.js +10 -2
- package/build/es/react/hooks/stableVariablesHash.js +1 -2
- package/build/es/react/hooks/stableVariablesHash.test.js +6 -6
- package/build/es/react/hooks/useDataMutation.js +7 -6
- package/build/es/react/hooks/useDataMutation.test.js +70 -43
- package/build/es/react/hooks/useDataQuery.js +13 -9
- package/build/es/react/hooks/useDataQuery.test.js +259 -162
- package/build/es/react/hooks/useQueryExecutor.js +11 -9
- package/build/es/react/hooks/useQueryExecutor.test.js +16 -12
- package/build/es/react/hooks/useStaticInput.js +7 -6
- package/build/es/react/hooks/useStaticInput.test.js +44 -25
- package/package.json +2 -2
|
@@ -14,11 +14,14 @@ describe('useDataQuery', () => {
|
|
|
14
14
|
answer: 42
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
const wrapper = ({
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
const wrapper = (_ref) => {
|
|
18
|
+
let {
|
|
19
|
+
children
|
|
20
|
+
} = _ref;
|
|
21
|
+
return /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
22
|
+
data: data
|
|
23
|
+
}, children);
|
|
24
|
+
};
|
|
22
25
|
|
|
23
26
|
const onComplete = jest.fn();
|
|
24
27
|
const onError = jest.fn();
|
|
@@ -62,11 +65,14 @@ describe('useDataQuery', () => {
|
|
|
62
65
|
}
|
|
63
66
|
};
|
|
64
67
|
|
|
65
|
-
const wrapper = ({
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
const wrapper = (_ref2) => {
|
|
69
|
+
let {
|
|
70
|
+
children
|
|
71
|
+
} = _ref2;
|
|
72
|
+
return /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
73
|
+
data: data
|
|
74
|
+
}, children);
|
|
75
|
+
};
|
|
70
76
|
|
|
71
77
|
const onComplete = jest.fn();
|
|
72
78
|
const onError = jest.fn();
|
|
@@ -100,14 +106,19 @@ describe('useDataQuery', () => {
|
|
|
100
106
|
const query = {
|
|
101
107
|
x: {
|
|
102
108
|
resource: 'answer',
|
|
103
|
-
id: ({
|
|
104
|
-
|
|
105
|
-
|
|
109
|
+
id: (_ref3) => {
|
|
110
|
+
let {
|
|
111
|
+
id
|
|
112
|
+
} = _ref3;
|
|
113
|
+
return id;
|
|
114
|
+
}
|
|
106
115
|
}
|
|
107
116
|
};
|
|
108
|
-
const mockSpy = jest.fn((_, {
|
|
109
|
-
|
|
110
|
-
|
|
117
|
+
const mockSpy = jest.fn((_, _ref4) => {
|
|
118
|
+
let {
|
|
119
|
+
id
|
|
120
|
+
} = _ref4;
|
|
121
|
+
|
|
111
122
|
switch (id) {
|
|
112
123
|
case one:
|
|
113
124
|
return Promise.resolve(resultOne);
|
|
@@ -120,11 +131,14 @@ describe('useDataQuery', () => {
|
|
|
120
131
|
answer: mockSpy
|
|
121
132
|
};
|
|
122
133
|
|
|
123
|
-
const wrapper = ({
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
134
|
+
const wrapper = (_ref5) => {
|
|
135
|
+
let {
|
|
136
|
+
children
|
|
137
|
+
} = _ref5;
|
|
138
|
+
return /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
139
|
+
data: data
|
|
140
|
+
}, children);
|
|
141
|
+
};
|
|
128
142
|
|
|
129
143
|
const initialProps = {
|
|
130
144
|
query,
|
|
@@ -184,11 +198,14 @@ describe('useDataQuery', () => {
|
|
|
184
198
|
answer: mockSpy
|
|
185
199
|
};
|
|
186
200
|
|
|
187
|
-
const wrapper = ({
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
201
|
+
const wrapper = (_ref6) => {
|
|
202
|
+
let {
|
|
203
|
+
children
|
|
204
|
+
} = _ref6;
|
|
205
|
+
return /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
206
|
+
data: data
|
|
207
|
+
}, children);
|
|
208
|
+
};
|
|
192
209
|
|
|
193
210
|
const {
|
|
194
211
|
result,
|
|
@@ -232,12 +249,15 @@ describe('useDataQuery', () => {
|
|
|
232
249
|
}
|
|
233
250
|
};
|
|
234
251
|
|
|
235
|
-
const wrapper = ({
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
252
|
+
const wrapper = (_ref7) => {
|
|
253
|
+
let {
|
|
254
|
+
children
|
|
255
|
+
} = _ref7;
|
|
256
|
+
return /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
257
|
+
data: data,
|
|
258
|
+
queryClientOptions: queryClientOptions
|
|
259
|
+
}, children);
|
|
260
|
+
};
|
|
241
261
|
|
|
242
262
|
const {
|
|
243
263
|
result,
|
|
@@ -306,11 +326,14 @@ describe('useDataQuery', () => {
|
|
|
306
326
|
}
|
|
307
327
|
};
|
|
308
328
|
|
|
309
|
-
const wrapper = ({
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
329
|
+
const wrapper = (_ref8) => {
|
|
330
|
+
let {
|
|
331
|
+
children
|
|
332
|
+
} = _ref8;
|
|
333
|
+
return /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
334
|
+
data: data
|
|
335
|
+
}, children);
|
|
336
|
+
};
|
|
314
337
|
|
|
315
338
|
const {
|
|
316
339
|
result,
|
|
@@ -352,11 +375,14 @@ describe('useDataQuery', () => {
|
|
|
352
375
|
answer: 42
|
|
353
376
|
};
|
|
354
377
|
|
|
355
|
-
const wrapper = ({
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
378
|
+
const wrapper = (_ref9) => {
|
|
379
|
+
let {
|
|
380
|
+
children
|
|
381
|
+
} = _ref9;
|
|
382
|
+
return /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
383
|
+
data: data
|
|
384
|
+
}, children);
|
|
385
|
+
};
|
|
360
386
|
|
|
361
387
|
const {
|
|
362
388
|
result,
|
|
@@ -391,11 +417,14 @@ describe('useDataQuery', () => {
|
|
|
391
417
|
opposite: 24
|
|
392
418
|
};
|
|
393
419
|
|
|
394
|
-
const wrapper = ({
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
420
|
+
const wrapper = (_ref10) => {
|
|
421
|
+
let {
|
|
422
|
+
children
|
|
423
|
+
} = _ref10;
|
|
424
|
+
return /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
425
|
+
data: data
|
|
426
|
+
}, children);
|
|
427
|
+
};
|
|
399
428
|
|
|
400
429
|
const {
|
|
401
430
|
result,
|
|
@@ -432,11 +461,14 @@ describe('useDataQuery', () => {
|
|
|
432
461
|
}
|
|
433
462
|
};
|
|
434
463
|
|
|
435
|
-
const wrapper = ({
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
464
|
+
const wrapper = (_ref11) => {
|
|
465
|
+
let {
|
|
466
|
+
children
|
|
467
|
+
} = _ref11;
|
|
468
|
+
return /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
469
|
+
data: data
|
|
470
|
+
}, children);
|
|
471
|
+
};
|
|
440
472
|
|
|
441
473
|
const {
|
|
442
474
|
result,
|
|
@@ -472,11 +504,14 @@ describe('useDataQuery', () => {
|
|
|
472
504
|
opposite: 24
|
|
473
505
|
};
|
|
474
506
|
|
|
475
|
-
const wrapper = ({
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
507
|
+
const wrapper = (_ref12) => {
|
|
508
|
+
let {
|
|
509
|
+
children
|
|
510
|
+
} = _ref12;
|
|
511
|
+
return /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
512
|
+
data: data
|
|
513
|
+
}, children);
|
|
514
|
+
};
|
|
480
515
|
|
|
481
516
|
const {
|
|
482
517
|
result,
|
|
@@ -512,11 +547,14 @@ describe('useDataQuery', () => {
|
|
|
512
547
|
}
|
|
513
548
|
};
|
|
514
549
|
|
|
515
|
-
const wrapper = ({
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
550
|
+
const wrapper = (_ref13) => {
|
|
551
|
+
let {
|
|
552
|
+
children
|
|
553
|
+
} = _ref13;
|
|
554
|
+
return /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
555
|
+
data: data
|
|
556
|
+
}, children);
|
|
557
|
+
};
|
|
520
558
|
|
|
521
559
|
const {
|
|
522
560
|
result,
|
|
@@ -570,17 +608,23 @@ describe('useDataQuery', () => {
|
|
|
570
608
|
const query = {
|
|
571
609
|
x: {
|
|
572
610
|
resource: 'answer',
|
|
573
|
-
id: ({
|
|
574
|
-
|
|
575
|
-
|
|
611
|
+
id: (_ref14) => {
|
|
612
|
+
let {
|
|
613
|
+
id
|
|
614
|
+
} = _ref14;
|
|
615
|
+
return id;
|
|
616
|
+
}
|
|
576
617
|
}
|
|
577
618
|
};
|
|
578
619
|
|
|
579
|
-
const wrapper = ({
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
620
|
+
const wrapper = (_ref15) => {
|
|
621
|
+
let {
|
|
622
|
+
children
|
|
623
|
+
} = _ref15;
|
|
624
|
+
return /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
625
|
+
data: data
|
|
626
|
+
}, children);
|
|
627
|
+
};
|
|
584
628
|
|
|
585
629
|
const {
|
|
586
630
|
result,
|
|
@@ -621,17 +665,23 @@ describe('useDataQuery', () => {
|
|
|
621
665
|
const query = {
|
|
622
666
|
x: {
|
|
623
667
|
resource: 'answer',
|
|
624
|
-
id: ({
|
|
625
|
-
|
|
626
|
-
|
|
668
|
+
id: (_ref16) => {
|
|
669
|
+
let {
|
|
670
|
+
id
|
|
671
|
+
} = _ref16;
|
|
672
|
+
return id;
|
|
673
|
+
}
|
|
627
674
|
}
|
|
628
675
|
};
|
|
629
676
|
|
|
630
|
-
const wrapper = ({
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
677
|
+
const wrapper = (_ref17) => {
|
|
678
|
+
let {
|
|
679
|
+
children
|
|
680
|
+
} = _ref17;
|
|
681
|
+
return /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
682
|
+
data: data
|
|
683
|
+
}, children);
|
|
684
|
+
};
|
|
635
685
|
|
|
636
686
|
const {
|
|
637
687
|
result,
|
|
@@ -671,11 +721,14 @@ describe('useDataQuery', () => {
|
|
|
671
721
|
}
|
|
672
722
|
};
|
|
673
723
|
|
|
674
|
-
const wrapper = ({
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
724
|
+
const wrapper = (_ref18) => {
|
|
725
|
+
let {
|
|
726
|
+
children
|
|
727
|
+
} = _ref18;
|
|
728
|
+
return /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
729
|
+
data: data
|
|
730
|
+
}, children);
|
|
731
|
+
};
|
|
679
732
|
|
|
680
733
|
const {
|
|
681
734
|
result,
|
|
@@ -711,11 +764,14 @@ describe('useDataQuery', () => {
|
|
|
711
764
|
}
|
|
712
765
|
};
|
|
713
766
|
|
|
714
|
-
const wrapper = ({
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
767
|
+
const wrapper = (_ref19) => {
|
|
768
|
+
let {
|
|
769
|
+
children
|
|
770
|
+
} = _ref19;
|
|
771
|
+
return /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
772
|
+
data: data
|
|
773
|
+
}, children);
|
|
774
|
+
};
|
|
719
775
|
|
|
720
776
|
const {
|
|
721
777
|
result,
|
|
@@ -778,11 +834,14 @@ describe('useDataQuery', () => {
|
|
|
778
834
|
answer: mockSpy
|
|
779
835
|
};
|
|
780
836
|
|
|
781
|
-
const wrapper = ({
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
837
|
+
const wrapper = (_ref20) => {
|
|
838
|
+
let {
|
|
839
|
+
children
|
|
840
|
+
} = _ref20;
|
|
841
|
+
return /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
842
|
+
data: data
|
|
843
|
+
}, children);
|
|
844
|
+
};
|
|
786
845
|
|
|
787
846
|
const {
|
|
788
847
|
result,
|
|
@@ -824,11 +883,14 @@ describe('useDataQuery', () => {
|
|
|
824
883
|
answer: 42
|
|
825
884
|
};
|
|
826
885
|
|
|
827
|
-
const wrapper = ({
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
886
|
+
const wrapper = (_ref21) => {
|
|
887
|
+
let {
|
|
888
|
+
children
|
|
889
|
+
} = _ref21;
|
|
890
|
+
return /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
891
|
+
data: data
|
|
892
|
+
}, children);
|
|
893
|
+
};
|
|
832
894
|
|
|
833
895
|
const onComplete = jest.fn();
|
|
834
896
|
const onError = jest.fn();
|
|
@@ -871,11 +933,14 @@ describe('useDataQuery', () => {
|
|
|
871
933
|
}
|
|
872
934
|
};
|
|
873
935
|
|
|
874
|
-
const wrapper = ({
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
936
|
+
const wrapper = (_ref22) => {
|
|
937
|
+
let {
|
|
938
|
+
children
|
|
939
|
+
} = _ref22;
|
|
940
|
+
return /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
941
|
+
data: data
|
|
942
|
+
}, children);
|
|
943
|
+
};
|
|
879
944
|
|
|
880
945
|
const onComplete = jest.fn();
|
|
881
946
|
const onError = jest.fn();
|
|
@@ -908,15 +973,18 @@ describe('useDataQuery', () => {
|
|
|
908
973
|
const query = {
|
|
909
974
|
x: {
|
|
910
975
|
resource: 'answer',
|
|
911
|
-
params: ({
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
976
|
+
params: (_ref23) => {
|
|
977
|
+
let {
|
|
978
|
+
one,
|
|
979
|
+
two,
|
|
980
|
+
three
|
|
981
|
+
} = _ref23;
|
|
982
|
+
return {
|
|
983
|
+
one,
|
|
984
|
+
two,
|
|
985
|
+
three
|
|
986
|
+
};
|
|
987
|
+
}
|
|
920
988
|
}
|
|
921
989
|
};
|
|
922
990
|
const spy = jest.fn(() => 42);
|
|
@@ -924,11 +992,14 @@ describe('useDataQuery', () => {
|
|
|
924
992
|
answer: spy
|
|
925
993
|
};
|
|
926
994
|
|
|
927
|
-
const wrapper = ({
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
995
|
+
const wrapper = (_ref24) => {
|
|
996
|
+
let {
|
|
997
|
+
children
|
|
998
|
+
} = _ref24;
|
|
999
|
+
return /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
1000
|
+
data: data
|
|
1001
|
+
}, children);
|
|
1002
|
+
};
|
|
932
1003
|
|
|
933
1004
|
const {
|
|
934
1005
|
result,
|
|
@@ -970,11 +1041,14 @@ describe('useDataQuery', () => {
|
|
|
970
1041
|
answer: 42
|
|
971
1042
|
};
|
|
972
1043
|
|
|
973
|
-
const wrapper = ({
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
1044
|
+
const wrapper = (_ref25) => {
|
|
1045
|
+
let {
|
|
1046
|
+
children
|
|
1047
|
+
} = _ref25;
|
|
1048
|
+
return /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
1049
|
+
data: data
|
|
1050
|
+
}, children);
|
|
1051
|
+
};
|
|
978
1052
|
|
|
979
1053
|
const {
|
|
980
1054
|
result,
|
|
@@ -1011,11 +1085,14 @@ describe('useDataQuery', () => {
|
|
|
1011
1085
|
answer: 42
|
|
1012
1086
|
};
|
|
1013
1087
|
|
|
1014
|
-
const wrapper = ({
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1088
|
+
const wrapper = (_ref26) => {
|
|
1089
|
+
let {
|
|
1090
|
+
children
|
|
1091
|
+
} = _ref26;
|
|
1092
|
+
return /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
1093
|
+
data: data
|
|
1094
|
+
}, children);
|
|
1095
|
+
};
|
|
1019
1096
|
|
|
1020
1097
|
const {
|
|
1021
1098
|
result,
|
|
@@ -1055,11 +1132,14 @@ describe('useDataQuery', () => {
|
|
|
1055
1132
|
}
|
|
1056
1133
|
};
|
|
1057
1134
|
|
|
1058
|
-
const wrapper = ({
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1135
|
+
const wrapper = (_ref27) => {
|
|
1136
|
+
let {
|
|
1137
|
+
children
|
|
1138
|
+
} = _ref27;
|
|
1139
|
+
return /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
1140
|
+
data: data
|
|
1141
|
+
}, children);
|
|
1142
|
+
};
|
|
1063
1143
|
|
|
1064
1144
|
const {
|
|
1065
1145
|
result,
|
|
@@ -1093,11 +1173,14 @@ describe('useDataQuery', () => {
|
|
|
1093
1173
|
}
|
|
1094
1174
|
};
|
|
1095
1175
|
|
|
1096
|
-
const wrapper = ({
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1176
|
+
const wrapper = (_ref28) => {
|
|
1177
|
+
let {
|
|
1178
|
+
children
|
|
1179
|
+
} = _ref28;
|
|
1180
|
+
return /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
1181
|
+
data: data
|
|
1182
|
+
}, children);
|
|
1183
|
+
};
|
|
1101
1184
|
|
|
1102
1185
|
const {
|
|
1103
1186
|
result,
|
|
@@ -1126,14 +1209,19 @@ describe('useDataQuery', () => {
|
|
|
1126
1209
|
const query = {
|
|
1127
1210
|
x: {
|
|
1128
1211
|
resource: 'answer',
|
|
1129
|
-
id: ({
|
|
1130
|
-
|
|
1131
|
-
|
|
1212
|
+
id: (_ref29) => {
|
|
1213
|
+
let {
|
|
1214
|
+
id
|
|
1215
|
+
} = _ref29;
|
|
1216
|
+
return id;
|
|
1217
|
+
}
|
|
1132
1218
|
}
|
|
1133
1219
|
};
|
|
1134
|
-
const mockSpy = jest.fn((_, {
|
|
1135
|
-
|
|
1136
|
-
|
|
1220
|
+
const mockSpy = jest.fn((_, _ref30) => {
|
|
1221
|
+
let {
|
|
1222
|
+
id
|
|
1223
|
+
} = _ref30;
|
|
1224
|
+
|
|
1137
1225
|
switch (id) {
|
|
1138
1226
|
case one:
|
|
1139
1227
|
return Promise.resolve(resultOne);
|
|
@@ -1146,11 +1234,14 @@ describe('useDataQuery', () => {
|
|
|
1146
1234
|
answer: mockSpy
|
|
1147
1235
|
};
|
|
1148
1236
|
|
|
1149
|
-
const wrapper = ({
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1237
|
+
const wrapper = (_ref31) => {
|
|
1238
|
+
let {
|
|
1239
|
+
children
|
|
1240
|
+
} = _ref31;
|
|
1241
|
+
return /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
1242
|
+
data: data
|
|
1243
|
+
}, children);
|
|
1244
|
+
};
|
|
1154
1245
|
|
|
1155
1246
|
const initialProps = {
|
|
1156
1247
|
query,
|
|
@@ -1199,15 +1290,18 @@ describe('useDataQuery', () => {
|
|
|
1199
1290
|
const query = {
|
|
1200
1291
|
x: {
|
|
1201
1292
|
resource: 'answer',
|
|
1202
|
-
params: ({
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1293
|
+
params: (_ref32) => {
|
|
1294
|
+
let {
|
|
1295
|
+
one,
|
|
1296
|
+
two,
|
|
1297
|
+
three
|
|
1298
|
+
} = _ref32;
|
|
1299
|
+
return {
|
|
1300
|
+
one,
|
|
1301
|
+
two,
|
|
1302
|
+
three
|
|
1303
|
+
};
|
|
1304
|
+
}
|
|
1211
1305
|
}
|
|
1212
1306
|
};
|
|
1213
1307
|
const mockSpy = jest.fn(() => Promise.resolve(42));
|
|
@@ -1215,11 +1309,14 @@ describe('useDataQuery', () => {
|
|
|
1215
1309
|
answer: mockSpy
|
|
1216
1310
|
};
|
|
1217
1311
|
|
|
1218
|
-
const wrapper = ({
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1312
|
+
const wrapper = (_ref33) => {
|
|
1313
|
+
let {
|
|
1314
|
+
children
|
|
1315
|
+
} = _ref33;
|
|
1316
|
+
return /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
1317
|
+
data: data
|
|
1318
|
+
}, children);
|
|
1319
|
+
};
|
|
1223
1320
|
|
|
1224
1321
|
const {
|
|
1225
1322
|
result,
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { useState, useCallback, useRef, useEffect } from 'react';
|
|
2
2
|
import { FetchError } from '../../engine';
|
|
3
3
|
import { useStaticInput } from './useStaticInput';
|
|
4
|
-
export const useQueryExecutor = ({
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
export const useQueryExecutor = (_ref) => {
|
|
5
|
+
let {
|
|
6
|
+
execute,
|
|
7
|
+
variables: initialVariables,
|
|
8
|
+
singular,
|
|
9
|
+
immediate,
|
|
10
|
+
onComplete,
|
|
11
|
+
onError
|
|
12
|
+
} = _ref;
|
|
12
13
|
const [theExecute] = useStaticInput(execute);
|
|
13
14
|
const [state, setState] = useState({
|
|
14
15
|
called: !!immediate,
|
|
@@ -31,7 +32,8 @@ export const useQueryExecutor = ({
|
|
|
31
32
|
})
|
|
32
33
|
}));
|
|
33
34
|
}, [abort]);
|
|
34
|
-
const refetch = useCallback((
|
|
35
|
+
const refetch = useCallback(function () {
|
|
36
|
+
let newVariables = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
35
37
|
setState(state => !state.called || !state.loading ? {
|
|
36
38
|
called: true,
|
|
37
39
|
loading: true
|