Mutate customAttributes on orderUpdate overwrites all existing key value pairs

Hey everyone, I’m attempting to mutate customAttributes on the orderUpdate mutation.

https://shopify.dev/docs/admin-api/graphql/reference/mutation/orderupdate

It has the option to mutate customAttributes as shown here:

customAttributes ([AttributeInput!])

Custom information to add to the order, represented as a key value pair. Also referred to as note attributes.

When I mutate, it deletes all existing customAttribute key value pairs, and writes the key value pair from my query variables. Is there any way to only change that one key value pair without deleting the others?

Do i need to dynamically grab ALL the customAttributes and use them as my variables?

I am very new to graphQL, please school me if my mutation is just plain wrong!

Here is my query and variables:

mutation orderUpdate($input: OrderInput!) {
  orderUpdate(input: $input) {
    order {
      id
      customAttributes {
        key
        value
      }
    }
    userErrors {
      field
      message
    }
  }
}
{
  "input":{
     "id": "gid://shopify/Order/theordernumber",
     "customAttributes": {
       "key": "Checkout-Method",
       "value": "delivery"
    }
  }
} 

I have the same problem, did you manged to solve it?

I have the same problem.
Do we have any info about how to solve this issue?

Same problem

My solution was i tiny workaround.

  1. Get all the attributes
  2. Insert or delete the new values
  3. Save the new attributes array

This could be much nicer, if the shopify api out of the box could handle this, but it works for me, so who cares?! :grinning_face_with_smiling_eyes:

Hey guys just did this myself. As @Radixsecur1ty says, no, the only way is to get all the custom attributes first then submit the updated array. I thought I’d add that to get them from a webhook, you can include the field “note_attributes” in the webhook subscription. Then when you do your mutation, transform the note attributes ({ name, value }) to custom attributes ({ key, value }) and submit that through orderUpdate.