graphql-compose / graphql-compose-mongoose

Mongoose model converter to GraphQL types with resolvers for graphql-compose https://github.com/nodkz/graphql-compose
MIT License
708 stars 94 forks source link

Generate Upsert Resolvers #387

Open dannydi12 opened 2 years ago

dannydi12 commented 2 years ago

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!

Resousse commented 2 years ago

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

darwinphi commented 2 years ago

Any update on this?

DrakeAnglin commented 1 year ago

This is much needed!