Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

"InputObject 'CustomerUpdateInput' doesn't accept argument 'metafields'"

"InputObject 'CustomerUpdateInput' doesn't accept argument 'metafields'"

Maaazahmed
Shopify Partner
3 0 0

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 

Replies 3 (3)

Liam
Community Manager
3108 342 884

Hi Maaazahmed,

 

The error you're experiencing might occur due to several reasons. Here are a couple things you might want to check:

  1. Invalid Access Token: Make sure your customerAccessToken is valid. Access tokens can expire, so you should ensure it's up-to-date.

  2. 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.

  3. Permissions: Ensure that you have the necessary permissions to update the customer's metafields.

  4. Valid Namespace and Key: Make sure the namespace and key you are trying to update actually exist for this customer.

  5. 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

Maaazahmed
Shopify Partner
3 0 0

Thank You Laim 

 

I have checked the access token, and it's valid.

basically mutation is no accepting Metafields argument 

Maaazahmed
Shopify Partner
3 0 0

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