On this page

query_planner

The query_planner configuration block allows you to fine-tune the behavior of the router’s query planning phase. The query planner is a critical component that analyzes incoming GraphQL operations and creates an efficient execution plan for fetching data from the required subgraphs.

These settings act as important safeguards to protect your router and subgraphs from overly complex or malicious queries that could degrade performance.

Options

allow_expose

  • Type: boolean
  • Default: false

The allow_expose flag is a debugging tool that controls whether the generated query plan can be exposed in the GraphQL response.

When set to true, if an incoming request includes the HTTP header hive-expose-query-plan: true, the router will add the detailed query plan to the extensions field of the GraphQL response.

This should be disabled in production environments to avoid leaking implementation details about your graph.

timeout

  • Type: string
  • Default: "10s"

The timeout property sets a maximum duration for the query planner to generate an execution plan. This is a crucial defense against “denial of service” attacks that use deeply nested or complex queries to exhaust server resources.

If the planning phase for a query takes longer than this specified duration, the process is cancelled, and an error is returned to the client. The value should be a string representing a duration, for example, "5s" or "500ms".

arguments_to_variables

  • Type: boolean
  • Default: true

Rewrites hard-coded field argument values in planned subgraph operations into variables. For example, { user(id: "1") { name } } is sent to the subgraph as an operation with an id variable. Operations that differ only in argument values can then share a query-plan cache entry, reducing cache churn when clients issue similar queries with many different values.

The subgraph receives these values as variables rather than inline literals. Custom scalars are therefore parsed with the subgraph’s parseValue instead of parseLiteral. Set this option to false if a subgraph’s custom scalar handles those differently.

Example

This example configuration enables query plan exposure for debugging, sets a stricter timeout, and keeps argument values inline when sent to subgraphs.

router.config.yaml
query_planner:
  allow_expose: true
  timeout: "5s"
  arguments_to_variables: false