New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@envelop/validation-cache

Package Overview
Dependencies
Maintainers
1
Versions
1587
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@envelop/validation-cache - npm Package Compare versions

Comparing version 4.4.0 to 4.5.0-alpha-18632d3.0

17

cjs/index.js

@@ -6,3 +6,3 @@ "use strict";

const graphql_1 = require("graphql");
const tiny_lru_1 = tslib_1.__importDefault(require("tiny-lru"));
const lru_cache_1 = tslib_1.__importDefault(require("lru-cache"));
const DEFAULT_MAX = 1000;

@@ -12,6 +12,17 @@ const DEFAULT_TTL = 3600000;

const useValidationCache = (pluginOptions = {}) => {
const resultCache = typeof pluginOptions.cache !== 'undefined' ? pluginOptions.cache : (0, tiny_lru_1.default)(DEFAULT_MAX, DEFAULT_TTL);
const resultCache = typeof pluginOptions.cache !== 'undefined'
? pluginOptions.cache
: new lru_cache_1.default({
max: DEFAULT_MAX,
maxAge: DEFAULT_TTL,
});
return {
onSchemaChange() {
resultCache.clear();
var _a, _b;
if (resultCache.reset) {
(_a = resultCache.reset) === null || _a === void 0 ? void 0 : _a.call(resultCache);
}
else if ('clear' in resultCache) {
(_b = resultCache.clear) === null || _b === void 0 ? void 0 : _b.call(resultCache);
}
},

@@ -18,0 +29,0 @@ onParse({ params, extendContext }) {

import { print } from 'graphql';
import lru from 'tiny-lru';
import LRU from 'lru-cache';
const DEFAULT_MAX = 1000;

@@ -7,6 +7,17 @@ const DEFAULT_TTL = 3600000;

export const useValidationCache = (pluginOptions = {}) => {
const resultCache = typeof pluginOptions.cache !== 'undefined' ? pluginOptions.cache : lru(DEFAULT_MAX, DEFAULT_TTL);
const resultCache = typeof pluginOptions.cache !== 'undefined'
? pluginOptions.cache
: new LRU({
max: DEFAULT_MAX,
maxAge: DEFAULT_TTL,
});
return {
onSchemaChange() {
resultCache.clear();
var _a, _b;
if (resultCache.reset) {
(_a = resultCache.reset) === null || _a === void 0 ? void 0 : _a.call(resultCache);
}
else if ('clear' in resultCache) {
(_b = resultCache.clear) === null || _b === void 0 ? void 0 : _b.call(resultCache);
}
},

@@ -13,0 +24,0 @@ onParse({ params, extendContext }) {

4

package.json
{
"name": "@envelop/validation-cache",
"version": "4.4.0",
"version": "4.5.0-alpha-18632d3.0",
"sideEffects": false,

@@ -10,3 +10,3 @@ "peerDependencies": {

"dependencies": {
"tiny-lru": "7.0.6"
"lru-cache": "^6.0.0"
},

@@ -13,0 +13,0 @@ "repository": {

@@ -16,4 +16,4 @@ ## `@envelop/validation-cache`

```ts
import { envelop } from '@envelop/core';
import { useValidationCache } from '@envelop/validation-cache';
import { envelop } from '@envelop/core'
import { useValidationCache } from '@envelop/validation-cache'

@@ -25,5 +25,5 @@ const getEnveloped = envelop({

// options goes here
}),
],
});
})
]
})
```

@@ -30,0 +30,0 @@

import { Plugin } from '@envelop/core';
import { GraphQLError } from 'graphql';
export interface ValidationCache {
/**
* Get a result from the validation cache.
*/
get(key: string): readonly GraphQLError[] | undefined;
/**
* Set a result to the validation cache.
*/
set(key: string, value: readonly GraphQLError[]): void;
clear(): void;
/**
* @deprecated Provide a `reset` implementation instead.
*/
clear?(): void;
/**
* Reset the cache by clearing all entries.
*/
reset?(): void;
}

@@ -8,0 +21,0 @@ export declare type ValidationCacheOptions = {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc