@envelop/validation-cache
Version:
This plugins adds simple LRU caching to your `validate`, to improve performance by caching the validation result.
39 lines (28 loc) • 810 B
Markdown
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).
```
yarn add @envelop/validation-cache
```
```ts
import { parse, validate, execute, subscribe } from 'graphql'
import { envelop } from '@envelop/core'
import { useValidationCache } from '@envelop/validation-cache'
const getEnveloped = envelop({
parse,
validate,
execute,
subscribe,
plugins: [
// ... other plugins ...
useValidationCache({
// options goes here
})
]
})
```
Set this to pass in a cache instance. By default a new LRU cache is created using default `max` and `ttl`.