I am creating a Shopify app and using a GraphQL mutation to create a BXGY automatic discount. The mutation works fine when I specify a specific product in the customerBuys.items field. However, when I remove the products field from the customerBuys field and set customerBuys.items.all to true (to apply it to all products) I get the following error:
{
"discountAutomaticBxgyCreate": {
"userErrors": [
{
"field": [
"automaticBxgyDiscount",
"customerBuys",
"items"
],
"message": "Items in 'customer buys' must be defined",
"code": "BLANK"
}
],
"automaticDiscountNode": null
}
}
I’m not sure why this error is happening, as I have followed the Shopify API documentation correctly. Could this be a problem with the Shopify API or is there something wrong with my mutation?
My Mutation:
mutation CreateDiscount($amount: Decimal!, $productId: ID!) {
discountAutomaticBxgyCreate(automaticBxgyDiscount: {
title: "BXGY discount test",
startsAt: "2022-01-01",
endsAt: "2024-04-18T02:38:45Z",
usesPerOrderLimit: "1",
customerBuys: {
value: {
amount: $amount
}
items: {
all: true
}
},
customerGets: {
value: {
discountOnQuantity: {
quantity: "1"
effect: {
percentage: 1
}
}
}
items: {
products: {
productsToAdd: [$productId]
}
}
}}) {
userErrors {
field
message
code
}
automaticDiscountNode {
id
automaticDiscount {
... on DiscountAutomaticBxgy {
title
summary
status
}
}
}
}
}
Any help or suggestions would be appreciated. Thank you!