App reviews, troubleshooting, and recommendations
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Error updating extension draft for product-discount: Query has complexity of 33, which exceeds max complexity of 30
Thanks for your message.
You're absolutely right in the product discount function API (and other function APIs), Shopify enforces a hard limit of 30 query complexity in the GraphQL input. When your query exceeds this (e.g. complexity of 33), it triggers the following error:
"Error updating extension draft for product-discount: Query has complexity of 33, which exceeds max complexity of 30."
Unfortunately, this limit is set by Shopify and cannot be increased.
Since you've noted that all fields are essential and Metafield-based solutions won’t work, here are your best options:
Optimize or split the query to stay within the limit
Offload logic to an external backend or App Proxy, then pass minimal required data to the function
Let me know if you need help restructuring the query or implementing one of these approaches.
Best regards.
Thank you very much for the reply, and yes it would be really nice if you help me restructure the query or suggest me any different approach.
here is the whole query.
query RunInput(
$lineItemProperty: String,
$startTime: TimeWithoutTimezone!,
$endTime: TimeWithoutTimezone!,
$collectionIds:[ID!],
$customerTags: [String!],
$productTags: [String!],
$cartAttributeKey: String
) {
shop {
localTime {
timeBetween(endTime: $endTime, startTime: $startTime)
}
}
cart {
attribute(key: $cartAttributeKey) {
key
value
}
cost {
subtotalAmount {
currencyCode
amount
}
totalAmount {
amount
}
}
lines {
id
quantity
sellingPlanAllocation {
sellingPlan {
name
}
}
cost {
totalAmount {
amount
}
}
attribute(key: $lineItemProperty) {
key
value
}
merchandise {
...on ProductVariant {
id
product {
id
# productType
inAnyCollection(ids: $collectionIds)
hasAnyTag(tags: $productTags)
}
}
}
}
buyerIdentity {
purchasingCompany {
company {
name
}
}
customer {
hasAnyTag(tags: $customerTags)
amountSpent {
amount
}
email
displayName
numberOfOrders
}
isAuthenticated
}
}
localization {
country {
isoCode
}
market {
regions {
name
}
}
}
presentmentCurrencyRate
discountNode {
metafield(namespace: "$app:product-discount", key: "function-configuration") {
jsonValue
}
}
}
Without knowing the use case in question, it'd be hard for anyone to help reduce your input query cost.
Please share further information so that someone can help you with optimising your function query.
Founder
• Dollarlabs: Ultimate Discounts (5★) – If you can think of a discount, you can build it
• Dollarback: Cashback & Loyalty (5★) – Simple cashback. Powerful loyalty.