Function Not Found Issue/Misunderstanding

I need to migrate several hundred Basic Code Discounts to a custom Discount Function due to the scripts deprecation. I am using a node script to do this that is part of my extension only app that has the target Discount and other UI Functions. The issue is that when I call the mutation to create the custom discount I get an error that my function is not found. The function is v2026-01, the mutation variables look something like:

{
“codeAppDiscount”: {
“title”: “My Custom discount”,
“code”: “aa14-418100”,
“functionHandle”: “handle-of-discount-function-in-toml”,
“startsAt”: “2018-12-13T15:10:00Z”,
“endsAt”: “2019-12-13T15:10:00.000Z”,
“usageLimit”: 1,
“appliesOncePerCustomer”: false,
“discountClasses”: [
“PRODUCT”
],
“combinesWith”: {
“orderDiscounts”: false,
“productDiscounts”: false,
“shippingDiscounts”: false
},
“metafields”: [
{
“namespace”: “$app”,
“key”: “discount-function-configuration”,
“type”: “json”,
“value”: “{\"collectionIds\":,\"productIds\":}”
}
]
}
}

The error is “Functionhandle-of-discount-function-in-toml not found. Ensure that it is released in the current app (34352397NNNN), and that the app is installed.”

Any help/insights appreciated here.

Found the issue!

Turns out that my env file’s client id and secret were pointing to the wrong dev store. SO the GraphiQL was working but my script was not. Phew!