A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Hello Expert,
I have faced a problem when updating product prices using Graphql in js fetch API.
I can get all products but could not update the product price using Graphql mutation.
Errors: message: "Field 'productVariantUpdate' doesn't exist on type 'Mutation'"
const priceUpdate =` mutation {
productVariantUpdate(input:{id:"gid://shopify/ProductVariant/40524123832528", price: "10"}) {
productVariant {
price
}
}
}`
const GRAPHQL_URL = 'https://dimerc-pmg.myshopify.com/api/2022-04/graphql.json';
const GRAPHQL_BODY = () => {
return {
'async': true,
'crossDomain': true,
'method': 'POST',
'headers': {
'X-Shopify-Storefront-Access-Token': STOREFRONT_ACCESS_TOKEN,
'Content-Type': 'application/graphql',
},
'body': priceUpdate
};
}
fetch(GRAPHQL_URL, GRAPHQL_BODY())
.then(res => res.json())
.then(products => {
console.log('products', products)
})
The above is what I did for updating the price. Could you please help me with how can I achieve the perfect result?
Thanks in advance!