I was able to do updateCustomer in the GraphQL playground, but when I try to do it in node.js (see below) I get the following error:
Error updating customer: RequestError: Variable $input of type CustomerInput! was provided invalid value
at Request. (c:\nodejs\node_modules\got\dist\source\as-promise\index.js:113:42)
at afterResponse (c:\nodejs\node_modules\shopify-api-node\index.js:296:15)
at Request. (c:\nodejs\node_modules\got\dist\source\as-promise\index.js:87:42)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
{name: ‘RequestError’, code: ‘ERR_GOT_REQUEST_ERROR’, timings: {…}, locations: Array(1), path: undefined, …}
const Shopify = require(‘shopify-api-node’);
const shopify = new Shopify({
shopName: ‘myStoreAt.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();