I am new to GraphQL…I was able to do a customerUpdate mutation using the GraphQL playground, but when I try it in a node.js script (below) I get the following error: “Error updating customer: RequestError: Variable $input of type CustomerInput! was provided invalid value.”
const Shopify = require(‘shopify-api-node’);
const shopify = new Shopify({
shopName: ‘mystore.myshopify.com’,
accessToken:‘xxx’
});
const updateCustomer = async () => {
const query = mutation customerUpdate($input: CustomerInput!) { customerUpdate(input: $input) { userErrors { field message } customer { id firstName lastName } } }
const variables= {
“input”: {
“id”: ‘gid://shopify/Customer/1018520244’,
“firstName”: ‘Frank’,
“lastName”: ‘Jones’
}
};
try {
const response = await shopify.graphql(query);
console.log(JSON.stringify(response, null, 2));
} catch (error) {
console.log(‘Error updating customer:’, error);
}
}
updateCustomer();