📊

GraphQL Cost Estimator — Analyze Query Complexity and Depth

Assign custom field weights to a GraphQL schema and calculate the total query complexity score. Paste any GraphQL query, configure per-field costs, and get a per-field breakdown table showing depth, multipliers, and cumulative cost.

API ToolsAPI & Backend
Loading tool...

How to Use GraphQL Cost Estimator — Analyze Query Complexity and Depth

How to Use the GraphQL Query Cost Estimator:

  1. Paste your GraphQL query: Enter any valid GraphQL query into the Query textarea on the left. The tool supports shorthand queries, named queries, mutations, aliases, fragments, inline fragments, and nested selection sets. Use the example buttons (Simple Query, Nested + Args, Social Graph) to load ready-made queries and see how the tool works.

  2. Load a field weight preset: Click one of the three preset buttons above the Field Weights table — REST-like API, Social Graph, or E-Commerce — to load a pre-configured weight table suited to your API type. Each preset includes typical field names and their recommended complexity costs. You can edit any value after loading a preset.

  3. Configure field weights: The Field Weights table maps each field name to a numeric cost. Fields with weight 0 are free (leaf fields like id, name). Fields like users or products get higher weights because they trigger database queries or joins. Use the field name input to match the exact name as it appears in your GraphQL schema. Click Add Field to add more rows, or the trash icon to remove a row.

  4. Set the default weight: The Default Weight controls the cost assigned to any field not explicitly listed in the table. Set it to 0 if you only want to score specific fields, or to a small positive number (like 1 or 2) to count every unspecified field toward the total.

  5. Understand argument multipliers: If a field has a count-style argument — limit, first, last, count, pageSize, size, or take — the estimator multiplies that field's base weight by the argument value. For example, users(limit: 10) with a weight of 10 contributes 100 to the total score. This models the real cost of fetching large result sets.

  6. Click Calculate Cost: Press the Calculate Cost button to parse the query and compute the total complexity score. The tool builds a recursive AST from your query, resolves aliases and inline fragments, and walks the full field tree.

  7. Read the total score and rating: The large score card shows the total complexity number along with a rating — Low (≤50), Medium (≤200), High (≤500), or Very High (>500). Use these thresholds as starting points and adjust them to match your API's capacity and rate limits.

  8. Review the per-field breakdown table: The breakdown table shows every field in the query with its depth (indented visually), base weight, argument multiplier, and individual cost. Rows with high costs are easy to spot. Use this to identify which fields are driving the complexity and decide whether to reduce their weights, add caching, or impose argument limits.

  9. Iterate on weights: Adjust field weights and re-run the calculation to find the right balance. You can set critical root fields (search, recommendations) much higher than scalar leaf fields. Fields that always return a single object (user, order) can have lower weights than list fields (products, posts) that scale with argument values.

  10. Export or document thresholds: Copy the total score value to set a threshold in your GraphQL server middleware. Tools like graphql-cost-analysis, graphql-query-complexity, or GraphQL Shield use similar field-weight schemes. You can translate the weights and thresholds from this tool directly into your server configuration.

Common Use Cases:

  • API rate limiting: Set a maximum complexity threshold (e.g., 500) and reject queries that exceed it
  • Cost-aware caching: Prioritize caching for high-cost fields and queries
  • Developer education: Show engineers which queries are expensive before they ship
  • Security hardening: Prevent deeply nested or large-result queries from overloading your database
  • Schema design reviews: Evaluate the cost implications of new field additions before release
  • CI checks: Integrate complexity scoring into pull request checks for GraphQL schema changes
  • Client SDK guidelines: Document complexity budgets so client teams know which queries to avoid

Tips and Best Practices:

  • Start with a preset that matches your API type, then adjust individual field weights
  • Set scalar leaf fields (id, name, email, createdAt) to 0 — they add no measurable database cost
  • Give list-returning fields (users, posts, products) high base weights since they scale with result size
  • Use argument multipliers for pagination — a field with limit=100 is 100× more expensive than limit=1
  • A good starting threshold for a typical API is 200–500 total complexity points
  • Treat the score as relative, not absolute — calibrate it against your real server performance
  • Fields backed by full-text search or aggregation (search, analytics) should have the highest weights
  • Nested list fields multiply — posts inside users inside feed compounds the cost exponentially
  • Set up your production GraphQL server (Apollo, Yoga, Envelop) to enforce the same thresholds
  • Re-run analysis after every schema change that adds new list fields or expensive resolvers

Frequently Asked Questions

Most Viewed Tools

📺

Screen Size Converter — Diagonal Dimension Tool

