Update mutation (graphql) to add a many-to-many relationship without overwriting the whole thing

System Information
  • Strapi Version: 4.1.6
  • Operating System: macbook pro m1
  • Database: sqlite
  • Node Version: 14.18.3
  • NPM Version: 6.14.15
  • Yarn Version: 1.22.10

I have a many-to-many relationship, and would like to add an entry on an update mutation without overwriting all previous records

Example mutation

mutation addField($foo:ID!, $bar:ID!) {
   updateEntry(id: $foo, data: { property: [$bar] }) {
      data {

Result I get

data {

Desired result if running multiple times with different values for $bar

data {

Is anyone able to help me with this? Please let me know if I should add more detail to solve this problem.



Hi @kd_coded , did you find a solution ?

I am stuck with the same problem, whether it’s with GraphQL or API REST, my relationship updates overwrite all previous relationships…


Same problem

Which Strapi version are you using?

I tried adding a relation to the user but it didn’t work. But it worked if you add
relation to the opposite collection

now I have a problem to remove the relation))

1 Like