Skip to content
This repository has been archived by the owner on Apr 5, 2023. It is now read-only.

Does mongoke supports mutations? #6

Open
jmorakuebler opened this issue May 1, 2020 · 2 comments
Open

Does mongoke supports mutations? #6

jmorakuebler opened this issue May 1, 2020 · 2 comments

Comments

@jmorakuebler
Copy link

Hello @remorses, this project is awesome, very easy set up and deploy. But I have one question, does mongoke supports mutations? I'm planning on creating a database from scratch for insertion and query. Many thanks in advance.

@remorses
Copy link
Owner

remorses commented May 2, 2020

Currently no, I created mongoke as a way to query your database from the frontend client, implementing mutations this way is an anti pattern, you would add a lot of complex logic in the client side, making the bundle size a lot bigger.

Another problem that arises when you implement mutations directly in the client is that usually you don’t mutate a single collection in database, but instead you change many resources (like change a user object and a blogPost object), if you mutate from the client there is the possibility that the database becomes inconsistent if all the mutations don’t end successful and there is no way you can handle the case the client disconnects

A better alternative is to implement mutations in a different api that talks directly to the database, this way you separate the complex logic from the client, making the code base cleaner

To connect the api you can use an Apollo federation gateway to connect the 2 services, check out the federation example in the examples directly

If you think mutations are useful I can maybe implement them and enable them via the configuration file with an option

@remorses
Copy link
Owner

remorses commented May 2, 2020

I am now thinking that mutations would be useful in server side to have a typed client like prisma does, will implement them in the near future

Let me know what would be an ideal api and schema you would like

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants