express-graphql icon indicating copy to clipboard operation
express-graphql copied to clipboard

depth-limit

Open kingrupam opened this issue 4 years ago • 1 comments

how to Limit query depth using express-graphql

kingrupam avatar Aug 11 '21 19:08 kingrupam

@kingrupam something like the following should do it:

const depthLimit = require('graphql-depth-limit')
const express = require('express')
const graphqlHTTP = require('express-graphql')

const app = express()

const schema = `...`

app.use('/graphql', graphqlHTTP((req, res) => ({
  schema,
  validationRules: [ depthLimit(7) ]
})))

app.listen(4000)

notrab avatar Aug 18 '21 18:08 notrab