@envelop/validation-cache
TypeScript icon, indicating that this package has built-in type declarations

7.0.0 • Public • Published

@envelop/validation-cache

This plugins adds simple LRU caching to your validate, to improve performance by caching the validation result.

This plugins improves performance of validating by ~50% (based on benchmarks).

Getting Started

yarn add @envelop/validation-cache

Usage Example

import { execute, parse, specifiedRules, subscribe, validate } from 'graphql'
import { envelop, useEngine } from '@envelop/core'
import { useValidationCache } from '@envelop/validation-cache'

const getEnveloped = envelop({
  plugins: [
    useEngine({ parse, validate, specifiedRules, execute, subscribe }),
    // ... other plugins ...
    useValidationCache({
      // options goes here
    })
  ]
})

API Reference

cache

Set this to pass in a cache instance. By default a new LRU cache is created using default max and ttl.

Dependencies (3)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i @envelop/validation-cache

    Weekly Downloads

    178,977

    Version

    7.0.0

    License

    MIT

    Unpacked Size

    8.63 kB

    Total Files

    8

    Last publish

    Collaborators

    • dotansimha