A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hey. I've been banging my head over this for several hours now, any kind help is greatly appreciated! I followed the guide made by Shopify on creating a new discount type to learn more about Shopify functions (https://shopify.dev/apps/discounts/create). I followed the guide all the way through and when I finally came to testing it I ran into this error when trying to create a new discount as the guide says: DiscountCodeAppInput isn't a defined input type (on $discount)
I've made sure that I have the write_discounts scope in shopify.app.toml. I have also made sure that I enabled checkout extensibility developer preview for the new dev store I created.
Here's the full error i get from the console (if it's any help):
mutation.js:106 Error: DiscountCodeAppInput isn't a defined input type (on $discount): {"response":{"errors":[{"message":"DiscountCodeAppInput isn't a defined input type (on $discount)","locations":[{"line":2,"column":31}],"path":["mutation CreateCodeDiscount"],"extensions":{"code":"variableRequiresValidType","typeName":"DiscountCodeAppInput","variableName":"discount"}},{"message":"Field 'discountCodeAppCreate' doesn't exist on type 'Mutation'","locations":[{"line":3,"column":5}],"path":["mutation CreateCodeDiscount","discountCreate"],"extensions":{"code":"undefinedField","typeName":"Mutation","fieldName":"discountCodeAppCreate"}},{"message":"Variable $discount is declared by CreateCodeDiscount but not used","locations":[{"line":2,"column":3}],"path":["mutation CreateCodeDiscount"],"extensions":{"code":"variableNotUsed","variableName":"discount"}}],"status":200,"headers":{}},"request":{"query":"\n mutation CreateCodeDiscount($discount: DiscountCodeAppInput!) {\n discountCreate: discountCodeAppCreate(codeAppDiscount: $discount) {\n userErrors {\n code\n message\n field\n }\n }\n }\n","variables":{"discount":{"functionId":"d8fccec0-8395-4abb-9cc0-6867f8ed65e8","combinesWith":{"orderDiscounts":false,"productDiscounts":false,"shippingDiscounts":false},"startsAt":"2022-07-13T18:44:09.149Z","endsAt":null,"metafields":[{"namespace":"rapid-discounts","key":"volume-config","type":"json","value":"{\"quantity\":1,\"percentage\":0}"}],"title":"PCAV7DCE0YGS","code":"PCAV7DCE0YGS"}}}}
at index.ts:410:11
at step (graphql-ws.ts:258:1)
at Object.next (graphql-ws.ts:258:1)
at fulfilled (graphql-ws.ts:258:1)
I am facing the same issue, you figured out the fix? By the way am using remix and making storefront.graphql call.
Just lost an hour with this error.
The error happened because I was making admin queries on storefront graphql. Normally admin queries must be executed on admin graphql endpoint.
Exactly the case with me.