happytails.ai

GraphQL Query Cost Estimator

Open GraphQL Query Cost Estimator on Happytails.ai. This view has the same page content and links, with explicit tool capabilities. Read the processing notes before using a tool.

Tool capabilities

{
  "id": "graphql-query-cost-estimator",
  "category": "developer-tools",
  "built": true,
  "requirements": "Accepts an operation of up to 200,000 characters, a schema of up to 1,000,000 characters and variables of up to 200,000 characters. It counts at most 10,000 fields and 64 nesting levels, list sizes from 1 to 10,000 and field costs from 0 to 1,000. The estimate runs in your browser in a background worker. Downloads are a JSON report and a CSV breakdown.",
  "implementation": {
    "fields": [
      {
        "key": "schema",
        "label": "Schema",
        "value": "",
        "type": "textarea",
        "maxLength": 1000000,
        "help": "GraphQL SDL, or introspection JSON with a __schema object. @cost and @listSize directives in SDL are read when enabled below."
      },
      {
        "key": "variables",
        "label": "Variables, optional",
        "value": "",
        "type": "textarea",
        "maxLength": 200000,
        "help": "A JSON object. Whole number variables used as slicing arguments set list sizes."
      },
      {
        "key": "operationName",
        "label": "Operation name, optional",
        "value": "",
        "type": "text",
        "maxLength": 200,
        "help": "Needed when the document has more than one operation."
      },
      {
        "key": "defaultListSize",
        "label": "Default list size",
        "value": "10",
        "type": "text",
        "inputMode": "numeric",
        "maxLength": 5,
        "help": "Whole number from 1 to 10000, used for list fields without a slicing argument or @listSize."
      },
      {
        "key": "slicingArguments",
        "label": "Slicing arguments",
        "value": "first,last,limit",
        "type": "text",
        "maxLength": 500,
        "help": "Comma separated argument names whose value sets a list size. The largest given value is used."
      },
      {
        "key": "objectCost",
        "label": "Cost per object field",
        "value": "1",
        "type": "text",
        "inputMode": "decimal",
        "maxLength": 10,
        "help": "Number from 0 to 1000 for fields that return an object, interface or union."
      },
      {
        "key": "scalarCost",
        "label": "Cost per scalar field",
        "value": "0",
        "type": "text",
        "inputMode": "decimal",
        "maxLength": 10,
        "help": "Number from 0 to 1000 for fields that return a scalar or enum."
      },
      {
        "key": "useDirectives",
        "label": "Use @cost and @listSize from the schema",
        "value": true,
        "type": "checkbox"
      }
    ],
    "registrationFamily": "api-contracts-schemas",
    "codeDirection": "ltr",
    "inputMaxLength": 200000,
    "inputErrorCode": "API_CONTRACTS_SCHEMAS_TOO_LONG_GRAPHQL_QUERY_COST_ESTIMATOR",
    "note": "Runs in your browser in a background worker. Accepts an operation of up to 200000 characters and counts at most 10000 fields.",
    "experience": {
      "automatic": false,
      "single": false,
      "inputMaxLength": 200000,
      "inputMode": "text",
      "label": "GraphQL operation",
      "placeholder": "query { books(first: 20) { title } }",
      "help": "One operation, or several with the operation name set. Fragments are expanded. Up to 200,000 characters. Review the settings before running.",
      "helpParts": [
        "One operation, or several with the operation name set. Fragments are expanded.",
        "Up to 200,000 characters.",
        "Review the settings before running."
      ],
      "action": null
    },
    "mode": "explicit",
    "interactive": false
  },
  "execution": "Browser interface",
  "api": null,
  "browser_agent": {
    "supported": true,
    "name": "run_current_tool",
    "discovery": "WebMCP on the human page in a supporting browser",
    "verification": "See audit/API-AUDIT.md; availability is not verification"
  }
}

Page guide

Estimate how expensive a GraphQL operation is before it reaches your server. Find the deeply nested and multiplied list selections, with every list size assumption written down.

How to use GraphQL Query Cost Estimator
  1. Paste the GraphQL operation in the main box.
  2. Paste the schema as SDL or introspection JSON.
  3. Adjust the default list size, slicing arguments and field costs if your server uses other values.
  4. Run the estimate and review the hotspots, then download the JSON or CSV breakdown.

Useful next steps

Accepts an operation of up to 200,000 characters, a schema of up to 1,000,000 characters and variables of up to 200,000 characters. It counts at most 10,000 fields and 64 nesting levels, list sizes from 1 to 10,000 and field costs from 0 to 1,000. The estimate runs in your browser in a background worker. Downloads are a JSON report and a CSV breakdown.

The cost model

Each selected field has the object or scalar cost for its return type, multiplied by the list sizes above it. The total is the sum over expanded field selections; repeated selections can therefore overestimate merged server execution. __typename is free. This planning model does not execute a server, conditional directives or nested list contents, and is not a server-enforced limit.

List sizes

A list field takes its size from the largest slicing argument, such as first, last or limit. Operation variable defaults and schema argument defaults are used when a value is omitted. Without a slicing value it uses @listSize(assumedSize:) when enabled, then the model default list size. @cost(weight:) replaces a field cost. All derived sizes must be whole numbers from 1 to 10,000, and weights from 0 to 1,000. Invalid operations, variables, bounds and cyclic fragments stop the estimate with a typed error.

Reading the report

The report lists assumptions, the ten most expensive subtrees and the full tree with depth, multiplier, list size, own cost and subtree cost. The CSV has one row per field path. Fragment spreads expand where used; a cyclic fragment is a query validation error rather than a finite cost assumption.