Skip to content
This repository has been archived by the owner on Mar 20, 2023. It is now read-only.

depth-limit #771

Open
kingrupam opened this issue Aug 11, 2021 · 1 comment
Open

depth-limit #771

kingrupam opened this issue Aug 11, 2021 · 1 comment

Comments

@kingrupam
Copy link

how to Limit query depth using express-graphql

@notrab
Copy link

notrab commented Aug 18, 2021

@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)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants