Back office ops · Production

Whatnot builds a daily AI subagent to eliminate GraphQL schema bloat via automated cleanup PRs

The problem

Whatnot's GraphQL schema had accumulated over 2,600 unused fields left behind from old features, making the schema more complex and harder to navigate and introducing risk of accidentally reusing old, unoptimized endpoints. Manual cleanup was impractical because making breaking changes to remove fields is tricky, time-consuming, and risks breaking client experiences.

First attempt

Static analysis alone could not reliably identify safe-to-delete fields because older mobile app versions may still call queries removed from the main branch, and admin tooling dashboards execute queries entirely outside the primary repositories.

Workflow diagram · grounded in source
1
Traffic pipeline identifies unused fields
validation
“We built a pipeline that parsed 30 days of queries, deduplicated traffic by unique query hashes, and traversed the schema's Abstract Syntax Tree (AST) to record every field "visit."”
2
Daily GitHub Action triggers cleanup
trigger
“We then wired this process into a GitHub Action that runs on a regular schedule. Each day, the action automatically triggers the cleanup agent, picks an unused field, and removes it one at a time.”
3
AI subagent removes unused field
ai_action
“we built an AI subagent to do it for us. The agent was designed to follow the same steps an engineer would, only faster and completely running in the background.”
4
PR created with context and assignment
output
“Every PR clearly explains what the agent did, links to validation data, and provides a safety checklist for reviewers. Since each field in our schema already has a defined code owner, the agent automatically assigns the PR to the right t…”
5
Code owner reviews and approves
human_review
“code owners can simply skim the diff, verify the context, and approve it while getting their morning coffee”
Reported outcome

A process that once took an engineer one to two hours per field now takes minutes to review, with the subagent having safely removed 24 of approximately 200 unused root fields at a cost of roughly $1–3 per run in LLM credits, and most PRs requiring no edits at all.

Reported metrics
unused GraphQL fields discoveredover 2,600
Unused root queries and mutationsnearly 200
Unused root fields safely removed24 of ~200
Engineer time per field cleanupfrom one to two hours per field to minutes to review
Show all 6 reported metrics
unused GraphQL fields discoveredover 2,600
unused root queries and mutationsnearly 200
unused root fields safely removed24 of ~200
engineer time per field cleanupfrom one to two hours per field to minutes to review
cost per run in LLM credits$1–3
PRs requiring manual editsonly three
Reported stack
GitHub ActionLLMAbstract Syntax Tree (AST)
Source
https://medium.com/whatnot-engineering/eliminating-graphql-schema-bloat-with-ai-so-you-dont-have-to-5f6ae84d0ee1
Read source ↗

Frequently asked questions

What did this team achieve with this AI workflow?

A process that once took an engineer one to two hours per field now takes minutes to review, with the subagent having safely removed 24 of approximately 200 unused root fields at a cost of roughly $1–3 per run in LLM…

What tools did this team use?

GitHub Action, LLM, Abstract Syntax Tree (AST).

What results were reported?

unused GraphQL fields discovered: over 2,600; Unused root queries and mutations: nearly 200; Unused root fields safely removed: 24 of ~200; Engineer time per field cleanup: from one to two hours per field to minutes to review (source-reported, not independently verified).

What failed first in this deployment?

Static analysis alone could not reliably identify safe-to-delete fields because older mobile app versions may still call queries removed from the main branch, and admin tooling dashboards execute queries entirely outs…

How is this back office ops AI workflow structured?

Traffic pipeline identifies unused fields → Daily GitHub Action triggers cleanup → AI subagent removes unused field → PR created with context and assignment → Code owner reviews and approves.