Unexpected error in Shopify GraphiQL app when i'm going to create an automatic discount (I built a discount function app)

I successfully built a discount function app that works exactly the way i want, following the tutorial “Build a Discount Function” and by making some small changes to the code in the files within the src folder and in shopify.extension.toml.

I ran all the necessary procedures and created an automatic discount in my dev store using GraphiQL (Admin API) in my browser (while running “shopify app dev”).
I downloaded the discount function app to my production store, and to create the automatic discount, I also downloaded the Shopify GraphiQL App to make it the same as in the dev store. Running the exact same mutation:
mutation {
discountAutomaticAppCreate(
automaticAppDiscount: {
title: “Bundle Lab OFFER”
functionHandle: “discount-function-js”
discountClasses: [ORDER, SHIPPING]
startsAt: “2025-01-01T00:00:00”
}
)
{
automaticAppDiscount {
discountId
}
userErrors {
field
message
}
}
}

It gave me the following errors:
{
"data": {
"discountAutomaticAppCreate": {
"automaticAppDiscount": null,
"userErrors": [
{
"field": [
"automaticAppDiscount"
],
"message": "Function not found. Ensure that it is released in the current app (2315872), and that the app is installed."
…..}

The paradox is that I also downloaded the Shopify GraphiQL App on the dev store, and while the same mutation created the automatic discount correctly from GraphiQL (Admin API) in my browser, the Shopify GraphiQL App showed me the same error that I was getting on the production store (the error is shown above).

What could be wrong that I can’t create an automatic discount?
The app installed successfully on the store.
The function released
I’m using the correct function handle.
I’m using the correct API version.

App has the write_discountsaccess scope.

i have already written “write_discounts” and “read_products” scopes in “ shopify.app.toml”

Please follow the query to confirm the function exist

     shopifyFunctions(first: 10) {
       edges {
         node {
           id
           app {
             title
           }
           apiType
           apiVersion
         }
       }
     }
   }

Running this code in the Shopify GraphiQL App (putting at start the command “query”) it showing the first 10 functions that installed on my store. I found the desirable function and took the ID of the function and put it in my mutation to create the automatic discount.

I’m a little confused because it’s not the same ID in the shopify.extension.toml file code.

In the end this is the error and finally solved!

Thank you very much for your time to reply in my problem!
I really apriciate it!

You’re very welcome! :blush: I’m glad to hear you got it all sorted out in the end.