OutputTooLargeError for Orders with more then 125 line items

Hey,our store have heavy problems with the discount function api which gives us the error: “OutputTooLargeError”.

We use the Discount Function API for our B2B Partners to order up to 400 line items once with custom prices.This did fine for a while but now gives us this error, on every order which is bigger then 125 line items.

Our Function is written in rust, so that should work totally fine.In the Thread i attach you the Input and a screenshot from the Ressources.

Would be cool if we could sort this out, for the time right now i did write a admin action as a workaround that our B2B manager can apply the discounts manually.

Pastebin with the input: https://pastebin.com/raw/czE8QTN0

Log:

Error message: The output size limit of 20000 bytes was exceeded.

Thats my query:

query Input {
  cart {
    lines {
      id
      quantity
      cost {
        amountPerQuantity {
          amount
        }
      }
      merchandise {
        __typename
        ...on ProductVariant {
          product {
            productType
          }
        }
      }
    }
    buyerIdentity {
      purchasingCompany {
        company {
          id
        }
      }
    }
  }
  localization {
    country {
      isoCode
    }
  }
  shop {
    metafield (namespace: "custom", key: "b2b_pricelist") {
      jsonValue
    }
  }
}

Hi @Baldbytes ,

I think you are indeed hitting the output limit. If you’re creating discount operations for every cart line each with with product metadata and pricing information, you could hit the limit even with 100-400 line items. The limit exists to maintain quick proposals at checkout. For b2b and custom pricing by volume, most merchants use catalogs and I think that would work for your usecase. Though, if you’re set on discount functions, you could probably calculate by line item and quantity then create a single order discount while remaining within the output limit. Of course that approach doesn’t display a discount for each line item.

1 Like

:waving_hand: - +1ing @IanP-Shopify here. Also wanted to share this bit in our docs that goes over Functions Limitations in case it helps: