Hi Shopify developers,
We’re currently migrating our app’s discount functionality to use the latest [Discount API] and the discountAutomaticAppCreate mutation with Shopify Admin API (version 2025-04). For our new function-based discounts, we’re using the mutation with the required fields, including discountClasses as recommended in documentation and as supported in the GraphQL explorer. However, we’ve run into an issue:
Whenever we try to create a discount via our app with a mutation like:
graphql
mutation CreateAutomaticDiscount($automaticAppDiscount: DiscountAutomaticAppInput!) {
discountAutomaticAppCreate(automaticAppDiscount: $automaticAppDiscount) {
automaticAppDiscount {
title
discountId
}
userErrors {
code
message
field
}
}
}
and pass discountClasses as a field in the variable payload (e.g. discountClasses: ["PRODUCT", "ORDER"]), we get the following error from the Admin API:
text
Variable $automaticAppDiscount of type DiscountAutomaticAppInput! was provided invalid value for discountClasses (Field is not defined on DiscountAutomaticAppInput)
Strangely, when we run an inline mutation in the GraphQL app/playground, everything works as expected and the discount is created with the specified classes.
For legacy discounts (older functions not yet migrated), we’re still using the older automaticAppCreate mutation, which works fine without this field.
Questions:
- Is this a known issue with the Admin API’s variable payload validation for
discountClasses?- Is there an official roadmap or best practice for ensuring
discountClassesworks in both inline and variable payloads?- Does anyone have experience resolving this or know of any workarounds that work for production apps?
- Should we just omit
discountClassesfor now in variable payloads and rely on defaults, or is there a way to fully define the discount type?
Any advice for developers migrating to the new Discount API and managing old discounts with legacy mutations would be greatly appreciated.
Thanks!
We’re eager to hear from anyone who has encountered or resolved this!