How to create new components in a existing collection type

Hey,

I’m working on a frontend application and like to add new dynamic zone components to an existing collection type. I mutate the data with apollo but I get headaches when I try to add new data to a collection type. Here is my apollo mutate request: mutation editPrintroll ( $ID : ID! $Diameter: Float){ updatePrintroll( - Pastebin.com

The mutation request works but delete all existing ones. So I’m just able to add one entry and unfortunately delete all existing ones. How can I just add new dynamic components to a collection type. Also how I can delete a specific component of a collection type. I searched the trough the internet but didn’t find a suitable answer. Hope you guys can help me.

Cheers,
Lars

When adding a new one, you will need to include the old ones as well (else how would you delete one? :wink: )

As you figured out, to delete you just need to omit the entry from the mutation or simply provide an empty array if you need to delete the last one in the array.

Thanks for your advice. I already thought that would be the way to achieve what I want. I know it’s not a strapi specific request but how can I get an array as a variable for graphql? Like to achieve what you suggested.

Thanks in advance!

I was able to solve my question myself. Anybody who is facing the same task check the following pastebin. mutation editPrintroll ( $ID : ID! $printrollctx: [PrintrollPrintrollctxDy - Pastebin.com

I will now fetch the data and transfer it into the variables. Now when I like to add something to a dynamic zone, I will take all data and add new data on top. Bring all together in the variables and mutate it. Bam! If I like to delete a specific one I will remove it from the fetched data and mutate it again.

Cheers everybody

Ah yes, sorry it took me so long to respond, you are correct. Thank you for the posting the answer for others though <3