@graphql-box/cache-manager 2.1.0 → 2.1.4
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 +21 -11
- package/lib/main/helpers/deriveOpCacheability.js +46 -0
- package/lib/main/helpers/deriveOpCacheability.js.map +1 -0
- package/lib/main/main/index.js +12 -7
- package/lib/main/main/index.js.map +1 -1
- package/lib/module/helpers/deriveOpCacheability.js +32 -0
- package/lib/module/helpers/deriveOpCacheability.js.map +1 -0
- package/lib/module/main/index.js +12 -8
- package/lib/module/main/index.js.map +1 -1
- package/lib/types/helpers/deriveOpCacheability.d.ts +10 -0
- package/lib/types/helpers/deriveOpCacheability.d.ts.map +1 -0
- package/lib/types/main/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/helpers/deriveOpCacheability.ts +32 -0
- package/src/index.test.ts +25 -0
- package/src/main/index.ts +15 -5
package/src/main/index.ts
CHANGED
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
import Cacheability from "cacheability";
|
|
37
37
|
import { FieldNode, print } from "graphql";
|
|
38
38
|
import { cloneDeep, get, isArray, isNumber, isObjectLike, isPlainObject, isUndefined, set, unset } from "lodash";
|
|
39
|
-
import { CACHE_CONTROL,
|
|
39
|
+
import { CACHE_CONTROL, HEADER_NO_CACHE, METADATA, NO_CACHE } from "../consts";
|
|
40
40
|
import { logCacheEntry, logCacheQuery, logPartialCompiled } from "../debug";
|
|
41
41
|
import {
|
|
42
42
|
AnalyzeQueryResult,
|
|
@@ -66,6 +66,7 @@ import {
|
|
|
66
66
|
TypeNames,
|
|
67
67
|
UserOptions,
|
|
68
68
|
} from "../defs";
|
|
69
|
+
import deriveOpCacheability from "../helpers/deriveOpCacheability";
|
|
69
70
|
|
|
70
71
|
export class CacheManager implements CacheManagerDef {
|
|
71
72
|
public static async init(options: InitOptions): Promise<CacheManager> {
|
|
@@ -101,7 +102,7 @@ export class CacheManager implements CacheManagerDef {
|
|
|
101
102
|
CacheManager._getFieldDataFromAncestor(requestFieldPathData, propNameOrIndex);
|
|
102
103
|
|
|
103
104
|
const typeNames = {
|
|
104
|
-
dataTypeName: dataEntityData
|
|
105
|
+
dataTypeName: dataEntityData?.__typename || requestFieldPathData?.__typename,
|
|
105
106
|
fieldTypeName: typeName,
|
|
106
107
|
};
|
|
107
108
|
|
|
@@ -556,10 +557,19 @@ export class CacheManager implements CacheManagerDef {
|
|
|
556
557
|
{ operation }: RequestContext,
|
|
557
558
|
): CacheMetadata {
|
|
558
559
|
const cacheMetadata = new Map();
|
|
559
|
-
|
|
560
|
-
const cacheability =
|
|
560
|
+
|
|
561
|
+
const cacheability = deriveOpCacheability({
|
|
562
|
+
_cacheMetadata,
|
|
563
|
+
fallback: this._fallbackOperationCacheability,
|
|
564
|
+
headers,
|
|
565
|
+
});
|
|
566
|
+
|
|
561
567
|
cacheMetadata.set(operation, cacheability);
|
|
562
|
-
|
|
568
|
+
|
|
569
|
+
if (_cacheMetadata) {
|
|
570
|
+
rehydrateCacheMetadata(_cacheMetadata, cacheMetadata);
|
|
571
|
+
}
|
|
572
|
+
|
|
563
573
|
return cacheMetadata;
|
|
564
574
|
}
|
|
565
575
|
|