graphql_​caching

Version: v2025-01-13Includes use: Yes

Behavior name: GraphQL Caching

This behavior configures how to cache GraphQL-based API traffic. Enable caching for your GraphQL API traffic along with allow_post to cache POST responses. To configure REST API traffic use the rapid behavior.

Default behavior

These samples reflect the behavior's default settings. You can use these as is in your configurations or make adjustments based on the behavior's available options.

data "akamai_property_rules_builder" "graphql_caching" {
  rules_v2025_02_18 {
    name     = "GraphQL Caching"
    comments = "Configures how to cache GraphQL-based API traffic."
    behavior {
      graphql_caching {
        enabled                                = true
        cache_responses_with_errors            = false
        advanced                               = ""
        post_request_processing_error_handling = "NO_STORE"
        operations_url_query_parameter_name    = "query"
        operations_json_body_parameter_name    = "query"
      }
    }
  }
}
"behaviors": [
  {
  "name": "graphqlCaching",
  "options": {
    "enabled": true,
    "cacheResponsesWithErrors": false,
    "advanced": "",
    "postRequestProcessingErrorHandling": "NO_STORE",
    "operationsUrlQueryParametername": "query",
    "operationsJsonBodyParametername": "query"
    }
  }
]

Options

Option Description
enabled
Enables GraphQL caching.
cache_responses_with_errors
When enabled, caches responses that include an error field at the top of the response body object. Disable this if your GraphQL server yields temporary errors with success codes in the 2xx range.
post_request_processing_error_handling
Specify what happens if GraphQL query processing fails on POST requests. Value is one of:
  • APPLY_CACHING_BEHAVIOR. If your GraphQL server does not allow mutations and subscriptions, this offloads requests.
  • NO_STORE. Pass requests to the origin.
operations_url_query_parameter_name
Specifies the name of a query parameter that identifies requests as GraphQL queries.
operations_json_body_parameter_name
The name of the JSON body parameter that identifies GraphQL POST requests.