@graphql-box/cache-manager 2.4.0 → 2.5.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.
Files changed (64) hide show
  1. package/lib/browser/index.js +1 -1
  2. package/lib/browser/index.js.map +1 -1
  3. package/lib/browser/production.analysis.txt +63 -27
  4. package/lib/main/helpers/isFirstResponseChunk.js +11 -0
  5. package/lib/main/helpers/isFirstResponseChunk.js.map +1 -0
  6. package/lib/main/helpers/isLastResponseChunk.js +11 -0
  7. package/lib/main/helpers/isLastResponseChunk.js.map +1 -0
  8. package/lib/main/helpers/isNotLastResponseChunk.js +11 -0
  9. package/lib/main/helpers/isNotLastResponseChunk.js.map +1 -0
  10. package/lib/main/helpers/isNotResponseChunk.js +11 -0
  11. package/lib/main/helpers/isNotResponseChunk.js.map +1 -0
  12. package/lib/main/helpers/mergeResponseDataSets.js +53 -0
  13. package/lib/main/helpers/mergeResponseDataSets.js.map +1 -0
  14. package/lib/main/helpers/{normalizeResponseData.js → normalizePatchResponseData.js} +13 -8
  15. package/lib/main/helpers/normalizePatchResponseData.js.map +1 -0
  16. package/lib/main/main/index.js +125 -90
  17. package/lib/main/main/index.js.map +1 -1
  18. package/lib/module/helpers/isFirstResponseChunk.js +2 -0
  19. package/lib/module/helpers/isFirstResponseChunk.js.map +1 -0
  20. package/lib/module/helpers/isLastResponseChunk.js +2 -0
  21. package/lib/module/helpers/isLastResponseChunk.js.map +1 -0
  22. package/lib/module/helpers/isNotLastResponseChunk.js +2 -0
  23. package/lib/module/helpers/isNotLastResponseChunk.js.map +1 -0
  24. package/lib/module/helpers/isNotResponseChunk.js +2 -0
  25. package/lib/module/helpers/isNotResponseChunk.js.map +1 -0
  26. package/lib/module/helpers/mergeResponseDataSets.js +41 -0
  27. package/lib/module/helpers/mergeResponseDataSets.js.map +1 -0
  28. package/lib/module/helpers/normalizePatchResponseData.js +17 -0
  29. package/lib/module/helpers/normalizePatchResponseData.js.map +1 -0
  30. package/lib/module/main/index.js +122 -90
  31. package/lib/module/main/index.js.map +1 -1
  32. package/lib/types/defs/index.d.ts +2 -2
  33. package/lib/types/defs/index.d.ts.map +1 -1
  34. package/lib/types/helpers/isFirstResponseChunk.d.ts +5 -0
  35. package/lib/types/helpers/isFirstResponseChunk.d.ts.map +1 -0
  36. package/lib/types/helpers/isLastResponseChunk.d.ts +5 -0
  37. package/lib/types/helpers/isLastResponseChunk.d.ts.map +1 -0
  38. package/lib/types/helpers/isNotLastResponseChunk.d.ts +5 -0
  39. package/lib/types/helpers/isNotLastResponseChunk.d.ts.map +1 -0
  40. package/lib/types/helpers/isNotResponseChunk.d.ts +5 -0
  41. package/lib/types/helpers/isNotResponseChunk.d.ts.map +1 -0
  42. package/lib/types/helpers/mergeResponseDataSets.d.ts +4 -0
  43. package/lib/types/helpers/mergeResponseDataSets.d.ts.map +1 -0
  44. package/lib/types/helpers/normalizePatchResponseData.d.ts +5 -0
  45. package/lib/types/helpers/normalizePatchResponseData.d.ts.map +1 -0
  46. package/lib/types/main/index.d.ts +6 -3
  47. package/lib/types/main/index.d.ts.map +1 -1
  48. package/package.json +1 -1
  49. package/src/__snapshots__/index.test.ts.snap +12483 -11883
  50. package/src/defs/index.ts +13 -13
  51. package/src/helpers/isFirstResponseChunk.ts +5 -0
  52. package/src/helpers/isLastResponseChunk.ts +5 -0
  53. package/src/helpers/isNotLastResponseChunk.ts +5 -0
  54. package/src/helpers/isNotResponseChunk.ts +5 -0
  55. package/src/helpers/mergeResponseDataSets.ts +35 -0
  56. package/src/helpers/normalizePatchResponseData.ts +17 -0
  57. package/src/index.test.ts +162 -86
  58. package/src/main/index.ts +151 -107
  59. package/lib/main/helpers/normalizeResponseData.js.map +0 -1
  60. package/lib/module/helpers/normalizeResponseData.js +0 -12
  61. package/lib/module/helpers/normalizeResponseData.js.map +0 -1
  62. package/lib/types/helpers/normalizeResponseData.d.ts +0 -11
  63. package/lib/types/helpers/normalizeResponseData.d.ts.map +0 -1
  64. package/src/helpers/normalizeResponseData.ts +0 -10
