@graphql-mesh/plugin-http-cache 0.104.7 → 0.104.8

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
@@ -5,6 +5,7 @@ const tslib_1 = require("tslib");
5
5
  const http_cache_semantics_1 = tslib_1.__importDefault(require("http-cache-semantics"));
6
6
  const utils_1 = require("@graphql-mesh/utils");
7
7
  const fetch_1 = require("@whatwg-node/fetch");
8
+ const promise_helpers_1 = require("@whatwg-node/promise-helpers");
8
9
  function useHTTPCache({ cache, matches, ignores, logger, }) {
9
10
  if (!cache) {
10
11
  throw new Error('HTTP Cache plugin requires a cache instance');
@@ -58,8 +59,7 @@ function useHTTPCache({ cache, matches, ignores, logger, }) {
58
59
  url,
59
60
  headers: (0, utils_1.getHeadersObj)(options.headers),
60
61
  };
61
- const cacheEntry$ = cache.get(cacheKey);
62
- return (0, utils_1.mapMaybePromise)(cacheEntry$, function handleCacheEntry(cacheEntry) {
62
+ return (0, promise_helpers_1.handleMaybePromise)(() => cache.get(cacheKey), function handleCacheEntry(cacheEntry) {
63
63
  let policy;
64
64
  function returnCachedResponse(endResponse) {
65
65
  return endResponse(new ResponseCtor(cacheEntry.body, {
@@ -91,7 +91,7 @@ function useHTTPCache({ cache, matches, ignores, logger, }) {
91
91
  headers: (0, utils_1.getHeadersObj)(response.headers),
92
92
  };
93
93
  function updateCacheEntry() {
94
- const store$ = (0, utils_1.mapMaybePromise)(body$, body => {
94
+ const store$ = (0, promise_helpers_1.handleMaybePromise)(() => body$, body => {
95
95
  const ttl = policy.timeToLive();
96
96
  if (ttl) {
97
97
  pluginLogger?.debug(`TTL: ${ttl}ms`);
package/esm/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import CachePolicy from 'http-cache-semantics';
2
- import { getHeadersObj, mapMaybePromise } from '@graphql-mesh/utils';
2
+ import { getHeadersObj } from '@graphql-mesh/utils';
3
3
  import { Response as DefaultResponseCtor, URLPattern as DefaultURLPatternCtor, } from '@whatwg-node/fetch';
4
+ import { handleMaybePromise } from '@whatwg-node/promise-helpers';
4
5
  export default function useHTTPCache({ cache, matches, ignores, logger, }) {
5
6
  if (!cache) {
6
7
  throw new Error('HTTP Cache plugin requires a cache instance');
@@ -54,8 +55,7 @@ export default function useHTTPCache({ cache, matches, ignores, logger, }) {
54
55
  url,
55
56
  headers: getHeadersObj(options.headers),
56
57
  };
57
- const cacheEntry$ = cache.get(cacheKey);
58
- return mapMaybePromise(cacheEntry$, function handleCacheEntry(cacheEntry) {
58
+ return handleMaybePromise(() => cache.get(cacheKey), function handleCacheEntry(cacheEntry) {
59
59
  let policy;
60
60
  function returnCachedResponse(endResponse) {
61
61
  return endResponse(new ResponseCtor(cacheEntry.body, {
@@ -87,7 +87,7 @@ export default function useHTTPCache({ cache, matches, ignores, logger, }) {
87
87
  headers: getHeadersObj(response.headers),
88
88
  };
89
89
  function updateCacheEntry() {
90
- const store$ = mapMaybePromise(body$, body => {
90
+ const store$ = handleMaybePromise(() => body$, body => {
91
91
  const ttl = policy.timeToLive();
92
92
  if (ttl) {
93
93
  pluginLogger?.debug(`TTL: ${ttl}ms`);
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@graphql-mesh/plugin-http-cache",
3
- "version": "0.104.7",
3
+ "version": "0.104.8",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
6
  "graphql": "*"
7
7
  },
8
8
  "dependencies": {
9
- "@graphql-mesh/types": "^0.103.19",
10
- "@graphql-mesh/utils": "^0.103.19",
9
+ "@graphql-mesh/types": "^0.103.20",
10
+ "@graphql-mesh/utils": "^0.103.20",
11
11
  "@whatwg-node/fetch": "^0.10.4",
12
+ "@whatwg-node/promise-helpers": "^1.0.0",
12
13
  "http-cache-semantics": "^4.1.1",
13
14
  "tslib": "^2.4.0"
14
15
  },