Update existing document and push a value to an аrray

I have the following document:

[User]
image

I want to insert one more object it utms array.
When I do this with the following graphql mutation, it’s not inserting a new one.

image

It’s ovewriting the existing one, not adding one more item in the array.
What is the correct way to do it with graphql mutation?
Thanks!

1 Like

Hi Fanka,

Thanks for creating your first post and welcome to the MongoDB community!

It appears that appending to an array is not yet possible with graphQL mutations.

You would have to include all the items in the array that you want to have which will replace whatever value is currently present.

Example:
set: { utms: {link: ["6000d6ee8e7e7e17ca723899", "600101d2e2b2ccf6c995f77d"]}

This has been requested as a feature in our product feedback forum below:

Please go ahead and vote on this idea if you’d like to receive updates on it’s progress.

I also found this posted as an issue on our graphql repo which you could subscribe to:

Regards
Manny

1 Like