@@ -1,23 +1,23 @@
1
1
  -----------------------------
2
2
  Rollup File Analysis
3
3
  -----------------------------
4
- bundle size: 90.576 KB
5
- original size: 60.859 KB
4
+ bundle size: 94.202 KB
5
+ original size: 64.867 KB
6
6
  code reduction: 0 %
7
- module count: 21
7
+ module count: 25
8
8
 
9
9
  ███████████████████████████████████░░░░░░░░░░░░░░░
10
10
  file: /src/main/index.ts
11
- bundle space: 71.58 %
12
- rendered size: 64.837 KB
13
- original size: 35.978 KB
11
+ bundle space: 70.22 %
12
+ rendered size: 66.144 KB
13
+ original size: 38.003 KB
14
14
  code reduction: 0 %
15
15
  dependents: 1
16
16
  - /src/index.ts
17
17
 
18
18
  ██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
19
19
  file: /src/debug/log-cache-query/index.ts
20
- bundle space: 4.24 %
20
+ bundle space: 4.08 %
21
21
  rendered size: 3.839 KB
22
22
  original size: 1.282 KB
23
23
  code reduction: 0 %
@@ -26,7 +26,7 @@ dependents: 1
26
26
 
27
27
  █░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
28
28
  file: /src/debug/log-cache-entry/index.ts
29
- bundle space: 3.81 %
29
+ bundle space: 3.66 %
30
30
  rendered size: 3.451 KB
31
31
  original size: 1.197 KB
32
32
  code reduction: 0 %
@@ -35,7 +35,7 @@ dependents: 1
35
35
 
36
36
  █░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
37
37
  file: /src/debug/log-partial-compiled/index.ts
38
- bundle space: 3.72 %
38
+ bundle space: 3.58 %
39
39
  rendered size: 3.37 KB
40
40
  original size: 1.161 KB
41
41
  code reduction: 0 %
@@ -44,7 +44,7 @@ dependents: 1
44
44
 
45
45
  █░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
46
46
  file: /src/helpers/filterField.ts
47
- bundle space: 3.13 %
47
+ bundle space: 3.01 %
48
48
  rendered size: 2.834 KB
49
49
  original size: 2.914 KB
50
50
  code reduction: 2.75 %
@@ -54,7 +54,7 @@ dependents: 2
54
54
 
55
55
  █░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
56
56
  file: /src/helpers/buildKeysAndPaths.ts
57
- bundle space: 2.72 %
57
+ bundle space: 2.61 %
58
58
  rendered size: 2.461 KB
59
59
  original size: 2.196 KB
60
60
  code reduction: 0 %
@@ -64,9 +64,18 @@ dependents: 4
64
64
  - /src/helpers/filterQuery.ts
65
65
  - /src/main/index.ts
66
66
 
67
+ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
68
+ file: /src/helpers/mergeResponseDataSets.ts
69
+ bundle space: 1.82 %
70
+ rendered size: 1.716 KB
71
+ original size: 907 Bytes
72
+ code reduction: 0 %
73
+ dependents: 1
74
+ - /src/main/index.ts
75
+
67
76
  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
68
77
  file: /src/helpers/filterFragmentDefinitions.ts
69
- bundle space: 1.59 %
78
+ bundle space: 1.53 %
70
79
  rendered size: 1.441 KB
71
80
  original size: 1.5 KB
72
81
  code reduction: 3.93 %
@@ -74,17 +83,17 @@ dependents: 1
74
83
  - /src/helpers/filterQuery.ts
75
84
 
76
85
  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
77
- file: /src/helpers/normalizeResponseData.ts
78
- bundle space: 1.27 %
79
- rendered size: 1.152 KB
80
- original size: 287 Bytes
86
+ file: /src/helpers/normalizePatchResponseData.ts
87
+ bundle space: 1.39 %
88
+ rendered size: 1.309 KB
89
+ original size: 478 Bytes
81
90
  code reduction: 0 %
82
91
  dependents: 1
83
92
  - /src/main/index.ts
84
93
 
85
94
  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
86
95
  file: /src/helpers/filterQuery.ts
87
- bundle space: 1.2 %
96
+ bundle space: 1.15 %
88
97
  rendered size: 1.088 KB
89
98
  original size: 1.467 KB
90
99
  code reduction: 25.84 %
@@ -93,7 +102,7 @@ dependents: 1
93
102
 
94
103
  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
95
104
  file: /src/helpers/filterIDsAndTypeNames.ts
96
- bundle space: 1.1 %
105
+ bundle space: 1.06 %
97
106
  rendered size: 998 Bytes
98
107
  original size: 1.107 KB
99
108
  code reduction: 9.85 %
@@ -102,7 +111,7 @@ dependents: 1
102
111
 
103
112
  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
104
113
  file: /src/helpers/checkFieldPathChecklist.ts
105
- bundle space: 1.06 %
114
+ bundle space: 1.02 %
106
115
  rendered size: 957 Bytes