7,054 views

Calculate screen width and height from diagonal size and aspect ratio. Convert between inches and centimeters for displays, TVs, and monitors with instant dimension calculations.

Use Tool →
🖨️

DPI Calculator — Print Resolution Tool

5,270 views

Calculate DPI (dots per inch), image dimensions, and print sizes. Convert between pixels and physical dimensions for printing and displays.

Use Tool →
🔐

TOTP Code Generator — 2FA Testing Tool

3,827 views

Generate time-based one-time passwords from a TOTP secret key. Enter your base32 secret, choose a period and digit length, and get the current and next codes with a live countdown timer. Useful for testing and debugging 2FA integrations.

Use Tool →
{}

JSONL Formatter — Line-by-Line Validator

3,742 views

Format, validate, and inspect JSON Lines (JSONL) and NDJSON files. Validates each line individually, reports parse errors by line number, outputs compact JSONL or a pretty-print preview, and lets you download the cleaned file.

Use Tool →
🔑

Password Entropy Calculator — Crack Time Estimator

3,729 views

Calculate the information-theoretic bit entropy of any password or API key. Detects character set pools automatically, shows the total number of possible combinations, and estimates crack time across five attack scenarios from rate-limited web logins to GPU cracking clusters.

Use Tool →
{ }

JSON to Zod — Schema Generator

3,610 views

Generate Zod validation schema code from a JSON sample object. Infers z.string(), z.number(), z.boolean(), z.array(), z.object(), and z.null() types automatically. Handles nested objects, arrays of objects with optional field detection, and outputs copy-ready TypeScript with import and z.infer type alias.

Use Tool →
🔐

TLS Cipher Suite Checker — Strength Analyzer

3,456 views

Check TLS protocol version compatibility and cipher suite strength ratings against current best practices. Supports IANA and OpenSSL cipher names — rates each suite as Strong, Weak, or Deprecated and explains why.

Use Tool →
⏱️

Seconds to Time Converter — HH:MM:SS Formatter

3,337 views

Convert seconds to HH:MM:SS time format instantly with precise calculations and easy-to-read formatting.

Use Tool →

Related API & Backend Tools

🗄️

API Mock Server Config Generator — Build Instant Mock Endpoints Online

Paste API route definitions to instantly generate JSON configuration files for json-server, Mockoon, and Prism mock servers. Define routes as METHOD /path lines and get ready-to-use config with realistic sample data.

Use Tool →
🔄

Postman to OpenAPI Converter — Spec Migration Tool

Convert Postman Collection v2.1 JSON to OpenAPI 3.0 specification format. Upload or paste your collection, and get a downloadable openapi.yaml or openapi.json with mapped paths, parameters, request bodies, and example responses.

Use Tool →

GraphQL Subscription Builder — Generate WebSocket Payloads and Client Queries

Build GraphQL subscription query strings and generate WebSocket connection code snippets for Apollo Client, urql, and graphql-ws. Define your operation name, variables, and selection fields visually, then copy the ready-to-use code.

Use Tool →
🗄️

API Mock Data Generator — Realistic JSON Builder

Generate structured, realistic mock data for API endpoint testing. Define fields with names and types — UUID, name, email, integer, enum, date, and more — set how many rows you need, and export as a JSON array, NDJSON, or CSV. All generation runs entirely in your browser with no data sent to any server.

Use Tool →
🔍

API Error Decoder — Fix Suggestion Tool

Decode HTTP status codes and OAuth 2.0 error strings with plain-English descriptions, common causes, and actionable fix suggestions. Covers every HTTP 1xx–5xx status code and all standard OAuth 2.0 error responses. Results appear instantly as you type.

Use Tool →
🔑

JWT Token Validator — Signature Verifier

Decode and validate JWT tokens instantly in your browser. Inspect header and payload claims, check expiry, and verify HMAC signatures (HS256/HS384/HS512). Free and private.

Use Tool →
🔐

OAuth Token Validator — JWT & OIDC Decoder

Validate and inspect OAuth tokens in your browser. Decode JWT access tokens and ID tokens to view claims, scopes, and expiry. Analyse opaque tokens for entropy and format. Free and private.

Use Tool →
🔐

OAuth PKCE Generator — Create Secure Code Verifiers and Challenges

Generate RFC 7636 PKCE code verifier and challenge pairs for OAuth 2.0 authorization code flow. Choose verifier length, get the SHA-256 code challenge, and see exactly where each value goes in the auth URL and token exchange request.

Use Tool →

Share Your Feedback

Help us improve this tool by sharing your experience

We will only use this to follow up on your feedback