DEV Community

Discussion on: Simple ToDo GraphQL API in Ruby on Rails and MongoDB with Docker [PART 01]

Collapse
 
sulmanweb profile image
Sulman Baig

Yes, I admit it's a bit odd. But If you see till last I managed to create two mutations 😂. The boilerplate in this article is mostly taking initialization of rails in docker which is not so simple and then RSpec suite takes a bit of work. So simple GraphQL and MongoDB initialization are easy enough. The world is moving to the docker platform so I thought I should do with docker. As far as ergonomics are concerned making boilerplate of rails is much much easy for me now after practice. Lastly not every day you create a new app from scratch 😊

Collapse
 
leastbad profile image
leastbad • Edited

Hey Sulman,

I re-read what I sent earlier and it sounds super aggressive - I was unintentionally antagonistic. I was just so floored to see how much bike-shedding was necessary to get to what I experience almost immediately after running rails new. Do you know what I mean?

Without getting into the relative merits, why do you find yourself gravitating towards GraphQL and MongoDB when RESTful resources and Postgres are so amazing to work with? Especially in Rails, it seems like many of the theoretical upsides of MongoDB (no schema) are completely negated, both by ActiveModel enforcing a data structure and Postgres having a JSONB column type that is just as fast and powerful as working with MongoDB? It seems like you're trading a batteries included developer experience for tools that are trendy but far less supported and proven. It wasn't that long ago that MongoDB couldn't guarantee that all data would actually be stored!

I actually installed the graphql-client gem for the first time just the other day, so that I could interact with some of the new endpoints available in Githubs API. I was kind of shocked at how hard it was just to compose what seems like a relatively simple query. It's just so laborious compared to calling REST endpoints. Especially when people are just starting out, nothing about the experience seems simpler to me.

So what am I missing? Is it driven by hype, "everyone is doing it so it must be good"? Is there a major upside I am too slow to see?

Thread Thread
 
sulmanweb profile image
Sulman Baig

Let me explain the purpose of this article in detail:

  • The first and far most important purpose is rails can do it as well
  • You can see many articles of creating rest API of todo with PostgreSQL but not like this.
  • rails is not only about short programming that you write one line and 10 files are created
  • rails best ergonomics is its design of OOP and restrictive architecture
  • I work in nodejs and cause of its openness one developer writes his way other developer writes his own way and when the third developer comes he gets confused what is written in code
  • Due to rails restrictiveness even when graphql laborious still when another user comes to code he will understand the flow.
  • I always prefer rails not because of shorthand but because of smooth coding.
  • Also, rails is hectic to install on windows which still is 70% of the world using that's why instead of simple rails new I devised docker methodology so that all world can work on rails.
  • This article is not for beginners but for intermediate developers that want to switch to node as its cool nowadays to give them a sense that rails is not dead and there is a lot more in rails than the fast development.
  • As far as mongo is concerned I agree with you but still, mongo is faster is not non-deep relationships, and also I used it as its being used as the norm in nodejs.
  • Documentation of rest API is a great issue if we use grape that even changes the development style of ruby or otherwise has to create yaml docs for front end which is a hectic job. But with graphql gem we keep in our normal ruby code and we get beautiful docs for frontend.
  • Also, the frontend can get whatever he/she needs from backend by making query instead of getting all non-relevant data and multiple calls to the server which is the main reason behind graphql creation.
  • Lastly, when working in an industry client sees that graphql and mongo is in these days so they order developers to use those then this article can be helpful.

Apart from those points, your point is valid that its hard to work like this in rails but believe me I have seen these situations where I needed such methodology. So, you can say its the article you may need not for your personal project but for some professional projects.

Hope this answers your confusions

Happy Coding!

Thread Thread
 
leastbad profile image
leastbad

Thanks for the detailed explanation! You sort of answered my question, I guess - your interest in Mongo and GraphQL seems primarily driven by what others are doing and what companies appear to be hiring for. This isn't a bad answer; maybe I was just hoping that you actually loved Mongo and GraphQL for some reason on a personal basis and you could tell me about it.

As you might guess, I'm not a big fan of doing what everyone else is doing just because, but I don't want to be a snob to the folks who think of development only as a job - they could be asked to use these tools because some CTO heard they were the next big thing.

I get (completely) why Mongo appeals to Node devs. Like I said, it's just a lot murkier for Rails devs.

I'm actually on Windows, but I'm using WSL2 so I can have an Ubuntu VM running all of my development concerns. It's amazing! Best of both worlds. Since I can only write code for one project at a time, I don't have a big need for Docker. Again, I'm not working on a team so I understand that I have a different case than you.

Just curious: have you checked out StimulusReflex yet? docs.stimulusreflex.com - it might be the coolest thing you see this week.

Thread Thread
 
sulmanweb profile image
Sulman Baig

Yes, I have been meaning to learn stimulus and stimulus reflex. Soon I will. Right now I know VueJS quite well and you will see VueJS implementation of this API soon.

Also, I love mongo and graphql but not more than the right tool for the right job. And I disagree with the notion that the right tool for the right job means switch to node from ruby as its right tool. Otherwise, I will still prefer graphql over rest but not mongo over postgres.

And maybe soon you will see me writing stimulus reflex tutorial as well 😊.

Happy Coding!

Thread Thread
 
leastbad profile image
leastbad

I honestly believe that Ruby and Rails both bring the world a little closer to happiness.