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