107
116
  original size: 828 Bytes
108
117
  code reduction: 0 %
@@ -111,7 +120,7 @@ dependents: 1
111
120
 
112
121
  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
113
122
  file: /src/helpers/filterOutPropsWithArgsOrDirectives.ts
114
- bundle space: 1.02 %
123
+ bundle space: 0.98 %
115
124
  rendered size: 927 Bytes
116
125
  original size: 1.119 KB
117
126
  code reduction: 17.16 %
@@ -120,7 +129,7 @@ dependents: 1
120
129
 
121
130
  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
122
131
  file: /src/helpers/filterInlineFragments.ts
123
- bundle space: 0.87 %
132
+ bundle space: 0.84 %
124
133
  rendered size: 788 Bytes
125
134
  original size: 941 Bytes
126
135
  code reduction: 16.26 %
@@ -129,7 +138,7 @@ dependents: 1
129
138
 
130
139
  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
131
140
  file: /src/helpers/deriveOpCacheability.ts
132
- bundle space: 0.87 %
141
+ bundle space: 0.83 %
133
142
  rendered size: 786 Bytes
134
143
  original size: 858 Bytes
135
144
  code reduction: 8.39 %
@@ -138,7 +147,7 @@ dependents: 1
138
147
 
139
148
  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
140
149
  file: /src/helpers/filterFragmentSpreads.ts
141
- bundle space: 0.73 %
150
+ bundle space: 0.7 %
142
151
  rendered size: 661 Bytes
143
152
  original size: 936 Bytes
144
153
  code reduction: 29.38 %
@@ -147,7 +156,7 @@ dependents: 1
147
156
 
148
157
  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
149
158
  file: /src/helpers/createFragmentSpreadChecklist.ts
150
- bundle space: 0.4 %
159
+ bundle space: 0.38 %
151
160
  rendered size: 362 Bytes
152
161
  original size: 470 Bytes
153
162
  code reduction: 22.98 %
@@ -156,7 +165,7 @@ dependents: 1
156
165
 
157
166
  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
158
167
  file: /src/consts/index.ts
159
- bundle space: 0.35 %
168
+ bundle space: 0.33 %
160
169
  rendered size: 315 Bytes
161
170
  original size: 390 Bytes
162
171
  code reduction: 19.23 %
@@ -170,18 +179,45 @@ dependents: 6
170
179
 
171
180
  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
172
181
  file: /src/helpers/validTypeIDValue.ts
173
- bundle space: 0.34 %
182
+ bundle space: 0.33 %
174
183
  rendered size: 309 Bytes
175
184
  original size: 426 Bytes
176
185
  code reduction: 27.46 %
177
186
  dependents: 1
178
187
  - /src/main/index.ts
179
188
 
189
+ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
190
+ file: /src/helpers/isNotResponseChunk.ts
191
+ bundle space: 0.17 %
192
+ rendered size: 157 Bytes
193
+ original size: 306 Bytes
194
+ code reduction: 48.69 %
195
+ dependents: 1
196
+ - /src/main/index.ts
197
+
198
+ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
199
+ file: /src/helpers/isLastResponseChunk.ts
200
+ bundle space: 0.17 %
201
+ rendered size: 156 Bytes
202
+ original size: 304 Bytes
203
+ code reduction: 48.68 %
204
+ dependents: 1
205
+ - /src/main/index.ts
206
+
207
+ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
208
+ file: /src/helpers/isNotLastResponseChunk.ts
209
+ bundle space: 0.14 %
210
+ rendered size: 133 Bytes
211
+ original size: 278 Bytes
212
+ code reduction: 52.16 %
213
+ dependents: 1
214
+ - /src/main/index.ts
215
+
180
216
  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
181
217
  file: /src/defs/index.ts
182
218
  bundle space: 0 %
183
219
  rendered size: 0 Byte
184
- original size: 5.422 KB
220
+ original size: 5.419 KB
185
221
  code reduction: 100 %
186
222
  dependents: 1
