Syntax for customerUpdate mutation using node.js and shopify-api-node

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();

Hey @epodietz

Looks like you’re not passing the variables. You can pass them as a second argument to shopify.graphql like this:

const response = await shopify.graphql(query, variables);

Thanks, Scott. Pretty obvious, in retrospect. Now to glue back those hairs that I pulled out…