Conversations about creating, managing, and using metafields to store and retrieve custom data for apps and themes.
I have to updated metafields in for customer in custom data but when I run this
mutation {
customerUpdate(
customerAccessToken: "ba66f112107a1ffd4be40c6671d79431",
customer: {
, metafields: [{
namespace: "instructions",
key: "wash",
valueInput: {
value: "cold wash",
valueType: "STRING"
}
}
]} ) {
userErrors {
field
message
}
customer {
metafields(first: 100) {
edges {
node {
id
namespace
key
value
}
}
}
}
}
}
I face errors
Hi Maaazahmed,
The error you're experiencing might occur due to several reasons. Here are a couple things you might want to check:
Invalid Access Token: Make sure your customerAccessToken
is valid. Access tokens can expire, so you should ensure it's up-to-date.
Incorrect Syntax: Look for any syntax errors in your mutation. In your case, there is a comma ,
before `metafields which may be causing a syntax error.
Permissions: Ensure that you have the necessary permissions to update the customer's metafields.
Valid Namespace and Key: Make sure the namespace and key you are trying to update actually exist for this customer.
Proper Value Input: Ensure that the value
and valueType
you are trying to update are compatible. In your case, it looks correct as you're a string value.
Here's your corrected mutation:
mutation {
customerUpdate(
customerAccessToken: "ba66f112107a1ffd4be40c6671d79431",
customer: {
metafields: [{
namespace: "instructions",
key: "wash",
valueInput: {
value: "cold wash",
valueType: "STRING"
}
}]
}
) {
userErrors {
field
message
}
customer {
metafields(first: 100) {
edges {
node {
id
namespace
key
value
}
}
}
}
}
}
If possible can you also share the error message you're seeing?
Hope this helps!
Liam | Developer Advocate @ 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
Thank You Laim
basically mutation is no accepting Metafields argument
When i use Shopify GraphiQL App working fine mutation customerUpdate($input: CustomerInput!) {
customerUpdate(input: $input) {
userErrors {
message
field
}
customer {
firstName
lastName
email
id
phone
metafields(first: 10) {
edges {
node {
namespace
key
value
id
}
}
}
}
}
}
but when run same code in postmen its node working and return this error
Error: CustomerInput isn't a defined input type (on $input)"
I have checked everything and also i have set HTTP-headers