187
223
  - /src/index.ts
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _default = (rawResponseData, context) => context.hasDeferOrStream && rawResponseData.hasNext && !rawResponseData.paths;
9
+
10
+ exports.default = _default;
11
+ //# sourceMappingURL=isFirstResponseChunk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/helpers/isFirstResponseChunk.ts"],"names":["rawResponseData","context","hasDeferOrStream","hasNext","paths"],"mappings":";;;;;;;eAGe,CAACA,eAAD,EAAyDC,OAAzD,KACbA,OAAO,CAACC,gBAAR,IAA4BF,eAAe,CAACG,OAA5C,IAAuD,CAACH,eAAe,CAACI,K","sourcesContent":["import { RawResponseDataWithMaybeCacheMetadata } from \"@graphql-box/core\";\nimport { CacheManagerContext } from \"..\";\n\nexport default (rawResponseData: RawResponseDataWithMaybeCacheMetadata, context: CacheManagerContext) =>\n context.hasDeferOrStream && rawResponseData.hasNext && !rawResponseData.paths;\n"],"file":"isFirstResponseChunk.js"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _default = (rawResponseData, context) => context.hasDeferOrStream && !rawResponseData.hasNext && rawResponseData.paths;
9
+
10
+ exports.default = _default;
11
+ //# sourceMappingURL=isLastResponseChunk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/helpers/isLastResponseChunk.ts"],"names":["rawResponseData","context","hasDeferOrStream","hasNext","paths"],"mappings":";;;;;;;eAGe,CAACA,eAAD,EAAyDC,OAAzD,KACbA,OAAO,CAACC,gBAAR,IAA4B,CAACF,eAAe,CAACG,OAA7C,IAAwDH,eAAe,CAACI,K","sourcesContent":["import { RawResponseDataWithMaybeCacheMetadata } from \"@graphql-box/core\";\nimport { CacheManagerContext } from \"..\";\n\nexport default (rawResponseData: RawResponseDataWithMaybeCacheMetadata, context: CacheManagerContext) =>\n context.hasDeferOrStream && !rawResponseData.hasNext && rawResponseData.paths;\n"],"file":"isLastResponseChunk.js"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _default = (rawResponseData, context) => context.hasDeferOrStream && rawResponseData.hasNext;
9
+
10
+ exports.default = _default;
11
+ //# sourceMappingURL=isNotLastResponseChunk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/helpers/isNotLastResponseChunk.ts"],"names":["rawResponseData","context","hasDeferOrStream","hasNext"],"mappings":";;;;;;;eAGe,CAACA,eAAD,EAAyDC,OAAzD,KACbA,OAAO,CAACC,gBAAR,IAA4BF,eAAe,CAACG,O","sourcesContent":["import { RawResponseDataWithMaybeCacheMetadata } from \"@graphql-box/core\";\nimport { CacheManagerContext } from \"..\";\n\nexport default (rawResponseData: RawResponseDataWithMaybeCacheMetadata, context: CacheManagerContext) =>\n context.hasDeferOrStream && rawResponseData.hasNext;\n"],"file":"isNotLastResponseChunk.js"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _default = (rawResponseData, context) => !context.hasDeferOrStream && !rawResponseData.hasNext && !rawResponseData.paths;
9
+
10
+ exports.default = _default;
11
+ //# sourceMappingURL=isNotResponseChunk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/helpers/isNotResponseChunk.ts"],"names":["rawResponseData","context","hasDeferOrStream","hasNext","paths"],"mappings":";;;;;;;eAGe,CAACA,eAAD,EAAyDC,OAAzD,KACb,CAACA,OAAO,CAACC,gBAAT,IAA6B,CAACF,eAAe,CAACG,OAA9C,IAAyD,CAACH,eAAe,CAACI,K","sourcesContent":["import { RawResponseDataWithMaybeCacheMetadata } from \"@graphql-box/core\";\nimport { CacheManagerContext } from \"..\";\n\nexport default (rawResponseData: RawResponseDataWithMaybeCacheMetadata, context: CacheManagerContext) =>\n !context.hasDeferOrStream && !rawResponseData.hasNext && !rawResponseData.paths;\n"],"file":"isNotResponseChunk.js"}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _merge2 = _interopRequireDefault(require("lodash/merge"));
11
+
12
+ var _default = responseDataSets => {
13
+ return responseDataSets.reduce((acc, dataSet, index) => {
14
+ const {
15
+ _cacheMetadata,
16
+ data,
17
+ hasNext,
18
+ headers,
19
+ paths
20
+ } = dataSet;
21
+
22
+ if (_cacheMetadata) {
23
+ acc._cacheMetadata = acc._cacheMetadata ? { ...acc._cacheMetadata,
24
+ ..._cacheMetadata
25
+ } : _cacheMetadata;
26
+ }
27
+
28
+ acc.data = acc.data ? (0, _merge2.default)(acc.data, data) : data;
29
+
30
+ if (index === 0) {
31
+ acc.headers = headers;
32
+ }
33
+
34
+ if (index === responseDataSets.length - 1) {
35
+ acc.hasNext = hasNext;
36
+ }
37
+
38
+ if (paths) {
39
+ if (!acc.paths) {
40
+ acc.paths = [];
41
+ }
42
+
43
+ acc.paths.push(paths[0]);
44
+ }
45
+
46
+ return acc;
47
+ }, {
48
+ data: {}
49
+ });
50
+ };
51
+
52
+ exports.default = _default;
53
+ //# sourceMappingURL=mergeResponseDataSets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/helpers/mergeResponseDataSets.ts"],"names":["responseDataSets","reduce","acc","dataSet","index","_cacheMetadata","data","hasNext","headers","paths","length","push"],"mappings":";;;;;;;;;;;eAGgBA,gBAAD,IAA+D;AAC5E,SAAOA,gBAAgB,CAACC,MAAjB,CACL,CAACC,GAAD,EAA6CC,OAA7C,EAAsDC,KAAtD,KAAgE;AAC9D,UAAM;AAAEC,MAAAA,cAAF;AAAkBC,MAAAA,IAAlB;AAAwBC,MAAAA,OAAxB;AAAiCC,MAAAA,OAAjC;AAA0CC,MAAAA;AAA1C,QAAoDN,OAA1D;;AAEA,QAAIE,cAAJ,EAAoB;AAClBH,MAAAA,GAAG,CAACG,cAAJ,GAAqBH,GAAG,CAACG,cAAJ,GAAqB,EAAE,GAAGH,GAAG,CAACG,cAAT;AAAyB,WAAGA;AAA5B,OAArB,GAAoEA,cAAzF;AACD;;AAEDH,IAAAA,GAAG,CAACI,IAAJ,GAAWJ,GAAG,CAACI,IAAJ,GAAW,qBAAMJ,GAAG,CAACI,IAAV,EAAgBA,IAAhB,CAAX,GAAmCA,IAA9C;;AAEA,QAAIF,KAAK,KAAK,CAAd,EAAiB;AACfF,MAAAA,GAAG,CAACM,OAAJ,GAAcA,OAAd;AACD;;AAED,QAAIJ,KAAK,KAAKJ,gBAAgB,CAACU,MAAjB,GAA0B,CAAxC,EAA2C;AACzCR,MAAAA,GAAG,CAACK,OAAJ,GAAcA,OAAd;AACD;;AAED,QAAIE,KAAJ,EAAW;AACT,UAAI,CAACP,GAAG,CAACO,KAAT,EAAgB;AACdP,QAAAA,GAAG,CAACO,KAAJ,GAAY,EAAZ;AACD;;AAEDP,MAAAA,GAAG,CAACO,KAAJ,CAAUE,IAAV,CAAeF,KAAK,CAAC,CAAD,CAApB;AACD;;AAED,WAAOP,GAAP;AACD,GA3BI,EA4BL;AAAEI,IAAAA,IAAI,EAAE;AAAR,GA5BK,CAAP;AA8BD,C","sourcesContent":["import { RawResponseDataWithMaybeCacheMetadata } from \"@graphql-box/core\";\nimport { merge } from \"lodash\";\n\nexport default (responseDataSets: RawResponseDataWithMaybeCacheMetadata[]) => {\n return responseDataSets.reduce(\n (acc: RawResponseDataWithMaybeCacheMetadata, dataSet, index) => {\n const { _cacheMetadata, data, hasNext, headers, paths } = dataSet;\n\n if (_cacheMetadata) {\n acc._cacheMetadata = acc._cacheMetadata ? { ...acc._cacheMetadata, ..._cacheMetadata } : _cacheMetadata;\n }\n\n acc.data = acc.data ? merge(acc.data, data) : data;\n\n if (index === 0) {\n acc.headers = headers;\n }\n\n if (index === responseDataSets.length - 1) {\n acc.hasNext = hasNext;\n }\n\n if (paths) {\n if (!acc.paths) {\n acc.paths = [];\n }\n\n acc.paths.push(paths[0]);\n }\n\n return acc;\n },\n { data: {} },\n );\n};\n"],"file":"mergeResponseDataSets.js"}
@@ -9,16 +9,21 @@ exports.default = void 0;
9
9
 
