graphql-compose-mongoose icon indicating copy to clipboard operation
graphql-compose-mongoose copied to clipboard

Generate Upsert Resolvers

Open dannydi12 opened this issue 4 years ago • 3 comments

I was wondering if I can modify the updateOne or createOne generated resolvers to insert/update depending on whether the document exists.

Usually, I would just create a custom resolver and pass the { upsert: true } option to mongoose. But it would be a lot of work to make a ton of custom resolvers for something that can easily be generated but with a small change.

Please let me know if there is any way to accomplish this! Thanks!

dannydi12 avatar Oct 07 '21 20:10 dannydi12

As a user, I would appreciate this upsert feature a lot !

I see there is in mongoose already a method findOneAndUpdate that embeds upsert feature, may be implementation wouldn't be too complex, if just creating a new resolver that uses this

Resousse avatar May 20 '22 20:05 Resousse

Any update on this?

darwinphi avatar Jul 14 '22 13:07 darwinphi

This is much needed!

DrakeAnglin avatar Feb 24 '23 20:02 DrakeAnglin