Optimize GraphQL input queries for
Shopify Functions

Built specifically for modern Shopify Functions and Wasm workflows. Reduce Shopify Function payload overhead before runtime issues occur. Helps developers minimize unnecessary query complexity, designed specifically for the Shopify Scripts → Functions migration era.

input.graphql — QueryTrim Analysis
Before — 38/30 complexity ❌
vendor
sku
title
metafield(namespace:
"custom", key: "x") {
value
}
tags
productType
id
After — 18/30 complexity ✓
 
 
title
 
 
 
 
tags
 
id
Before 38 / 30 pts
After 18 / 30 pts
Reduction −20 pts (52%)
Status ✓ Safe to Deploy
What It Analyzes

All 11 Shopify Functions constraints.
Enforced automatically.

QueryTrim applies every documented Shopify Functions runtime constraint as a static analysis rule. No guesswork, no mocks.

📊
Complexity Scoring
Implements Shopify's exact scoring formula — scalar=1pt, object=1+children, list=children×size. Warns at 25/30, errors at 30+. A score over 30 means Shopify will reject your extension at upload.
📋
Unbounded List Detection
Detects list fields (cart.lines, deliveryGroups, paymentMethods) missing first: or last: arguments. These scale linearly with cart size and can exhaust your Wasm instruction budget on large orders.
🔬
Deep Nesting Analysis
Measures max nesting depth per branch. Flags fields beyond depth 5 — each additional level multiplies Wasm instruction cost, pushing total execution time past the 5ms target.
Javy/QuickJS Overhead
JavaScript and TypeScript Shopify Functions run through QuickJS via Javy. Object fields with more than 5 children increase heap deserialization cost. QueryTrim flags these and recommends focused sub-selections.
🔄
Concurrency Risk
Up to 25 Shopify Functions can execute simultaneously on a single checkout. A query using >80% of the complexity budget creates compound instruction exhaustion risk under real concurrency load.
Smart Wasm Trimmer
QueryTrim's intelligent trimmer generates an optimized version of your query. It safely protects your metafields (business logic) while aggressively stripping UI bloat to save Wasm memory. A side-by-side diff shows exactly what changed. (Pro)
How It Works

Zero setup. Works inside
Shopify Admin.

QueryTrim installs as an Admin UI Extension — no separate app to open, no separate login, no external dashboard.

1
Install QueryTrim — takes 15 seconds
Click Install from the Shopify App Store. QueryTrim adds itself to the "More actions" menu on your Product and Order detail pages. No configuration required.
2
Find your input.graphql file
In your Shopify app project, open your function's directory. Every Shopify Function has an input.graphql file that defines the data your function receives at runtime.
your-app/ └── extensions/ └── your-function/ └── input.graphql ← copy this file's contents
3
Open QueryTrim in Shopify Admin
Navigate to any Product page in your Shopify Admin. Click the "Apps" puzzle piece icon in the top right corner (do not use the old "More actions" menu). Select QueryTrim. The analyzer opens as a modal — no page navigation, no tab switching.
4
Paste your query and click Analyze
Paste the full contents of your input.graphql file and click "Analyze Query". Analysis runs in under 100ms — it is pure static AST traversal with no network calls.
5
Review issues and apply the fix
QueryTrim shows your complexity score, every issue with a specific fix recommendation, and (on Pro) an automatically optimized query. Copy the optimized query and replace your input.graphql. Done.
Shopify Functions Runtime Constraints

Every constraint enforced.
No guesswork.

These are the real, verified Shopify Functions constraints that QueryTrim checks against. Exceed them and your extension fails at runtime — or worse, gets rejected at upload.

GraphQL Complexity Hard Limit
30 points — exceeded = rejected at upload
Complexity Warning Threshold
25 points — <5pts headroom is dangerous
Wasm Instruction Budget
~11M instructions per invocation
Execution Time Target
~5ms — exceeded = degraded checkout
Unbounded List Fields
Scale with cart size — can exhaust budget
JS/TS Runtime
QuickJS via Javy — JSON parse is expensive
External Network at Runtime
NOT ALLOWED — zero external calls
Runtime Database Calls
NOT ALLOWED — all data via input.graphql
Max Concurrent Functions
25 — compound budget pressure
Object Field Overhead (Javy)
>5 children increases heap pressure
Function Isolation
No shared state between functions
Workflow Examples

Which fields to keep.
Which to remove.

Real examples for the three main Shopify Function types. These patterns are pre-loaded as samples inside QueryTrim (Pro).

Use Case: Apply % discount if customer tag matches

KEEP cart.buyerIdentity.customer.tags
KEEP cart.lines.merchandise.product.tags
KEEP cart.lines.cost.amountPerQuantity
KEEP cart.lines.id + quantity
REMOVE product.vendor
REMOVE product.sku
REMOVE product.metafield
REMOVE product.productType
OPTIONAL customer.numberOfOrders
OPTIONAL customer.amountSpent

Why these fields are safe to remove

vendor, sku, productType — your discount logic only cares about tags. These fields add complexity points with zero business value.
metafield — adds at least 2–4 complexity points and requires an object traversal. If not used in your discount rule, remove immediately.
numberOfOrders, amountSpent — only keep these if your discount logic uses lifetime value gating. Otherwise they are wasted payload.
✓ Result: Typical discount function drops from 28–35 pts to 12–18 pts after removing unused fields.

Use Case: Hide a carrier for specific countries or provinces

