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-alpha-3936561.0 to 4.4.0-alpha-aca44e1.0

8

index.d.ts

@@ -1,8 +0,6 @@

import { Plugin } from '@envelop/core';
import { BasicCache, Plugin } from '@envelop/core';
import { GraphQLError } from 'graphql';
export interface ValidationCache {
get(key: string): readonly GraphQLError[] | undefined;
set(key: string, value: readonly GraphQLError[]): void;
export declare type ValidationCache = BasicCache<readonly GraphQLError[]> & {
clear(): void;
}
};
export declare type ValidationCacheOptions = {

@@ -9,0 +7,0 @@ cache?: ValidationCache;

@@ -8,5 +8,5 @@ 'use strict';

const rawDocumentSymbol = Symbol('rawDocument');
const rawDocumentMap = new WeakMap();
const useValidationCache = (pluginOptions = {}) => {
const resultCache = typeof pluginOptions.cache !== 'undefined' ? pluginOptions.cache : core.getInMemoryLRUCache();
const resultCache = pluginOptions.cache != null ? pluginOptions.cache : core.getInMemoryLRUCache();
return {

@@ -16,11 +16,13 @@ onSchemaChange() {

},
onParse({ params, extendContext }) {
extendContext({ [rawDocumentSymbol]: params.source.toString() });
onParse({ params, context }) {
var _a;
rawDocumentMap.set(context, core.isSourceObject(params.source) ? params.source.body : (_a = params.source) === null || _a === void 0 ? void 0 : _a.toString());
},
onValidate({ params, context, setResult }) {
var _a;
const key = (_a = context[rawDocumentSymbol]) !== null && _a !== void 0 ? _a : graphql.print(params.documentAST);
const key = (_a = rawDocumentMap.get(context)) !== null && _a !== void 0 ? _a : graphql.print(params.documentAST);
const cachedResult = resultCache.get(key);
if (cachedResult !== undefined) {
setResult(cachedResult);
return;
}

@@ -27,0 +29,0 @@ return ({ result }) => {

{
"name": "@envelop/validation-cache",
"version": "4.4.0-alpha-3936561.0",
"version": "4.4.0-alpha-aca44e1.0",
"sideEffects": false,
"peerDependencies": {
"@envelop/core": "2.4.0-alpha-3936561.0",
"@envelop/core": "2.4.0-alpha-aca44e1.0",
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"

@@ -8,0 +8,0 @@ },

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