@graphql-mesh/plugin-response-cache 1.0.0-alpha-3fc47d119.0 → 1.0.0-alpha-20230420181317-a95037648
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/{index.js → cjs/index.js} +28 -23
- package/cjs/package.json +1 -0
- package/{index.mjs → esm/index.js} +19 -15
- package/package.json +27 -20
- package/typings/index.d.cts +3 -0
- package/{index.d.ts → typings/index.d.ts} +1 -1
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
function getDocumentString(args) {
|
|
9
|
-
return utils.printWithCache(args.document);
|
|
10
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const cross_helpers_1 = require("@graphql-mesh/cross-helpers");
|
|
4
|
+
const string_interpolation_1 = require("@graphql-mesh/string-interpolation");
|
|
5
|
+
const plugin_response_cache_1 = require("@graphql-yoga/plugin-response-cache");
|
|
6
|
+
const defaultBuildResponseCacheKey = async (params) => (0, string_interpolation_1.hashObject)(params);
|
|
11
7
|
function generateSessionIdFactory(sessionIdDef) {
|
|
8
|
+
if (sessionIdDef == null) {
|
|
9
|
+
return function voidSession() {
|
|
10
|
+
return null;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
12
13
|
return function session(context) {
|
|
13
|
-
return
|
|
14
|
+
return string_interpolation_1.stringInterpolator.parse(sessionIdDef, {
|
|
14
15
|
context,
|
|
15
|
-
env:
|
|
16
|
+
env: cross_helpers_1.process.env,
|
|
16
17
|
});
|
|
17
18
|
};
|
|
18
19
|
}
|
|
@@ -24,12 +25,12 @@ function generateEnabledFactory(ifDef) {
|
|
|
24
25
|
}
|
|
25
26
|
function getBuildResponseCacheKey(cacheKeyDef) {
|
|
26
27
|
return function buildResponseCacheKey(cacheKeyParameters) {
|
|
27
|
-
let cacheKey =
|
|
28
|
+
let cacheKey = string_interpolation_1.stringInterpolator.parse(cacheKeyDef, {
|
|
28
29
|
...cacheKeyParameters,
|
|
29
|
-
env:
|
|
30
|
+
env: cross_helpers_1.process.env,
|
|
30
31
|
});
|
|
31
32
|
if (!cacheKey) {
|
|
32
|
-
cacheKey =
|
|
33
|
+
cacheKey = defaultBuildResponseCacheKey(cacheKeyParameters);
|
|
33
34
|
}
|
|
34
35
|
return cacheKey;
|
|
35
36
|
};
|
|
@@ -87,21 +88,25 @@ function useMeshResponseCache(options) {
|
|
|
87
88
|
}
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
|
-
return
|
|
91
|
+
return (0, plugin_response_cache_1.useResponseCache)({
|
|
91
92
|
ttl: options.ttl,
|
|
92
93
|
ignoredTypes: options.ignoredTypes,
|
|
93
94
|
idFields: options.idFields,
|
|
94
95
|
invalidateViaMutation: options.invalidateViaMutation,
|
|
95
|
-
includeExtensionMetadata: options.includeExtensionMetadata
|
|
96
|
+
includeExtensionMetadata: options.includeExtensionMetadata != null
|
|
97
|
+
? options.includeExtensionMetadata
|
|
98
|
+
: cross_helpers_1.process.env.DEBUG === '1',
|
|
96
99
|
ttlPerType,
|
|
97
100
|
ttlPerSchemaCoordinate,
|
|
98
|
-
|
|
99
|
-
session: options.sessionId ? generateSessionIdFactory(options.sessionId) : undefined,
|
|
101
|
+
session: generateSessionIdFactory(options.sessionId),
|
|
100
102
|
enabled: options.if ? generateEnabledFactory(options.if) : undefined,
|
|
101
|
-
buildResponseCacheKey: options.cacheKey
|
|
102
|
-
|
|
103
|
+
buildResponseCacheKey: options.cacheKey
|
|
104
|
+
? getBuildResponseCacheKey(options.cacheKey)
|
|
105
|
+
: undefined,
|
|
106
|
+
shouldCacheResult: options.shouldCacheResult
|
|
107
|
+
? getShouldCacheResult(options.shouldCacheResult)
|
|
108
|
+
: undefined,
|
|
103
109
|
cache: getCacheForResponseCache(options.cache),
|
|
104
110
|
});
|
|
105
111
|
}
|
|
106
|
-
|
|
107
|
-
module.exports = useMeshResponseCache;
|
|
112
|
+
exports.default = useMeshResponseCache;
|
package/cjs/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { useResponseCache, defaultBuildResponseCacheKey } from '@envelop/response-cache';
|
|
2
|
-
import { stringInterpolator } from '@graphql-mesh/string-interpolation';
|
|
3
1
|
import { process } from '@graphql-mesh/cross-helpers';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return printWithCache(args.document);
|
|
8
|
-
}
|
|
2
|
+
import { hashObject, stringInterpolator } from '@graphql-mesh/string-interpolation';
|
|
3
|
+
import { useResponseCache } from '@graphql-yoga/plugin-response-cache';
|
|
4
|
+
const defaultBuildResponseCacheKey = async (params) => hashObject(params);
|
|
9
5
|
function generateSessionIdFactory(sessionIdDef) {
|
|
6
|
+
if (sessionIdDef == null) {
|
|
7
|
+
return function voidSession() {
|
|
8
|
+
return null;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
10
11
|
return function session(context) {
|
|
11
12
|
return stringInterpolator.parse(sessionIdDef, {
|
|
12
13
|
context,
|
|
@@ -72,7 +73,7 @@ function getCacheForResponseCache(meshCache) {
|
|
|
72
73
|
},
|
|
73
74
|
};
|
|
74
75
|
}
|
|
75
|
-
function useMeshResponseCache(options) {
|
|
76
|
+
export default function useMeshResponseCache(options) {
|
|
76
77
|
const ttlPerType = {};
|
|
77
78
|
const ttlPerSchemaCoordinate = {};
|
|
78
79
|
if (options.ttlPerCoordinate) {
|
|
@@ -90,16 +91,19 @@ function useMeshResponseCache(options) {
|
|
|
90
91
|
ignoredTypes: options.ignoredTypes,
|
|
91
92
|
idFields: options.idFields,
|
|
92
93
|
invalidateViaMutation: options.invalidateViaMutation,
|
|
93
|
-
includeExtensionMetadata: options.includeExtensionMetadata
|
|
94
|
+
includeExtensionMetadata: options.includeExtensionMetadata != null
|
|
95
|
+
? options.includeExtensionMetadata
|
|
96
|
+
: process.env.DEBUG === '1',
|
|
94
97
|
ttlPerType,
|
|
95
98
|
ttlPerSchemaCoordinate,
|
|
96
|
-
|
|
97
|
-
session: options.sessionId ? generateSessionIdFactory(options.sessionId) : undefined,
|
|
99
|
+
session: generateSessionIdFactory(options.sessionId),
|
|
98
100
|
enabled: options.if ? generateEnabledFactory(options.if) : undefined,
|
|
99
|
-
buildResponseCacheKey: options.cacheKey
|
|
100
|
-
|
|
101
|
+
buildResponseCacheKey: options.cacheKey
|
|
102
|
+
? getBuildResponseCacheKey(options.cacheKey)
|
|
103
|
+
: undefined,
|
|
104
|
+
shouldCacheResult: options.shouldCacheResult
|
|
105
|
+
? getShouldCacheResult(options.shouldCacheResult)
|
|
106
|
+
: undefined,
|
|
101
107
|
cache: getCacheForResponseCache(options.cache),
|
|
102
108
|
});
|
|
103
109
|
}
|
|
104
|
-
|
|
105
|
-
export default useMeshResponseCache;
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-mesh/plugin-response-cache",
|
|
3
|
-
"version": "1.0.0-alpha-
|
|
3
|
+
"version": "1.0.0-alpha-20230420181317-a95037648",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"@graphql-mesh/
|
|
7
|
-
"@graphql-mesh/
|
|
8
|
-
"graphql": "
|
|
6
|
+
"@graphql-mesh/cross-helpers": "^0.3.4",
|
|
7
|
+
"@graphql-mesh/types": "1.0.0-alpha-20230420181317-a95037648",
|
|
8
|
+
"@graphql-mesh/utils": "1.0.0-alpha-20230420181317-a95037648",
|
|
9
|
+
"graphql": "*",
|
|
10
|
+
"tslib": "^2.4.0"
|
|
9
11
|
},
|
|
10
12
|
"dependencies": {
|
|
11
|
-
"@envelop/core": "^
|
|
12
|
-
"@
|
|
13
|
-
"@graphql-
|
|
14
|
-
"@graphql-mesh/string-interpolation": "0.3.0",
|
|
15
|
-
"tslib": "^2.4.0"
|
|
13
|
+
"@envelop/core": "^3.0.0",
|
|
14
|
+
"@graphql-mesh/string-interpolation": "0.4.4",
|
|
15
|
+
"@graphql-yoga/plugin-response-cache": "1.9.0"
|
|
16
16
|
},
|
|
17
17
|
"repository": {
|
|
18
18
|
"type": "git",
|
|
@@ -20,21 +20,28 @@
|
|
|
20
20
|
"directory": "packages/plugins/response-cache"
|
|
21
21
|
},
|
|
22
22
|
"license": "MIT",
|
|
23
|
-
"main": "index.js",
|
|
24
|
-
"module": "index.
|
|
25
|
-
"typings": "index.d.ts",
|
|
23
|
+
"main": "cjs/index.js",
|
|
24
|
+
"module": "esm/index.js",
|
|
25
|
+
"typings": "typings/index.d.ts",
|
|
26
26
|
"typescript": {
|
|
27
|
-
"definition": "index.d.ts"
|
|
27
|
+
"definition": "typings/index.d.ts"
|
|
28
28
|
},
|
|
29
|
+
"type": "module",
|
|
29
30
|
"exports": {
|
|
30
31
|
".": {
|
|
31
|
-
"require":
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
|
|
32
|
+
"require": {
|
|
33
|
+
"types": "./typings/index.d.cts",
|
|
34
|
+
"default": "./cjs/index.js"
|
|
35
|
+
},
|
|
36
|
+
"import": {
|
|
37
|
+
"types": "./typings/index.d.ts",
|
|
38
|
+
"default": "./esm/index.js"
|
|
39
|
+
},
|
|
40
|
+
"default": {
|
|
41
|
+
"types": "./typings/index.d.ts",
|
|
42
|
+
"default": "./esm/index.js"
|
|
43
|
+
}
|
|
37
44
|
},
|
|
38
45
|
"./package.json": "./package.json"
|
|
39
46
|
}
|
|
40
|
-
}
|
|
47
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { MeshPluginOptions, YamlConfig } from '@graphql-mesh/types';
|
|
2
1
|
import { Plugin } from '@envelop/core';
|
|
2
|
+
import { MeshPluginOptions, YamlConfig } from '@graphql-mesh/types';
|
|
3
3
|
export default function useMeshResponseCache(options: MeshPluginOptions<YamlConfig.ResponseCacheConfig>): Plugin;
|