Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@envelop/validation-cache

Package Overview
Dependencies
Maintainers
1
Versions
1528
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 1.1.0-alpha-d7e3951.0 to 2.0.0

9

index.d.ts
import { Plugin } from '@envelop/types';
import { GraphQLError } from 'graphql';
export interface ValidationCache {
get(key: string): readonly GraphQLError[] | undefined;
set(key: string, value: readonly GraphQLError[]): void;
clear(): void;
}
export declare type ValidationCacheOptions = {
max?: number;
ttl?: number;
cache?: ValidationCache;
};
export declare const useValidationCache: (pluginOptions?: ValidationCacheOptions) => Plugin;

@@ -13,5 +13,3 @@ 'use strict';

const useValidationCache = (pluginOptions = {}) => {
const max = typeof pluginOptions.max === 'number' ? pluginOptions.max : DEFAULT_MAX;
const ttl = typeof pluginOptions.ttl === 'number' ? pluginOptions.ttl : DEFAULT_TTL;
const resultCache = lru(max, ttl);
const resultCache = typeof pluginOptions.cache !== 'undefined' ? pluginOptions.cache : lru(DEFAULT_MAX, DEFAULT_TTL);
return {

@@ -23,7 +21,5 @@ onSchemaChange() {

const key = graphql.print(params.documentAST);
if (resultCache.get(key)) {
const errors = resultCache.get(key);
if (errors) {
setResult(errors);
}
const cachedResult = resultCache.get(key);
if (cachedResult !== undefined) {
setResult(cachedResult);
}

@@ -30,0 +26,0 @@ return ({ result }) => {

{
"name": "@envelop/validation-cache",
"version": "1.1.0-alpha-d7e3951.0",
"version": "2.0.0",
"sideEffects": false,
"peerDependencies": {
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
"graphql": "^14.0.0 || ^15.0.0"
},

@@ -8,0 +8,0 @@ "dependencies": {

@@ -31,8 +31,4 @@ ## `@envelop/validation-cache`

#### `max`
#### `cache`
Set this to configure your maximum amount of items in the LRU cache. The default is `1000`.
#### `ttl`
Set this to configure the TTL (time to live) of items in the LRU cache. The default is `3600000`.
Set this to pass in a cache instance. By default a new LRU cache is created using default `max` and `ttl`.

Sorry, the diff of this file is not supported yet

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