AI-Powered Automated GraphQL Schema Cleanup

whatnot · E-commerce · 2025 · source Agentic: yes · promotional bias: med · source-backed · extracted with prompt 0.5.4 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: GraphQL schema maintenance

Whatnot needed to remove unused GraphQL fields safely across multiple clients without asking engineers to spend hours manually tracing each field and cleanup path.

Constraints:

Architecture

Whatnot turned GraphQL cleanup into a traffic-evidence pipeline: real query logs and schema traversal identify unused fields, a daily GitHub Action asks an AI agent to remove one field, and PRs carry validation data plus code-owner review.

Diagram confidence: reconstructed (reconstructed from prose).

flowchart LR
  graphql-traffic-logs["GraphQL traffic logs"]
  schema-ast-traversal["Schema AST traversal"]
  unused-field-detector["Unused-field detector"]
  github-action-scheduler["GitHub Action scheduler"]
  cleanup-agent["Cleanup agent"]
  validation-data-links["Validation data links"]
  pull-request["Pull request"]
  code-owner-review["Code owner review"]
  graphql-traffic-logs --> unused-field-detector
  schema-ast-traversal --> unused-field-detector
  unused-field-detector --> github-action-scheduler
  github-action-scheduler --> cleanup-agent
  schema-ast-traversal --> cleanup-agent
  cleanup-agent --> pull-request
  validation-data-links --> pull-request
  validation-data-links --> code-owner-review
  pull-request --> code-owner-review
  code-owner-review --> graphql-traffic-logs
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
GraphQL traffic logs Record real request shapes across backend, mobile, web, and admin clients. Unused-field detector
Schema AST traversal Maps fields, resolvers, and schema structure for safe cleanup. Unused-field detector, Cleanup agent
Unused-field detector Identifies fields not requested during the chosen traffic window. GitHub Action scheduler
GitHub Action scheduler Runs daily cleanup jobs one field at a time. Cleanup agent
Cleanup agent Removes schema fields, resolvers, dead code, and tests. Pull request
Validation data links Attach traffic evidence and safety checklist to every PR. Pull request, Code owner review
Pull request Carries one cleanup change for review. Code owner review
Code owner review Human review gate for risky schema removals. GraphQL traffic logs

Data flow

Traffic logs prove which fields are unused, the detector selects one candidate, and the cleanup agent edits schema, resolver, dead code, and tests before opening a validated PR.

3 supporting quotes
“To get a truly reliable picture, we turned to real traffic data. Every GraphQL request that hits our backend is logged, including the full query shape.”article, stated
“remove the field from the schema, remove the resolver definition and any now-dead code, and clean up tests.”article, stated
“Every PR clearly explains what the agent did, links to validation data, and provides a safety checklist for reviewers.”article, stated

Why this architecture

The architecture relies on real traffic because static code search misses old mobile versions and admin tooling outside primary repositories.

“older versions of our mobile apps may still call queries that have long been removed from the main branch, and admin tooling dashboards often execute queries entirely outside our primary repositories.”article, stated

Models used: AI coding subagent

Scale

Alternatives considered (roads not taken)

One-time broad schema cleanup

Rejected because: Whatnot chose a daily background process that removes one field at a time to manage risk.

“This turns schema maintenance into an ongoing background process, not a one-time cleanup project.”article, implied

Define unused by repository references alone

Rejected because: The team used a 30-day real-traffic window to avoid deleting fields still used by deployed clients.

“We decided to define a field as “unused” if it hadn’t been requested in the last 30 days, a reasonable window to prevent overdeletion.”article, stated

Deleting many unused fields in one automated change

Rejected because: The daily action removes one field at a time so schema maintenance remains a background process.

“This turns schema maintenance into an ongoing background process, not a one-time cleanup project.”article, stated

Trusting the AI cleanup proposal without reviewer evidence

Rejected because: Each PR includes validation data and a safety checklist for human reviewers.

“Every PR clearly explains what the agent did, links to validation data, and provides a safety checklist for reviewers.”article, stated

Patterns

observability-tracing (data)

The system uses real GraphQL request logs rather than static analysis alone to decide which fields are unused.

“To get a truly reliable picture, we turned to real traffic data. Every GraphQL request that hits our backend is logged, including the full query shape.”article, stated

tool-use-orchestration (orchestration)

The AI subagent follows the same code-editing steps as an engineer, removing schema fields, resolvers, dead code, and tests.

“remove the field from the schema, remove the resolver definition and any now-dead code, and clean up tests.”article, stated

human-in-the-loop-gate (safety)

The agent opens PRs with validation data and a safety checklist, then routes them to code owners for review.

“Every PR clearly explains what the agent did, links to validation data, and provides a safety checklist for reviewers.”article, stated

batch-offline-processing (workflow)

A scheduled GitHub Action runs the cleanup process repeatedly in the background, one field per day/run, instead of a one-time migration.

“Each day, the action automatically triggers the cleanup agent, picks an unused field, and removes it one at a time.”article, stated

Tradeoffs

How aggressively to delete unused fields.

Chose one unused field per scheduled agent run over large batch removal of many fields at once.

Rationale: Small PRs reduce review risk and make ownership, validation, and rollback reasoning easier.

“This turns schema maintenance into an ongoing background process, not a one-time cleanup project.”article, stated

How to define unused.

Chose not requested in the last 30 days over pure repository reference absence.

Rationale: A traffic window better covers deployed mobile versions and external admin queries, while the fixed window limits overdeletion risk.

“We decided to define a field as “unused” if it hadn’t been requested in the last 30 days, a reasonable window to prevent overdeletion.”article, stated

Gotchas (what bit them)

Static code search was not enough to prove a GraphQL field was unused.

Root cause: Mobile app versions and admin dashboards can execute queries outside the current primary repositories.

Resolution: Define unused based on 30 days of production GraphQL request traffic and schema field visits.

“older versions of our mobile apps may still call queries that have long been removed from the main branch, and admin tooling dashboards often execute queries entirely outside our primary repositories.”article, implied

Automation proposed unsafe deletions where client-side tooling was incomplete.

Root cause: The web repository lacked the same unused GraphQL fragment linters as mobile clients.

Resolution: Improve environmental linters and code-cleanliness automation so agents can operate safely.

“we found the agent proposing deletions for fields that were technically still referenced in client code, particularly on the web.”article, stated

Evaluation

Whatnot reports field counts, removal counts, edit rates, and LLM cost from early runs.

Metrics: over 2,600 unused fields · nearly 200 unused root queries and mutations · 24 of about 200 unused root fields removed · $1-3 per run · only three PRs needed manual edits

“The data showed over 2,600 unused fields, including nearly 200 root queries and mutations.”article, stated

Outcomes

Whatnot engineering article; production codebase maintenance but early-run results only.

“So far, our subagent has safely removed 24 of ~200 unused root fields. Each run costs roughly $1–3 in LLM credits.”article, stated