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.

Cannot Create Giftcard

Cannot Create Giftcard

TravisImagine
Shopify Partner
16 0 2
I am trying to create a giftcard in Shopify's checkout extension. The goal is to have a user enter a code, and it will create a gift card that will be added to the order. I am currently stuck creating the gift card. I have the mutation below to create it. The mutation works when I use an external HTTP tool.
 

 

const { data } = await query(
        `mutation {
          giftCardCreate(input: {
            code: "0123456789",
            initialValue: "100",
            note: "0123456789"
          }) {
            userErrors {
              field
              message
            }
            giftCard {
              id
              expiresOn
              note
              initialValue {
                  amount
              }
              customer {
                  id
              }
            }
            giftCardCode
          }
        }`,
      );
      console.log(data);

 

 
The console log just returns "undefined". If I replace that mutation with a query like the product selection below, I get the expected result.
 

 

        `query ($first: Int!) {
          products(first: $first) {
            nodes {
              id
              title
              images(first:1){
                nodes {
                  url
                }
              }
              variants(first: 1) {
                nodes {
                  id
                  price {
                    amount
                  }
                }
              }
            }
          }
        }`,
        {
          variables: { first: 5 },
        }

 

 
I have double checked my permissions on the app, and I do have gift card write access. Is there some way to see an error when running this API call?
 
Travis
 
Replies 0 (0)