GraphQL API

GraphQL API

Latest Poppulo platform GraphQL API

Complexity Limiting

Cost Analysis

Cost analysis is the process of analysing the complexity of query fields and setting a cost value on each one. Each query will have a complexity limit. This limit will restrict retrieval of all available fields in one query.

Complexity limit

Graphql allows for deeply nested or expensive queries. A limit is necessary to prevent a denial-of-service attack. This kind of attack can be caused by a malicious actor or by an unintentionally large query. The query complexity limit, and the individual field costs will be viewable in time within the Graphql API Reference section.

Expensive example query

This is an example of a circular dependency between the continent and countries types.

{
  continents {
    countries {
      continent {
        countries {
          continent {
            countries {
              name
            }
          }
        }
      }
    }
  }
}

The complexity limit restricts unnecessarily large queries like this one.

Complexity limit exceeded Error

Status Code: 422 Unprocessable Entity
Error message: Query is too complex: $QueryCost. Maximum allowed complexity: $QueryLimit

Next steps

Rate Limiting