A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Can't figure out why I keep getting error on customerUpdate mutation . Can anyone spot the issue?
I've tried every permutation for the body that I can think of. I'm following this mutation: https://shopify.dev/api/examples/customer#update-a-customers-tags
{ errors: { query: 'Required parameter missing or invalid' } }
With code and node-fetch request library
const gql = `{
customerUpdate(input: {id: "gid://shopify/Customer/${customerId}", tags: "${tags.join(', ')}"}) {
customer {
tags
}
}
}`
const uri = `https://${shop}/admin/api/2021-07/graphql.json`
const options = {
method: 'POST',
headers: {
'X-Shopify-Access-Token': accessToken,
'Content-Type': 'application/json'
},
body: JSON.stringify({
mutation: gql
})
}
fetch(uri, options)
Hey @wb1,
While there were no specific details shared around the values you are passing with this request (the raw request), the only thing that stood out formatting wise would be the lack of operation in the request, eg: const gql = ` mutation{customerUpdate(input: ...
If you are using our shopify-node-api library, I would suggest looking through the documentation that includes GraphQL request examples to work with. That said, if you you be able to share an x-request-id response header that is returned with this error, I can take a closer look at logs on our end and pass back any potential insights.
Cheers!
awwdam | API Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Hey @wb1,
I also wanted ask if you tested the mutation and variables with using an API client (such as Insomnia) to confirm functionality. Please also let me know if this is successful!
awwdam | API Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Hey @awwdam I'm also having an issue with the `customerUpdate` endpoint when trying to update an address. If i send all empty strings it works and updates the default address of the Customer, but once I try to send interpolated data, the mutation runs successfully, however it does not update the Customer object and returns an empty array for addresses
{
input: {
id: `gid://shopify/Customer/${data.id}`,
addresses: [
{
address1: `${data.address1}`,
address2: `${data.address2}`,
city: `${data.city}`,
company: "",
countryCode: `${data.country_code}`,
firstName: `${data.first_name}`,
lastName: `${data.last_name}`,
provinceCode: `${data.province_code}`,
zip: `${data.zip}`
}
]
}
}
response of the customer object:
{
id: 'gid://shopify/Customer/CUSTOMER_ID',
firstName: 'firstName',
lastName: 'lastName',
defaultAddress: null,
addresses: []
}
*using graphql-request library