Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

graphql-depth-limit

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-depth-limit

Limit the complexity of your GraphQL queries based on depth.

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
595K
decreased by-7.98%
Maintainers
1
Weekly downloads
 
Created

What is graphql-depth-limit?

The graphql-depth-limit npm package is used to limit the depth of GraphQL queries. This is useful for preventing deeply nested queries that can lead to performance issues or denial of service attacks.

What are graphql-depth-limit's main functionalities?

Limit Query Depth

This feature allows you to set a maximum depth for GraphQL queries. In this example, the query depth is limited to 5 levels. If a query exceeds this depth, it will be rejected.

const depthLimit = require('graphql-depth-limit');
const { ApolloServer, gql } = require('apollo-server');

const typeDefs = gql`
  type Query {
    hello: String
  }
`;

const resolvers = {
  Query: {
    hello: () => 'Hello world!',
  },
};

const server = new ApolloServer({
  typeDefs,
  resolvers,
  validationRules: [depthLimit(5)], // Limit query depth to 5
});

server.listen().then(({ url }) => {
  console.log(`🚀 Server ready at ${url}`);
});

Other packages similar to graphql-depth-limit

Keywords

FAQs

Package last updated on 09 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc