I am not sure I follow… are you able to change my mutation in my example to achieve this goal? For more context I have a form where a user can edit a list of values. It would be a lot of additional code to have to work out which values were removed and run a separate mutation just for this. There is also a number of lists in this form, hence why I am looking to do everything in one mutation.
Is there no way to have this mutation to a simple replace?
This does work however feels like this is something the mutation should handle. Is there another mutation property I should be using instead for a simple replace?
Yep, this will work for now. I think a ticket should be created for allowing creating a new array instead of setting values to an existing array. @hardik can look into this and see where it can fit in the roadmap
Are there any updates on this? I have found an awkward situation I have run into a few times.
It is when I am wanting to remove/update a nested array in my type. I am wanting to pass in an array of IDs, but instead I have to pass in an array of TypeRef, which implies I have to have all the data for that type.
Is there a way around this? The below is what I need to pass in at the moment.
@charklewis - What you’re really asking is for the ability to pass in nested types. I think this should be a separate feature request, but may be fixed when nested filters are available one day.
Note: If you know the SEO ID (I imagine you do since you know the previous keywords), I believe you can avoid the other hassle by just updating the SEO node directly.
Since this is a foreign key problem, it is in relation to my @reference directive request, and perhaps should be added at the same time.
The difference, is that we are just dealing with the foreign keys, not the values themselves. We basically want to NOT merge the foreign keys on update.
I suggest this could be done in two ways:
1.) Going well with my other @reference suggestion:
Type Foo {
id: ID!
name: Bar @reference(merge: false)
...
}
2.) Or add a new setAll command to update all references…
@naman, do you think this might be a easy API enhancement?
Right now it takes quite a bit of logic on the UI to control the state to know the list of current children and then calculate which ones to add and remove when the user is presented with a list and checkboxes. So I have to keep up with 4 different state sets. The saved set from the last db query, the current active set for checkboxes selected, the set to add, and the set to remove. This gets even more problematic when I build my 4 different states of data off from the first one, but a user might send a second mutation before my original query updates to get the now active set so the ones that are “removed” and “added” in this second mutation are now wrong according to what is stored in the database. It would be a whole lot easier if I could just send the list of references that I want it to be exactly.