Development discussions around Shopify APIs
In my examples below I will replace my actual function id with "FUNCTIONID". Just know that yes I used the correct id.
I can issue this query in GraphQL (using version 2023-04 since you can't query for functions in earlier versions):
query { shopifyFunction(id:"FUNCTIONID"){ apiType apiVersion title description inputQuery app { id } } }
The query succeeds and it finds my function:
{ "data": { "shopifyFunction": { "apiType": "product_discounts", "apiVersion": "2023-01", "title": "volume-discounts", "description": "", "inputQuery": "query Input {\n cart {\n lines {\n quantity\n\t cost{\n\t\tamountPerQuantity{\n\t\t\tamount\n\t\t}\n\t }\n merchandise {\n __typename\n ...on ProductVariant {\n id\n\t\t\tproduct{\n\t\t\t\tid\n\t\t\t\tmetafield(namespace: \"nfusionsolutions\", key: \"pricetiers\"){\n\t\t\t\t\tvalue \n\t\t\t\t}\n\t\t\t}\t\t\t\t\n }\n }\n }\n }\n}\n", "app": { "id": "gid://shopify/App/4345823" } } }, "extensions": { "cost": { "requestedQueryCost": 2, "actualQueryCost": 2, "throttleStatus": { "maximumAvailable": 1000, "currentlyAvailable": 967, "restoreRate": 50 } } } }
So I know this function exists. However, if I try a mutation it fails:
mutation { discountAutomaticAppCreate(automaticAppDiscount: { title: "Volume discount", functionId: "FUNCTIONID", startsAt: "2022-06-22T00:00:00" }) { automaticAppDiscount { discountId } userErrors { field message } } }
Here is the error response:
{ "data": { "discountAutomaticAppCreate": { "automaticAppDiscount": null, "userErrors": [ { "field": [ "automaticAppDiscount", "functionId" ], "message": "Function not found." } ] } }, "extensions": { "cost": { "requestedQueryCost": 10, "actualQueryCost": 10, "throttleStatus": { "maximumAvailable": 1000, "currentlyAvailable": 973, "restoreRate": 50 } } } }
I have tried this in 2 development stores. One with "Checkout Extensibility" developer preview and one without. It fails in both.
The function I am trying to mutate is an extension that I have added using Shopify CLI and based on examples here (https://shopify.dev/docs/apps/discounts/experience/getting-started) and here (https://shopify.dev/docs/apps/selling-strategies/discounts/experience/config). It builds and deploys successfully to an existing public plugin that has been live in the Shopify store for some time (https://apps.shopify.com/precious-metal-product-prices). I can see the extension deployed in the partner developer dashboard under the details for that app. And as previously stated when that app is deployed to my test store I can query for that function in GraphQL. However, without the mutation my code is never called. What is the problem here and how can it be addressed?
Were you able to fix your issue? I'm exactly in the same case 😞
Seems that it has been fixed by reinstalling Shopify GraphQL app!
User | RANK |
---|---|
10 | |
4 | |
3 | |
3 | |
3 |
We're excited to announce improvements to the threaded messaging experience in our communi...
By TyW May 31, 2023Thank you to everyone who participated in our AMA with Klaviyo. It was great to see so man...
By Jacqui May 30, 2023Photo by Marco Verch Sales channels on Shopify are various platforms where you can sell...
By Ollie May 25, 2023