@envelop/validation-cache 5.0.4 → 5.0.5-alpha-20221216195722-efa72eac
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 +8 -1
- package/esm/index.js +8 -1
- package/package.json +1 -1
package/cjs/index.js
CHANGED
|
@@ -27,7 +27,14 @@ const useValidationCache = (pluginOptions = {}) => {
|
|
|
27
27
|
extendContext({ [rawDocumentSymbol]: params.source.toString() });
|
|
28
28
|
},
|
|
29
29
|
onValidate({ params, context, setResult }) {
|
|
30
|
-
|
|
30
|
+
let ruleKey = '';
|
|
31
|
+
if (Array.isArray(params.rules)) {
|
|
32
|
+
// Note: We could also order them... but that might be too much
|
|
33
|
+
for (const rule of params.rules) {
|
|
34
|
+
ruleKey = ruleKey + rule.name;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const key = ruleKey + (context[rawDocumentSymbol] ?? (0, graphql_1.print)(params.documentAST));
|
|
31
38
|
const cachedResult = resultCache.get(key);
|
|
32
39
|
if (cachedResult !== undefined) {
|
|
33
40
|
setResult(cachedResult);
|
package/esm/index.js
CHANGED
|
@@ -23,7 +23,14 @@ export const useValidationCache = (pluginOptions = {}) => {
|
|
|
23
23
|
extendContext({ [rawDocumentSymbol]: params.source.toString() });
|
|
24
24
|
},
|
|
25
25
|
onValidate({ params, context, setResult }) {
|
|
26
|
-
|
|
26
|
+
let ruleKey = '';
|
|
27
|
+
if (Array.isArray(params.rules)) {
|
|
28
|
+
// Note: We could also order them... but that might be too much
|
|
29
|
+
for (const rule of params.rules) {
|
|
30
|
+
ruleKey = ruleKey + rule.name;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const key = ruleKey + (context[rawDocumentSymbol] ?? print(params.documentAST));
|
|
27
34
|
const cachedResult = resultCache.get(key);
|
|
28
35
|
if (cachedResult !== undefined) {
|
|
29
36
|
setResult(cachedResult);
|