Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

DiscountCodeAppInput isn't a defined input type (on $discount)

DiscountCodeAppInput isn't a defined input type (on $discount)

Solveberg
Shopify Partner
1 0 1

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)

 

 

 

Replies 3 (3)

pixobe
Shopify Partner
8 0 3

I am facing the same issue, you figured out the fix? By the way am using remix and making storefront.graphql call.

dpavlutin
Shopify Partner
12 1 2

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.

pixobe
Shopify Partner
8 0 3

Exactly the case with me.