Query Complexity Limits

A complexity score is calculated for each request that is made to the GraphQL content delivery API. This score is based on the types of fields being requested, and the number of attributes contained within them.

There are four types of fields which can be requested, with each one contributing a different amount to the overall complexity score:

  • Root Query (Complexity Score: 50)
  • Relationship (Complexity Score: 10)
  • Item (Complexity Score: 5)
  • Field (Complexity Score: 1)
    • An exception to this rule is the total field within a collection query. This field creates additional work under the hood and so carries a complexity score of 10.

You can use the x-lexascms-query-complexity response header to determine the complexity score that was calculated for any given request.

The maximum complexity score that is allowed for a single request is 5000. In the event that this is exceeded, an error will be returned.

As an example, the following query has a total complexity score of 292

query {
  ###
  ### Score: 62
  ###
  bookItem(id: "1234") { # 50 (Root Query)
    title                # 1  (Field)
    author {             # 10 (Relationship)
      name               # 1  (Field)
    }
  }
  
  ###
  ### Score: 230
  ###
  bookCollection(limit: 10) { # 50  (Root Query)
    total                     # 10  (Total Field)
    items {                   # 50  (10 Items)
      title                   # 10  (Field x 10 Items)
      author {                # 100 (Relationship x 10 Items)
        name                  # 10  (Field x 10 Items)
      }
    }
  }
}
Integrates with your favourite tools and frameworks

© 2022 Status200 Ltd.