scottohara / loot

An implementation of some of the core MS Money features in Ruby on Rails
MIT License
4 stars 3 forks source link

Switch from REST to GraphQL #139

Closed scottohara closed 4 months ago

scottohara commented 5 years ago

Our Rails backend is simply a JSON-based REST API (essentially what you now get in Rails 5+ when creating a new app with the --api flag).

Most controller actions do little more (if anything) than render json: <some model or collection>

We use ActiveModelSerializers to serialize models to JSON, which has it's own set of challenges.

Over the years, AMS became more of a first-class JSON:API implementation (we don't use JSON:API); and at this point is largely an abandoned project (has not see any progress in a number of years).

At the same time GraphQL has seen huge popularity, and many of it's benefits would fit our use case, e.g.

Given all of this, we should call a spade a spade, and consider ditching REST in favour of GraphQL.

Arguably this does mean abandoning some of the most fundamental parts of Rails, such as its router and controllers; but then again we're already not using large parts of the overall Rails framework (ActionView, ActionController, ERB, ActiveJob, ActionMailer, ActionCable, Sprockets, asset pipeline, Webpacker, etc.). The main benefit we get from having a Rails backend is ActiveRecord.

Investigate using something like graphql-ruby gem.

scottohara commented 4 years ago

Would also have the benefit of being able to get rid of the existing controller tests and replace with request tests (#115)

scottohara commented 4 months ago

In the 5 years since opening this issue, I've had an opportunity to work closely with GraphQL in another project, and I've reached the conclusion that it would not be warranted for this project for the following reasons:

There is certainly still appetite to look at alternate JSON serialisation support to replace AMS, and improve inefficiencies such as category index, but GraphQL is not the right answer here.