App reviews, troubleshooting, and recommendations
I am developing an app for Shopify that applies automatic volume discounts based on the product metafields. For this, I obtain the shopping cart lines and obtain all the metafields that specify the discount breakpoints. Everything works correctly, the problem is that when requesting all the metafields I am exceeding the query.
Version couldn't be created.
product-discount
Validation errors
• targeting.0.input_query: Query has complexity of 57, which exceeds max complexity of 30
query RunInput {
cart {
lines {
quantity
cost {
amountPerQuantity {
amount
}
}
merchandise {
__typename
... on ProductVariant {
id
product {
id
compra10: metafield(namespace: "producto", key: "compra_10") {
value
}
compra12: metafield(namespace: "producto", key: "compra_12") {
value
}
compra20: metafield(namespace: "producto", key: "compra_20") {
value
}
compra25: metafield(namespace: "producto", key: "compra_25") {
value
}
compra30: metafield(namespace: "producto", key: "compra_30") {
value
}
compra50: metafield(namespace: "producto", key: "compra_50") {
value
}
compra60: metafield(namespace: "producto", key: "compra_60") {
value
}
compra100: metafield(namespace: "producto", key: "compra_100") {
value
}
compra150: metafield(namespace: "producto", key: "compra_150") {
value
}
compra200: metafield(namespace: "producto", key: "compra_200") {
value
}
compra250: metafield(namespace: "producto", key: "compra_250") {
value
}
compra300: metafield(namespace: "producto", key: "compra_300") {
value
}
compra400: metafield(namespace: "producto", key: "compra_400") {
value
}
compra500: metafield(namespace: "producto", key: "compra_500") {
value
}
compra600: metafield(namespace: "producto", key: "compra_600") {
value
}
compra1000: metafield(namespace: "producto", key: "compra_1000") {
value
}
compra1200: metafield(namespace: "producto", key: "compra_1200") {
value
}
}
}
}
}
}
}
From the Shopify Functions docs: "Function input queries can have a maximum calculated query cost of 30."
This article contains a table that explains all the query field costs:
https://shopify.dev/docs/apps/functions/input-output#limitations
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024