@graphql-mesh/transform-cache 1.0.0-alpha-20230523153644-760d1fa28 → 1.0.0-alpha-20230523154127-518d8667d

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/cjs/index.js CHANGED
@@ -11,12 +11,11 @@ class CacheTransform {
11
11
  this.shouldWaitLocal = {};
12
12
  }
13
13
  transformSchema(schema) {
14
- var _a;
15
14
  const { config, cache } = this.options;
16
15
  const sourceResolvers = (0, utils_1.extractResolvers)(schema);
17
16
  const compositions = {};
18
17
  for (const cacheItem of config) {
19
- const effectingOperations = ((_a = cacheItem.invalidate) === null || _a === void 0 ? void 0 : _a.effectingOperations) || [];
18
+ const effectingOperations = cacheItem.invalidate?.effectingOperations || [];
20
19
  for (const { operation, matchKey } of effectingOperations) {
21
20
  compositions[operation] = originalResolver => async (root, args, context, info) => {
22
21
  const result = await originalResolver(root, args, context, info);
@@ -30,7 +29,6 @@ class CacheTransform {
30
29
  };
31
30
  }
32
31
  compositions[cacheItem.field] = originalResolver => async (root, args, context, info) => {
33
- var _a, _b;
34
32
  const cacheKey = (0, compute_cache_key_js_1.computeCacheKey)({
35
33
  keyStr: cacheItem.cacheKey,
36
34
  args,
@@ -50,12 +48,12 @@ class CacheTransform {
50
48
  try {
51
49
  const result = await originalResolver(root, args, context, info);
52
50
  await cache.set(cacheKey, result, {
53
- ttl: (_a = cacheItem.invalidate) === null || _a === void 0 ? void 0 : _a.ttl,
51
+ ttl: cacheItem.invalidate?.ttl,
54
52
  });
55
53
  // do not await setting the cache here, otherwise we would delay returnig the result unnecessarily
56
54
  // instead await as part of shouldWait cleanup
57
55
  const setCachePromise = this.options.cache.set(cacheKey, result, {
58
- ttl: (_b = cacheItem.invalidate) === null || _b === void 0 ? void 0 : _b.ttl,
56
+ ttl: cacheItem.invalidate?.ttl,
59
57
  });
60
58
  // do not wait for cleanup to complete
61
59
  this.cleanupShouldWait({
package/esm/index.js CHANGED
@@ -9,12 +9,11 @@ export default class CacheTransform {
9
9
  this.shouldWaitLocal = {};
10
10
  }
11
11
  transformSchema(schema) {
12
- var _a;
13
12
  const { config, cache } = this.options;
14
13
  const sourceResolvers = extractResolvers(schema);
15
14
  const compositions = {};
16
15
  for (const cacheItem of config) {
17
- const effectingOperations = ((_a = cacheItem.invalidate) === null || _a === void 0 ? void 0 : _a.effectingOperations) || [];
16
+ const effectingOperations = cacheItem.invalidate?.effectingOperations || [];
18
17
  for (const { operation, matchKey } of effectingOperations) {
19
18
  compositions[operation] = originalResolver => async (root, args, context, info) => {
20
19
  const result = await originalResolver(root, args, context, info);
@@ -28,7 +27,6 @@ export default class CacheTransform {
28
27
  };
29
28
  }
30
29
  compositions[cacheItem.field] = originalResolver => async (root, args, context, info) => {
31
- var _a, _b;
32
30
  const cacheKey = computeCacheKey({
33
31
  keyStr: cacheItem.cacheKey,
34
32
  args,
@@ -48,12 +46,12 @@ export default class CacheTransform {
48
46
  try {
49
47
  const result = await originalResolver(root, args, context, info);
50
48
  await cache.set(cacheKey, result, {
51
- ttl: (_a = cacheItem.invalidate) === null || _a === void 0 ? void 0 : _a.ttl,
49
+ ttl: cacheItem.invalidate?.ttl,
52
50
  });
53
51
  // do not await setting the cache here, otherwise we would delay returnig the result unnecessarily
54
52
  // instead await as part of shouldWait cleanup
55
53
  const setCachePromise = this.options.cache.set(cacheKey, result, {
56
- ttl: (_b = cacheItem.invalidate) === null || _b === void 0 ? void 0 : _b.ttl,
54
+ ttl: cacheItem.invalidate?.ttl,
57
55
  });
58
56
  // do not wait for cleanup to complete
59
57
  this.cleanupShouldWait({
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@graphql-mesh/transform-cache",
3
- "version": "1.0.0-alpha-20230523153644-760d1fa28",
3
+ "version": "1.0.0-alpha-20230523154127-518d8667d",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
- "@graphql-mesh/cross-helpers": "0.4.0-alpha-20230523153644-760d1fa28",
7
- "@graphql-mesh/types": "1.0.0-alpha-20230523153644-760d1fa28",
8
- "@graphql-mesh/utils": "1.0.0-alpha-20230523153644-760d1fa28",
6
+ "@graphql-mesh/cross-helpers": "0.4.0-alpha-20230523154127-518d8667d",
7
+ "@graphql-mesh/types": "1.0.0-alpha-20230523154127-518d8667d",
8
+ "@graphql-mesh/utils": "1.0.0-alpha-20230523154127-518d8667d",
9
9
  "@graphql-tools/utils": "^9.2.1",
10
10
  "graphql": "*",
11
11
  "tslib": "^2.4.0"
12
12
  },
13
13
  "dependencies": {
14
- "@graphql-mesh/string-interpolation": "0.5.0-alpha-20230523153644-760d1fa28",
14
+ "@graphql-mesh/string-interpolation": "0.5.0-alpha-20230523154127-518d8667d",
15
15
  "@graphql-tools/resolvers-composition": "^6.5.18",
16
16
  "@graphql-tools/schema": "^9.0.18",
17
17
  "dayjs": "^1.11.7"
@@ -22,6 +22,9 @@
22
22
  "directory": "packages/transforms/cache"
23
23
  },
24
24
  "license": "MIT",
25
+ "engines": {
26
+ "node": ">=16.0.0"
27
+ },
25
28
  "main": "cjs/index.js",
26
29
  "module": "esm/index.js",
27
30
  "typings": "typings/index.d.ts",