I need to query a GraphQL function such as Steppun discount to generate a custom coupon code.
In my Shopify admin, I have the GraphQL app and I use:
{
shopifyFunctions(first: 100) {
nodes {
id
title
app {
id
title
}
}
}
}
to check out which function to use. I then create another query to generate the discount code:
mutation discountCodeAppCreate($codeAppDiscount: DiscountCodeAppInput!) {
discountCodeAppCreate(codeAppDiscount: $codeAppDiscount) {
codeAppDiscount {
discountId
title
appDiscountType {
description
functionId
}
codes(first:50) {
nodes {
code
}
}
status
}
userErrors {
field
message
}
}
}
with the following graphql variabls:
{
"codeAppDiscount": {
"code": "MY100FREE",
"title": "100% off",
"functionId": "333dab63-45b5-4b16-987e-bcc0f57ac562",
"startsAt": "2025-11-07T00:00:00Z",
"endsAt": "2025-12-31T23:59:59Z",
"appliesOncePerCustomer": true,
"combinesWith": {
"orderDiscounts": false,
"productDiscounts": false,
"shippingDiscounts": false
},
"metafields": [
{
"namespace": "steppun_discount",
"key": "quantity_limit_config",
"type": "json",
"value": "{ \"maxQuantity\": 1, \"effect\": { \"percentage\": 1.0 } }"
},
{
"namespace": "steppun_discount",
"key": "overflow_charge_config",
"type": "json",
"value": "{ \"overflowQuantityBehaviour\": \"charge_difference\" }"
}
]
}
}
but on the Admin API I get:
{
"data": {
"discountCodeAppCreate": {
"codeAppDiscount": null,
"userErrors": [
{
"field": [
"codeAppDiscount",
"functionId"
],
"message": "Function 333dab63-45b5-4b16-987e-bcc0f57ac562 not found. Ensure that it is released in the current app (259966828545), and that the app is installed."
}
]
}
},
"extensions": {
"cost": {
"requestedQueryCost": 20,
"actualQueryCost": 10,
"throttleStatus": {
"maximumAvailable": 2000.0,
"currentlyAvailable": 1990,
"restoreRate": 100.0
}
}
}
}
basically the app ID is the actual Shop. I’m also unable to query the functions using the Admin API as it just gets me an empty node:
{
"data": {
"shopifyFunctions": {
"nodes": []
}
},
"extensions": {
"cost": {
"requestedQueryCost": 20,
"actualQueryCost": 2,
"throttleStatus": {
"maximumAvailable": 2000.0,
"currentlyAvailable": 1998,
"restoreRate": 100.0
}
}
}
}
I am unsure if this functionality is only available to shopify plus customers only. I’m on the regular shopify. What are the other options to create a discount code programatically using the API on the fly please?
Thanks