GraphQL Limit Count Configuration
Parameters
See plugin common configurations for configuration options available to all plugins.
-
count—integer | string· optionalValid values: greater than 0
The maximum accumulated GraphQL query cost allowed within a given time interval. Query cost is depth under the default strategy. Required when
rulesis not configured. The value can use built-in variables when configured as a string. -
time_window—integer | string· optionalValid values: greater than 0
The time interval corresponding to the rate limiting
countin seconds. Required whenrulesis not configured. The value can use built-in variables when configured as a string. -
rules—array[object]· optionalAn array of rate-limiting rules that are applied sequentially. Configure either
rulesor the top-levelcountandtime_window, but not both.-
count—integer | string· requiredValid values: greater than 0
The maximum accumulated GraphQL query cost allowed within the rule's
time_window. Query cost is depth under the default strategy. The value can use built-in variables when configured as a string. -
time_window—integer | string· requiredValid values: greater than 0
The time interval corresponding to the rule's
countin seconds. The value can use built-in variables when configured as a string. -
key—string· requiredThe key to count requests by. Supports combinations of built-in variables, with each variable prefixed by a dollar sign (
$). If the key cannot be resolved, the rule is not applied. -
header_prefix—string· optionalPrefix inserted into the rate limiting response headers for this rule. For example,
fooproducesX-foo-RateLimit-Limit,X-foo-RateLimit-Remaining, andX-foo-RateLimit-Reset.
-
-
cost_strategy—string· optional · default:depthValid values:
depth,complexity, ornode_quantifierHow the raw cost of a GraphQL document is computed.
depthcounts the selection nesting depth, which is what this plugin has always done.complexityscores the nodes the query resolves.node_quantifierscores only nodes whose matching cost decoration resolves an argument listed inmul_arguments. If no node has both a matching decoration and a usable quantifier, the document's raw score is0. Forcomplexityandnode_quantifier, the plugin adds0.01, appliesscore_factor, and rounds up before charging the quota. The default factor produces a charged cost of1from a zero raw score; a factor greater than100increases it. Introduced in API7 Enterprise 3.10.6. -
max_cost—number· optional · default:0Valid values: greater than or equal to 0
Reject a document whose charged cost exceeds this value with
403 Forbiddenbefore it reaches the upstream. The request consumes quota before this check.0disables the check and lets the quota alone decide. Introduced in API7 Enterprise 3.10.6. -
score_factor—number· optional · default:1Valid values: greater than 0
Scaling applied before the cost is rounded up, charged against the quota, and compared with
max_cost. Introduced in API7 Enterprise 3.10.6. -
resolve_variables—boolean· optional · default:trueIf true, resolve supplied GraphQL variables, variable defaults declared by the operation, and argument defaults from the upstream schema when computing cost. The default ensures variable-based quantifiers contribute their resolved value. Introduced in API7 Enterprise 3.10.6.
-
introspection_endpoint—string· optionalValid values: starts with
http://orhttps://Endpoint used to introspect the upstream GraphQL schema, which the
complexityandnode_quantifierstrategies need in order to match cost decorations. Derived from the upstream when unset. The result is cached per worker and Service. Introduced in API7 Enterprise 3.10.6. -
introspection_headers—object· optionalHeaders sent on the schema introspection request for an upstream whose introspection endpoint requires credentials. The headers come from the configuration rather than from the request because the introspected schema is cached per worker and Service. When Data Plane data encryption is enabled, this field is encrypted at rest. Introduced in API7 Enterprise 3.10.6.
-
key_type—string· optional · default:varValid values:
var,var_combination, orconstantThe type of key.
If the
key_typeisvar, thekeyis interpreted as a variable.If the
key_typeisvar_combination, thekeyis interpreted as a combination of variables.If the
key_typeisconstant, thekeyis interpreted as a constant. -
key—string· optional · default:remote_addrThe key to count requests by.
If the
key_typeisvar, thekeyis interpreted as a variable. The variable does not need to be prefixed by a dollar sign ($). See built-in variables for available variables.If the
key_typeisvar_combination, thekeyis interpreted as a combination of variables. All variables should be prefixed by dollar signs ($). For example, to configure thekeyto use a combination of two request headerscustom-aandcustom-b, thekeyshould be configured as$http_custom_a $http_custom_b.If the
key_typeisconstant, thekeyis interpreted as a constant value. -
rejected_code—integer· optional · default:503Valid values: between 200 and 599 inclusive
The HTTP status code returned when a request is rejected for exceeding the threshold.
-
rejected_msg—string· optionalValid values: any non-empty string
The response body returned when a request is rejected for exceeding the threshold.
-
policy—string· optional · default:localValid values:
local,redis, orredis-clusterThe policy for rate limiting counter. If it is
local, the counter is stored in memory locally. If it isredis, the counter is stored on a Redis instance. If it isredis-cluster, the counter is stored in a Redis cluster. -
allow_degradation—boolean· optional · default:falseIf true, allow the gateway to continue handling requests without the plugin when the plugin or its dependencies become unavailable.
-
show_limit_quota_header—boolean· optional · default:trueIf true, includes the rate limiting response headers. Specifically:
X-RateLimit-Limitshows the total quota.X-RateLimit-Remainingshows the remaining quota.X-RateLimit-Resetshows the number of seconds until the counter resets.
-
group—string· optionalValid values: non-empty
The
groupID for the plugin, such that routes of the samegroupcan share the same rate limiting counter. -
redis_host—string· optionalThe address of the Redis node. Required when
policyisredis. -
redis_port—integer· optional · default:6379Valid values: greater than or equal to 1
The port of the Redis node when
policyisredis. -
redis_username—string· optionalThe username for Redis if Redis ACL is used. If you use the legacy authentication method
requirepass, configure only theredis_password. Used whenpolicyisredis. -
redis_password—string· optionalThe password of the Redis node when
policyisredisorredis-cluster. -
redis_database—integer· optional · default:0Valid values: greater than or equal to 0
The database number in Redis when
policyisredis. -
redis_ssl—boolean· optional · default:falseIf true, use SSL to connect to Redis when
policyisredis. -
redis_ssl_verify—boolean· optional · default:falseIf true, verify the server SSL certificate when
policyisredis. -
redis_timeout—integer· optional · default:1000Valid values: greater than or equal to 1
The Redis timeout value in milliseconds when
policyisredisorredis-cluster. -
redis_keepalive_timeout—integer· optional · default:10000Valid values: greater than or equal to 1000
Keepalive timeout in milliseconds for Redis when
policyisredisorredis-cluster.This parameter is available in API7 Enterprise from version 3.9.16 on the 3.9 line and from version 3.10.3 on the 3.10 line, and in APISIX from version 3.17.0.
-
redis_keepalive_pool—integer· optional · default:100Valid values: greater than or equal to 1
Keepalive pool size for Redis when
policyisredisorredis-cluster.This parameter is available in API7 Enterprise from version 3.9.16 on the 3.9 line and from version 3.10.3 on the 3.10 line, and in APISIX from version 3.17.0.
-
redis_cluster_nodes—array[string]· optionalThe list of Redis cluster nodes with at least two addresses. Required when
policyisredis-cluster. -
redis_cluster_name—string· optionalThe name of the Redis cluster. Required when
policyisredis-cluster. -
redis_cluster_ssl—boolean· optional · default:falseIf true, use SSL to connect to Redis cluster when
policyisredis-cluster. -
redis_cluster_ssl_verify—boolean· optional · default:falseIf true, verify the server SSL certificate when
policyisredis-cluster.
Plugin Metadata
-
limit_header—string· optional · default:X-RateLimit-LimitDefault response header name for the total rate limit quota. Available in API7 Enterprise from version 3.10.6.
-
remaining_header—string· optional · default:X-RateLimit-RemainingDefault response header name for the remaining rate limit quota. Available in API7 Enterprise from version 3.10.6.
-
reset_header—string· optional · default:X-RateLimit-ResetDefault response header name for the number of seconds until the rate limit counter resets. Available in API7 Enterprise from version 3.10.6.