KEEP cart.deliveryGroups.deliveryAddress.countryCode
KEEP cart.deliveryGroups.deliveryAddress.provinceCode
KEEP cart.deliveryGroups.deliveryOptions.handle
KEEP cart.deliveryGroups.deliveryOptions.deliveryMethodType
REMOVE deliveryAddress.address1, address2, city, zip
REMOVE deliveryOptions.cost (all sub-fields)
REMOVE deliveryGroups.lines (all sub-fields)
OPTIONAL deliveryOptions.title

Critical warning — lines is an unbounded list

deliveryGroups.lines is a list field without a first: argument. On a 50-item cart, it multiplies overhead by 50×. Always add lines(first: 250) or remove the field entirely if your logic doesn't use it.
address1, city, zip — most country/province filtering only needs countryCode and provinceCode. Street-level fields add payload with no logic value.
deliveryOptions.cost — if you're only hiding/showing delivery methods by handle, you don't need cost data at query time.
✓ Result: Delivery functions drop from 24–32 pts to 8–14 pts.

Use Case: Hide a payment method by country or cart value

KEEP cart.buyerIdentity.countryCode
KEEP cart.cost.totalAmount.amount
KEEP cart.cost.totalAmount.currencyCode
KEEP paymentMethods.id
OPTIONAL cart.buyerIdentity.customer.tags
REMOVE cart.lines (all line items)
REMOVE cart.buyerIdentity.customer.email
REMOVE paymentMethods.name (use id for matching)

Payment functions: the minimal safe pattern

Payment customizations are the most over-queried function type. Developers copy the full cart structure by default — but payment logic almost never needs line items.
cart.lines — If your payment filter is country-based or total-based, you do NOT need line items. Removing this field typically saves 8–15 complexity points alone.
paymentMethods.name — Always match payment methods by id not name. Names can change; IDs are stable.
✓ Result: Payment functions drop from 20–40+ pts to 4–8 pts — the leanest possible.
Pricing

Start free.
Upgrade when you need more.

Billing is handled entirely by Shopify. No credit card, no external payment portal.

Free
$0
forever
  • 3 analyses per day
  • 1 query trimming per day
  • Complexity score (0–30 gauge)
  • Risk level badge (Safe / Warning / Error)
  • Full issue list with detailed recommendations
  • All 3 sample queries — Discount, Delivery, Payment
  • Field tree visualization (Pro)
  • Side-by-side optimized query diff (Pro)
  • Last result comparison (Pro)
✓ Current Plan
Pro
$9
per month, billed by Shopify
  • Unlimited analyses & trimmings per day
  • Complexity score (0–30 gauge)
  • Full issue list — all issues with detailed recommendations
  • Risk level badge (Safe / Warning / Error)
  • Full field tree visualization with per-field flags
  • Side-by-side optimized query diff — see what changed
  • Last result comparison — track improvement over time
  • All 3 sample queries — Discount, Delivery, Payment
FAQ

Common questions

Does QueryTrim modify my live store or my code?
No. QueryTrim is purely a read-and-analyze tool. It reads the GraphQL text you paste into it — it never connects to your codebase, never reads your extension files directly, and never modifies anything in your Shopify store or app. It is a static analyzer only.
What is a Shopify Functions GraphQL complexity limit?
Shopify enforces a hard maximum of 30 complexity points on every input.graphql query. Each field in your query costs at least 1 point. List fields (like cart.lines) multiply by the number of items they can return. If your query exceeds 30 points, Shopify will reject your extension at upload time — before it ever runs in production.
Does analysis run on our servers or locally?
The GraphQL analysis (AST parsing, complexity calculation, field traversal) runs entirely inside the Shopify Admin extension — in your browser, on your machine. No query text is sent to any server. The only server calls QueryTrim makes are to check your usage count (for the daily limit) and save a compact result summary (complexity score and risk level — not the query text itself).
What Shopify Function types does QueryTrim support?
QueryTrim analyzes any valid Shopify Functions GraphQL query: Discount Functions, Delivery Customizations, Payment Customizations, Cart Transform Functions, and Validation Functions. If it is a Shopify Function with an input.graphql file, QueryTrim can analyze it.
My analysis shows a warning but the query works fine. Why?
QueryTrim enforces conservative thresholds that match what Shopify documents as "safe under all conditions." A warning means your query is within the hard limit but has little headroom. As your function grows — and as Shopify adds more concurrent functions to a checkout — a query at 27/30 points becomes a 31/30 point query after one new field. Warnings are intentionally proactive, not retroactive.
Is this the same as Shopify's built-in complexity checker?
Shopify's CLI validates complexity at deploy time and shows a pass/fail result. QueryTrim goes further: it tells you which specific fields are causing complexity, explains why each is risky (unbounded lists, deep nesting, Javy overhead), and generates an optimized query for you. QueryTrim is a development-time analysis tool, not a replacement for the CLI.
How does billing work?
Billing is handled entirely by Shopify through their App Pricing system. When you upgrade to Pro, Shopify handles the subscription, invoicing, and payment. QueryTrim never sees your payment information. You can manage or cancel your subscription from the standard Shopify billing page.
Is QueryTrim GDPR compliant?
Yes. QueryTrim is fully GDPR compliant and handles all Shopify Mandatory Privacy Webhooks. We do not store, process, or fetch any customer Personally Identifiable Information (PII) or store data. Our analysis runs on abstract GraphQL text strings.