@graphql-box/cache-manager 3.2.1 → 3.4.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/lib/browser/index.js +1 -1
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/production.analysis.txt +30 -34
- package/lib/main/consts/index.js +1 -7
- package/lib/main/consts/index.js.map +1 -1
- package/lib/main/debug/log-cache-entry/index.js +3 -3
- package/lib/main/debug/log-cache-entry/index.js.map +1 -1
- package/lib/main/debug/log-cache-query/index.js +3 -3
- package/lib/main/debug/log-cache-query/index.js.map +1 -1
- package/lib/main/debug/log-partial-compiled/index.js +4 -4
- package/lib/main/debug/log-partial-compiled/index.js.map +1 -1
- package/lib/main/index.js +0 -23
- package/lib/main/index.js.map +1 -1
- package/lib/main/main/index.js +5 -5
- package/lib/main/main/index.js.map +1 -1
- package/lib/module/consts/index.js +0 -3
- package/lib/module/consts/index.js.map +1 -1
- package/lib/module/debug/log-cache-entry/index.js +3 -3
- package/lib/module/debug/log-cache-entry/index.js.map +1 -1
- package/lib/module/debug/log-cache-query/index.js +3 -3
- package/lib/module/debug/log-cache-query/index.js.map +1 -1
- package/lib/module/debug/log-partial-compiled/index.js +4 -4
- package/lib/module/debug/log-partial-compiled/index.js.map +1 -1
- package/lib/module/index.js +0 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/main/index.js +5 -5
- package/lib/module/main/index.js.map +1 -1
- package/lib/types/consts/index.d.ts +0 -3
- package/lib/types/consts/index.d.ts.map +1 -1
- package/lib/types/debug/log-cache-entry/index.d.ts.map +1 -1
- package/lib/types/debug/log-cache-query/index.d.ts.map +1 -1
- package/lib/types/debug/log-partial-compiled/index.d.ts.map +1 -1
- package/lib/types/defs/index.d.ts +1 -5
- package/lib/types/defs/index.d.ts.map +1 -1
- package/lib/types/index.d.ts +0 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/main/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/__snapshots__/index.test.ts.snap +1082 -1082
- package/src/consts/index.ts +0 -4
- package/src/debug/log-cache-entry/index.ts +3 -4
- package/src/debug/log-cache-query/index.ts +3 -4
- package/src/debug/log-partial-compiled/index.ts +4 -5
- package/src/defs/index.ts +1 -6
- package/src/index.ts +0 -1
- package/src/main/index.ts +6 -6
package/src/consts/index.ts
CHANGED
|
@@ -4,7 +4,3 @@ export const NO_CACHE = "noCache";
|
|
|
4
4
|
|
|
5
5
|
export const HEADER_CACHE_CONTROL = "cache-control";
|
|
6
6
|
export const HEADER_NO_CACHE = "no-cache";
|
|
7
|
-
|
|
8
|
-
export const CACHE_ENTRY_ADDED = "cache_entry_added";
|
|
9
|
-
export const CACHE_ENTRY_QUERIED = "cache_entry_queried";
|
|
10
|
-
export const PARTIAL_QUERY_COMPILED = "partial_query_compiled";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { RequestContext } from "@graphql-box/core";
|
|
2
|
-
import { CACHE_ENTRY_ADDED } from "../../consts";
|
|
1
|
+
import { CACHE_ENTRY_ADDED, RequestContext } from "@graphql-box/core";
|
|
3
2
|
|
|
4
3
|
export default function logCacheEntry() {
|
|
5
4
|
return (
|
|
@@ -32,14 +31,14 @@ export default function logCacheEntry() {
|
|
|
32
31
|
cachemapOptions: args[3],
|
|
33
32
|
cacheType: args[0],
|
|
34
33
|
context: otherContext,
|
|
35
|
-
hash: args[1],
|
|
36
34
|
options: args[4],
|
|
35
|
+
requestHash: args[1],
|
|
37
36
|
stats: { duration, endTime, startTime },
|
|
38
37
|
value: args[2],
|
|
39
38
|
...(requestFieldCacheKey ? { decryptedCacheKey: requestFieldCacheKey } : {}),
|
|
40
39
|
};
|
|
41
40
|
|
|
42
|
-
debugManager.
|
|
41
|
+
debugManager.log(CACHE_ENTRY_ADDED, payload);
|
|
43
42
|
});
|
|
44
43
|
};
|
|
45
44
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { RequestContext } from "@graphql-box/core";
|
|
2
|
-
import { CACHE_ENTRY_QUERIED } from "../../consts";
|
|
1
|
+
import { CACHE_ENTRY_QUERIED, RequestContext } from "@graphql-box/core";
|
|
3
2
|
|
|
4
3
|
export default function logCacheQuery() {
|
|
5
4
|
return (
|
|
@@ -31,14 +30,14 @@ export default function logCacheQuery() {
|
|
|
31
30
|
const payload = {
|
|
32
31
|
cacheType: args[0],
|
|
33
32
|
context: otherContext,
|
|
34
|
-
hash: args[1],
|
|
35
33
|
options: args[2],
|
|
34
|
+
requestHash: args[1],
|
|
36
35
|
result,
|
|
37
36
|
stats: { duration, endTime, startTime },
|
|
38
37
|
...(requestFieldCacheKey ? { decryptedCacheKey: requestFieldCacheKey } : {}),
|
|
39
38
|
};
|
|
40
39
|
|
|
41
|
-
debugManager.
|
|
40
|
+
debugManager.log(CACHE_ENTRY_QUERIED, payload);
|
|
42
41
|
});
|
|
43
42
|
} catch (error) {
|
|
44
43
|
return Promise.reject(error);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { RequestContext } from "@graphql-box/core";
|
|
2
|
-
import { PARTIAL_QUERY_COMPILED } from "../../consts";
|
|
1
|
+
import { PARTIAL_QUERY_COMPILED, RequestContext } from "@graphql-box/core";
|
|
3
2
|
|
|
4
3
|
export default function logPartialCompiled() {
|
|
5
4
|
return (
|
|
@@ -26,11 +25,11 @@ export default function logPartialCompiled() {
|
|
|
26
25
|
const duration = endTime - startTime;
|
|
27
26
|
resolve();
|
|
28
27
|
|
|
29
|
-
debugManager.
|
|
28
|
+
debugManager.log(PARTIAL_QUERY_COMPILED, {
|
|
30
29
|
context: otherContext,
|
|
31
|
-
hash: args[0],
|
|
32
30
|
options: args[2],
|
|
33
|
-
|
|
31
|
+
requestHash: args[0],
|
|
32
|
+
result: args[1],
|
|
34
33
|
stats: { duration, endTime, startTime },
|
|
35
34
|
});
|
|
36
35
|
});
|
package/src/defs/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Cachemap
|
|
1
|
+
import Cachemap from "@cachemap/core";
|
|
2
2
|
import { Metadata } from "@cachemap/types";
|
|
3
3
|
import {
|
|
4
4
|
CacheMetadata,
|
|
@@ -159,11 +159,6 @@ export interface QueryResponseCacheEntry {
|
|
|
159
159
|
data: PlainObjectMap;
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
export interface CachemapOptions {
|
|
163
|
-
cacheHeaders: CacheHeaders;
|
|
164
|
-
tag?: any;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
162
|
export interface CacheManagerDef {
|
|
168
163
|
cache: Cachemap;
|
|
169
164
|
analyzeQuery(requestData: RequestData, options: RequestOptions, context: RequestContext): Promise<AnalyzeQueryResult>;
|
package/src/index.ts
CHANGED
package/src/main/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ import Cachemap from "@cachemap/core";
|
|
|
2
2
|
import {
|
|
3
3
|
CacheMetadata,
|
|
4
4
|
CacheTypes,
|
|
5
|
+
CachemapOptions,
|
|
5
6
|
DATA_ENTITIES,
|
|
6
7
|
FieldTypeInfo,
|
|
7
8
|
PlainObjectMap,
|
|
@@ -43,7 +44,6 @@ import {
|
|
|
43
44
|
CacheManagerInit,
|
|
44
45
|
CachedAncestorFieldData,
|
|
45
46
|
CachedResponseData,
|
|
46
|
-
CachemapOptions,
|
|
47
47
|
CheckCacheEntryResult,
|
|
48
48
|
ClientOptions,
|
|
49
49
|
ConstructorOptions,
|
|
@@ -906,10 +906,10 @@ export class CacheManager implements CacheManagerDef {
|
|
|
906
906
|
context: CacheManagerContext,
|
|
907
907
|
) {
|
|
908
908
|
const responseChunks = this._responseChunksAwaitingCaching.get(
|
|
909
|
-
context.
|
|
909
|
+
context.requestID,
|
|
910
910
|
) as RawResponseDataWithMaybeCacheMetadata[];
|
|
911
911
|
|
|
912
|
-
this._responseChunksAwaitingCaching.delete(context.
|
|
912
|
+
this._responseChunksAwaitingCaching.delete(context.requestID);
|
|
913
913
|
return mergeResponseDataSets([...responseChunks, normalizedResponseData]);
|
|
914
914
|
}
|
|
915
915
|
|
|
@@ -1170,12 +1170,12 @@ export class CacheManager implements CacheManagerDef {
|
|
|
1170
1170
|
normalizedResponseData: RawResponseDataWithMaybeCacheMetadata,
|
|
1171
1171
|
context: CacheManagerContext,
|
|
1172
1172
|
) {
|
|
1173
|
-
const responseChunks = this._responseChunksAwaitingCaching.get(context.
|
|
1173
|
+
const responseChunks = this._responseChunksAwaitingCaching.get(context.requestID);
|
|
1174
1174
|
|
|
1175
1175
|
if (responseChunks) {
|
|
1176
|
-
this._responseChunksAwaitingCaching.set(context.
|
|
1176
|
+
this._responseChunksAwaitingCaching.set(context.requestID, [...responseChunks, normalizedResponseData]);
|
|
1177
1177
|
} else {
|
|
1178
|
-
this._responseChunksAwaitingCaching.set(context.
|
|
1178
|
+
this._responseChunksAwaitingCaching.set(context.requestID, [normalizedResponseData]);
|
|
1179
1179
|
}
|
|
1180
1180
|
}
|
|
1181
1181
|
}
|