npm.io
7.1.1 • Published 4 months ago

@envelop/depth-limit

Licence
MIT
Version
7.1.1
Deps
2
Size
5 kB
Vulns
0
Weekly
0
Stars
829

@envelop/depth-limit

This plugins uses graphql-depth-limit in order to limit the depth of executed selection sets (by injecting a new GraphQL validation rule into your execution).

Getting Started

yarn add @envelop/depth-limit

Usage Example

import { execute, parse, specifiedRules, subscribe, validate } from 'graphql'
import { envelop, useEngine } from '@envelop/core'
import { useDepthLimit } from '@envelop/depth-limit'

const getEnveloped = envelop({
  plugins: [
    useEngine({ parse, validate, specifiedRules, execute, subscribe }),
    // ... other plugins ...
    useDepthLimit({
      maxDepth: 10
      // ignore: [ ... ] - you can set this to ignore specific fields or types
    })
  ]
})

Notes

You can find more details here: https://www.npmjs.com/package/graphql-depth-limit#documentation