@graphql-mesh/plugin-http-cache 0.1.15 → 0.1.17-alpha-20230314142432-674dfc30e
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 +17 -2
- package/esm/index.js +18 -3
- package/package.json +3 -3
- package/typings/index.d.cts +2 -2
- package/typings/index.d.ts +2 -2
package/cjs/index.js
CHANGED
|
@@ -1,12 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
|
|
4
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
|
5
5
|
const http_cache_semantics_1 = tslib_1.__importDefault(require("http-cache-semantics"));
|
|
6
|
+
const utils_1 = require("@graphql-mesh/utils");
|
|
6
7
|
const fetch_1 = require("@whatwg-node/fetch");
|
|
7
|
-
function useHTTPCache({ cache }) {
|
|
8
|
+
function useHTTPCache({ cache, matches, ignores, }) {
|
|
9
|
+
let matchesPatterns;
|
|
10
|
+
if (matches) {
|
|
11
|
+
matchesPatterns = matches.map(match => new fetch_1.URLPattern(match));
|
|
12
|
+
}
|
|
13
|
+
let ignoresPatterns;
|
|
14
|
+
if (ignores) {
|
|
15
|
+
ignoresPatterns = ignores.map(match => new fetch_1.URLPattern(match));
|
|
16
|
+
}
|
|
8
17
|
return {
|
|
9
18
|
async onFetch({ url, options, fetchFn, setFetchFn }) {
|
|
19
|
+
if (matchesPatterns && !matchesPatterns.some(pattern => pattern.test(url))) {
|
|
20
|
+
return () => { };
|
|
21
|
+
}
|
|
22
|
+
if (ignoresPatterns && ignoresPatterns.some(pattern => pattern.test(url))) {
|
|
23
|
+
return () => { };
|
|
24
|
+
}
|
|
10
25
|
if (options.cache === 'no-cache') {
|
|
11
26
|
return () => { };
|
|
12
27
|
}
|
package/esm/index.js
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
|
2
2
|
import CachePolicy from 'http-cache-semantics';
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { getHeadersObj } from '@graphql-mesh/utils';
|
|
4
|
+
import { Response, URLPattern } from '@whatwg-node/fetch';
|
|
5
|
+
export default function useHTTPCache({ cache, matches, ignores, }) {
|
|
6
|
+
let matchesPatterns;
|
|
7
|
+
if (matches) {
|
|
8
|
+
matchesPatterns = matches.map(match => new URLPattern(match));
|
|
9
|
+
}
|
|
10
|
+
let ignoresPatterns;
|
|
11
|
+
if (ignores) {
|
|
12
|
+
ignoresPatterns = ignores.map(match => new URLPattern(match));
|
|
13
|
+
}
|
|
5
14
|
return {
|
|
6
15
|
async onFetch({ url, options, fetchFn, setFetchFn }) {
|
|
16
|
+
if (matchesPatterns && !matchesPatterns.some(pattern => pattern.test(url))) {
|
|
17
|
+
return () => { };
|
|
18
|
+
}
|
|
19
|
+
if (ignoresPatterns && ignoresPatterns.some(pattern => pattern.test(url))) {
|
|
20
|
+
return () => { };
|
|
21
|
+
}
|
|
7
22
|
if (options.cache === 'no-cache') {
|
|
8
23
|
return () => { };
|
|
9
24
|
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-mesh/plugin-http-cache",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17-alpha-20230314142432-674dfc30e",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"graphql": "*"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@graphql-mesh/types": "0.91.
|
|
10
|
-
"@graphql-mesh/utils": "0.43.
|
|
9
|
+
"@graphql-mesh/types": "0.91.8-alpha-20230314142432-674dfc30e",
|
|
10
|
+
"@graphql-mesh/utils": "0.43.16-alpha-20230314142432-674dfc30e",
|
|
11
11
|
"@whatwg-node/fetch": "0.8.1",
|
|
12
12
|
"http-cache-semantics": "4.1.1",
|
|
13
13
|
"tslib": "^2.4.0"
|
package/typings/index.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { MeshPlugin, MeshPluginOptions } from '@graphql-mesh/types';
|
|
2
|
-
export default function useHTTPCache({ cache }: MeshPluginOptions<
|
|
1
|
+
import { MeshPlugin, MeshPluginOptions, YamlConfig } from '@graphql-mesh/types';
|
|
2
|
+
export default function useHTTPCache({ cache, matches, ignores, }: MeshPluginOptions<YamlConfig.HTTPCachePlugin>): MeshPlugin<{}>;
|
package/typings/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { MeshPlugin, MeshPluginOptions } from '@graphql-mesh/types';
|
|
2
|
-
export default function useHTTPCache({ cache }: MeshPluginOptions<
|
|
1
|
+
import { MeshPlugin, MeshPluginOptions, YamlConfig } from '@graphql-mesh/types';
|
|
2
|
+
export default function useHTTPCache({ cache, matches, ignores, }: MeshPluginOptions<YamlConfig.HTTPCachePlugin>): MeshPlugin<{}>;
|