Node.js Libraries for Protecting GraphQL APIs
- By : Mydatahack
- Category : Node.js, Web Technologies
- Tags: Apollo, GraphQL, Node.js
If you want to look beyond authentication and authorisation to protect your GraphQL APIs, there are a few Node.js libraries you can have a look at.
1. Implementing Rate-Limiting Protection
Rate-limiting will prevent too many requests coming in at once. For this, you can start with looking at graphql-rate-limit-directive. It not only does rate-limiting per query, but also can do rate-limiting per user.
2. Implementing Depth-Limiting Protection
We can protect our APIs against nested queries by implementing depth-limiting protection. For this, you can check out graphql-depth-limit.
3. Calculate query complexity and limit queries by complexity cost
There is a cool library to calculate your query complexity and limit queries by complexity cost. Implementing this is quite simple with the library called, graphql-validation-complexity.