10
10
  var _set2 = _interopRequireDefault(require("lodash/set"));
11
11
 
12
- var _default = ({
13
- data,
14
- path,
15
- ...rest
16
- }) => {
12
+ var _default = (rawResponseData, context) => {
13
+ if (!context.normalizePatchResponseData) {
14
+ return rawResponseData;
15
+ }
16
+
17
+ const {
18
+ data,
19
+ paths,
20
+ ...rest
21
+ } = rawResponseData;
17
22
  return { ...rest,
18
- data: (0, _set2.default)({}, path, data),
19
- path
23
+ data: (0, _set2.default)({}, paths[0], data),
24
+ paths
20
25
  };
21
26
  };
22
27
 
23
28
  exports.default = _default;
24
- //# sourceMappingURL=normalizeResponseData.js.map
29
+ //# sourceMappingURL=normalizePatchResponseData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/helpers/normalizePatchResponseData.ts"],"names":["rawResponseData","context","normalizePatchResponseData","data","paths","rest"],"mappings":";;;;;;;;;;;eAIe,CAACA,eAAD,EAAyDC,OAAzD,KAA0F;AACvG,MAAI,CAACA,OAAO,CAACC,0BAAb,EAAyC;AACvC,WAAOF,eAAP;AACD;;AAED,QAAM;AAAEG,IAAAA,IAAF;AAAQC,IAAAA,KAAR;AAAe,OAAGC;AAAlB,MAA2BL,eAAjC;AAEA,SAAO,EACL,GAAGK,IADE;AAELF,IAAAA,IAAI,EAAE,mBAAI,EAAJ,EAASC,KAAD,CAAoB,CAApB,CAAR,EAAgCD,IAAhC,CAFD;AAGLC,IAAAA;AAHK,GAAP;AAKD,C","sourcesContent":["import { RawResponseDataWithMaybeCacheMetadata } from \"@graphql-box/core\";\nimport { set } from \"lodash\";\nimport { CacheManagerContext } from \"..\";\n\nexport default (rawResponseData: RawResponseDataWithMaybeCacheMetadata, context: CacheManagerContext) => {\n if (!context.normalizePatchResponseData) {\n return rawResponseData;\n }\n\n const { data, paths, ...rest } = rawResponseData;\n\n return {\n ...rest,\n data: set({}, (paths as string[])[0], data),\n paths,\n };\n};\n"],"file":"normalizePatchResponseData.js"}
@@ -52,7 +52,15 @@ var _filterOutPropsWithArgsOrDirectives = _interopRequireDefault(require("../hel
52
52
 
53
53
  var _filterQuery = _interopRequireDefault(require("../helpers/filterQuery"));
54
54
 
55
- var _normalizeResponseData = _interopRequireDefault(require("../helpers/normalizeResponseData"));
55
+ var _isLastResponseChunk = _interopRequireDefault(require("../helpers/isLastResponseChunk"));
56
+
57
+ var _isNotLastResponseChunk = _interopRequireDefault(require("../helpers/isNotLastResponseChunk"));
58
+
59
+ var _isNotResponseChunk = _interopRequireDefault(require("../helpers/isNotResponseChunk"));
60
+
61
+ var _mergeResponseDataSets = _interopRequireDefault(require("../helpers/mergeResponseDataSets"));
62
+
63
+ var _normalizePatchResponseData = _interopRequireDefault(require("../helpers/normalizePatchResponseData"));
56
64
 
57
65
  var _validTypeIDValue = require("../helpers/validTypeIDValue");
58
66
 
@@ -225,6 +233,7 @@ let CacheManager = (_dec = (0, _debug.logCacheQuery)(), _dec2 = (0, _debug.logCa
225
233
  (0, _defineProperty2.default)(this, "_cascadeCacheControl", void 0);
226
234
  (0, _defineProperty2.default)(this, "_fallbackOperationCacheability", void 0);
227
235
  (0, _defineProperty2.default)(this, "_partialQueryResponses", new Map());
236
+ (0, _defineProperty2.default)(this, "_responseChunksAwaitingCaching", new Map());
228
237
  (0, _defineProperty2.default)(this, "_typeCacheDirectives", void 0);
229
238
  (0, _defineProperty2.default)(this, "_typeIDKey", void 0);
230
239
  const {
@@ -312,6 +321,22 @@ let CacheManager = (_dec = (0, _debug.logCacheQuery)(), _dec2 = (0, _debug.logCa
312
321
  };
313
322
  }
314
323
 
324
+ async cacheQuery(requestData, updatedRequestData, rawResponseData, options, context) {
325
+ const cacheManagerContext = { ...context,
326
+ fragmentDefinitions: (0, _helpers.getFragmentDefinitions)(updatedRequestData.ast),
327
+ typeIDKey: this._typeIDKey
328
+ };
329
+ return this._cacheResponse(requestData, updatedRequestData, rawResponseData, options, cacheManagerContext);
330
+ }
331
+
332
+ async cacheResponse(requestData, rawResponseData, options, context) {
333
+ const cacheManagerContext = { ...context,
334
+ fragmentDefinitions: (0, _helpers.getFragmentDefinitions)(requestData.ast),
335
+ typeIDKey: this._typeIDKey
336
+ };
337
+ return this._cacheResponse(requestData, undefined, rawResponseData, options, cacheManagerContext);
338
+ }
339
+
315
340
  async checkCacheEntry(cacheType, hash, options, context) {
316
341
  return this._checkCacheEntry(cacheType, hash, options, context);
317
342
  }
@@ -337,66 +362,10 @@ let CacheManager = (_dec = (0, _debug.logCacheQuery)(), _dec2 = (0, _debug.logCa
337
362
  this._partialQueryResponses.delete(hash);
338
363
  }
339
364
 
340
- async resolveQuery(requestData, updatedRequestData, rawResponseData, options, context) {
341
- const cacheManagerContext = { ...context,
342
- fragmentDefinitions: (0, _helpers.getFragmentDefinitions)(updatedRequestData.ast),
343
- typeIDKey: this._typeIDKey
344
- };
345
- const dataCaching = [];
346
- const {
347
- cacheMetadata,
348
- data,
349
- hasNext,
350
- path
351
- } = await this._resolveRequest(updatedRequestData, rawResponseData, options, cacheManagerContext);
352
- let partialQueryResponse;
353
-
354
- if (cacheManagerContext.queryFiltered) {
355
- if (!(rawResponseData.hasNext || rawResponseData.path)) {
356
- dataCaching.push(this._setQueryResponseCacheEntry(updatedRequestData.hash, {
357
- cacheMetadata,
358
- data
359
- }, options, cacheManagerContext));
360
- }
361
-
362
- if (!rawResponseData.path) {
363
- partialQueryResponse = this._getPartialQueryResponse(requestData.hash);
364
- }
365
- }
366
-
367
- const responseCacheMetadata = CacheManager._mergeResponseCacheMetadata(cacheMetadata, partialQueryResponse);
368
-
369
- const responseData = this._mergeResponseData(data, partialQueryResponse);
370
-
371
- if (!(rawResponseData.hasNext || rawResponseData.path)) {
372
- dataCaching.push(this._setQueryResponseCacheEntry(requestData.hash, {
373
- cacheMetadata: responseCacheMetadata,
374
- data: responseData
375
- }, options, cacheManagerContext));
376
- }
377
-
378
- if (options.awaitDataCaching) {
379
- await Promise.all(dataCaching);
380
- }
381
-
382
- return {
383
- cacheMetadata: responseCacheMetadata,
384
- data: responseData,
385
- hasNext,
386
- path
387
- };
388
- }
389
-
390
- async resolveRequest(requestData, rawResponseData, options, context) {
391
- const cacheManagerContext = { ...context,
392
- fragmentDefinitions: (0, _helpers.getFragmentDefinitions)(requestData.ast),
393
- typeIDKey: this._typeIDKey
394
- };
395
- return this._resolveRequest(requestData, rawResponseData, options, cacheManagerContext);
396
- }
397
-
398
365
  async _analyzeFieldNode(fieldNode, cachedAncestorFieldData, cachedResponseData, options, context) {
399
- if ((0, _helpers.hasChildFields)(fieldNode)) {
366
+ if ((0, _helpers.hasChildFields)(fieldNode, {
367
+ fragmentDefinitions: context.fragmentDefinitions
368
+ })) {
400
369
  await this._analyzeParentFieldNode(fieldNode, cachedAncestorFieldData, cachedResponseData, options, context);
401
370
  } else {
402
371
  await this._analyzeLeafFieldNode(fieldNode, cachedAncestorFieldData, cachedResponseData, options, context);
@@ -531,6 +500,81 @@ let CacheManager = (_dec = (0, _debug.logCacheQuery)(), _dec2 = (0, _debug.logCa
531
500
  return cacheMetadata;
532
501
  }
533
502
 
503
+ async _cacheResponse(requestData, updatedRequestData, rawResponseData, options, context) {
504
+ const normalizedResponseData = (0, _normalizePatchResponseData.default)(rawResponseData, context);
505
+ let responseDataForCaching = normalizedResponseData;
506
+
507
+ if ((0, _isNotLastResponseChunk.default)(rawResponseData, context)) {
508
+ this._setResponseChunksAwaitingCaching(normalizedResponseData, context);
509
+
510
+ responseDataForCaching = undefined;
511
+ }
512
+
513
+ if ((0, _isLastResponseChunk.default)(rawResponseData, context)) {
514
+ responseDataForCaching = this._retrieveResponseDataForCaching(normalizedResponseData, context);
515
+ }
516
+
517
+ const dataCaching = [];
518
+
519
+ if (responseDataForCaching) {
520
+ const {
521
+ data
522
+ } = responseDataForCaching;
523
+
524
+ const cacheMetadata = this._buildCacheMetadata(requestData, responseDataForCaching, options, context);
525
+
526
+ dataCaching.push(this._setEntityAndRequestFieldPathCacheEntries(requestData, {
527
+ cacheMetadata,
528
+ entityData: (0, _cloneDeep2.default)(data),
529
+ requestFieldPathData: (0, _cloneDeep2.default)(data)
530
+ }, options, context));
531
+ let queryCacheMetadata;
532
+ let queryData;
533
+
534
+ if (context.operation === _core.QUERY) {
535
+ let partialQueryResponse;
536
+
537
+ if (context.queryFiltered && updatedRequestData) {
538
+ dataCaching.push(this._setQueryResponseCacheEntry(updatedRequestData.hash, {
539
+ cacheMetadata,
540
+ data
541
+ }, options, context));
542
+ partialQueryResponse = this._getPartialQueryResponse(requestData.hash);
543
+ }
544
+
545
+ queryCacheMetadata = CacheManager._mergeResponseCacheMetadata(cacheMetadata, partialQueryResponse);
546
+ queryData = this._mergeResponseData(data, partialQueryResponse);
547
+ dataCaching.push(this._setQueryResponseCacheEntry(requestData.hash, {
548
+ cacheMetadata: queryCacheMetadata,
549
+ data: queryData
550
+ }, options, context));
551
+ }
552
+
553
+ if (options.awaitDataCaching) {
554
+ await Promise.all(dataCaching);
555
+ }
556
+
557
+ if ((0, _isNotResponseChunk.default)(normalizedResponseData, context) && queryCacheMetadata && queryData) {
558
+ return {
559
+ cacheMetadata: queryCacheMetadata,
560
+ data: queryData
561
+ };
562
+ }
563
+ }
564
+
565
+ const {
566
+ data,
567
+ hasNext,
568
+ paths
569
+ } = normalizedResponseData;
570
+ return {
571
+ cacheMetadata: this._buildCacheMetadata(requestData, normalizedResponseData, options, context),
572
+ data,
573
+ hasNext,
574
+ paths
575
+ };
576
+ }
577
+
534
578
  async _checkCacheEntry(cacheType, hash, options, context) {
535
579
  try {
536
580
  const cacheability = await this._hasCacheEntry(cacheType, hash);
@@ -674,35 +718,6 @@ let CacheManager = (_dec = (0, _debug.logCacheQuery)(), _dec2 = (0, _debug.logCa
674
718
  }, options, context);
675
719
  }
676
720
 
677
- async _resolveRequest(requestData, rawResponseData, options, context) {
678
- const normalizedResponseData = rawResponseData.path ? (0, _normalizeResponseData.default)(rawResponseData) : rawResponseData;
679
- const dataCaching = [];
680
-
681
- const cacheMetadata = this._buildCacheMetadata(requestData, normalizedResponseData, options, context);
682
-
683
- const {
684
- data,
685
- hasNext,
686
- path
687
- } = normalizedResponseData;
688
- dataCaching.push(this._setEntityAndRequestFieldPathCacheEntries(requestData, {
689
- cacheMetadata,
690
- entityData: (0, _cloneDeep2.default)(data),
691
- requestFieldPathData: (0, _cloneDeep2.default)(data)
692
- }, options, context));
693
-
694
- if (options.awaitDataCaching) {
695
- await Promise.all(dataCaching);
696
- }
697
-
698
- return {
699
- cacheMetadata,
700
- data,
701
- hasNext,
702
- path
703
- };
704
- }
705
-
706
721
  async _retrieveCachedEntityData(validTypeIDValue, {
707
722
  possibleTypes,
708
723
  typeName
@@ -821,6 +836,14 @@ let CacheManager = (_dec = (0, _debug.logCacheQuery)(), _dec2 = (0, _debug.logCa
821
836
  return cachedResponseData;
822
837
  }
823
838
 
839
+ _retrieveResponseDataForCaching(normalizedResponseData, context) {
840
+ const responseChunks = this._responseChunksAwaitingCaching.get(context.boxID);
841
+
842
+ this._responseChunksAwaitingCaching.delete(context.boxID);
843
+
844
+ return (0, _mergeResponseDataSets.default)([...responseChunks, normalizedResponseData]);
845
+ }
846
+
824
847
  async _setCacheEntry(cacheType, hash, value, cachemapOptions, _options, _context) {
825
848
  try {
826
849
  await this._cache.set(`${cacheType}::${hash}`, (0, _cloneDeep2.default)(value), cachemapOptions);
@@ -1032,7 +1055,9 @@ let CacheManager = (_dec = (0, _debug.logCacheQuery)(), _dec2 = (0, _debug.logCa
1032
1055
  tag: options.tag
1033
1056
  }, options, context);
1034
1057
 
1035
- if ((0, _helpers.hasChildFields)(field)) {
1058
+ if ((0, _helpers.hasChildFields)(field, {
1059
+ fragmentDefinitions: context.fragmentDefinitions
1060
+ })) {
1036
1061
  if (isEntity) {
1037
1062
  (0, _set2.default)(data, responseDataPath, {
1038
1063
  __cacheKey: `${_core.REQUEST_FIELD_PATHS}::${hashedRequestFieldCacheKey}`
@@ -1044,6 +1069,16 @@ let CacheManager = (_dec = (0, _debug.logCacheQuery)(), _dec2 = (0, _debug.logCa
1044
1069
  }
1045
1070
  }
1046
1071
 
1072
+ _setResponseChunksAwaitingCaching(normalizedResponseData, context) {
1073
+ const responseChunks = this._responseChunksAwaitingCaching.get(context.boxID);
1074
+
1075
+ if (responseChunks) {
1076
+ this._responseChunksAwaitingCaching.set(context.boxID, [...responseChunks, normalizedResponseData]);
1077
+ } else {
1078
+ this._responseChunksAwaitingCaching.set(context.boxID, [normalizedResponseData]);
1079
+ }
1080
+ }
1081
+
1047
1082
  }, ((0, _applyDecoratedDescriptor2.default)(_class.prototype, "_getCacheEntry", [_dec], Object.getOwnPropertyDescriptor(_class.prototype, "_getCacheEntry"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "_setCacheEntry", [_dec2], Object.getOwnPropertyDescriptor(_class.prototype, "_setCacheEntry"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "_setPartialQueryResponse", [_dec3], Object.getOwnPropertyDescriptor(_class.prototype, "_setPartialQueryResponse"), _class.prototype)), _class));
1048
1083
  exports.CacheManager = CacheManager;
1049
1084