How to update a value in an array

my data:

{
    name: 'test",
    Tag:  ["A", "B", "C"]
}

I want to change a value in the Tag array, such as:

{
    name: 'test",
    Tag:  ["A", "B", "EEEEEE"]
}

What should I do, delete the old value first, and then add the new value?

1 Like

try this:

upset {
  query {
    a as var(func: eq(name,"test"))
  }
  mutation {
    set {
      uid(a) <Tag> "EEEEEE" .
    }
    delete {
       uid(a) <Tag> "C" .
    }
  }
}

(assuming name is a unique field)

1 Like