Hello all,
in the documentation I see a lot of examples for graphql mutations but never a complete example with Shopify UI Extension React JS based.
Here is my example but It doesnt work. I don
t know why:
function createDraftOrder() {
query(
`mutation ($input: DraftOrderInput!) {
draftOrderCreate(input: $input) {
draftOrder {
id
}
}
}`,
{
"input": {
"lineItems": [{
"appliedDiscount": {
"amount": "5.00",
"description": "test modify lineitem price",
"title": "modify lineitem price",
"value": 5.00,
"valueType": "FIXED_AMOUNT"
},
"variantId": "gid://shopify/ProductVariant/39803484209270",
"quantity": 1
}
],
"purchasingEntity":{
"customerId": "gid://shopify/Customer/5790884724854"
}
}
},
)
.then(({data}) => {
})
.catch((error) => console.error(error));
}
Thanks