Better HN
topnewbestaskshowjobs
Log inSign up

Envek

14 karma · joined Aug 8, 2017 (9y ago) · 6 submissions

Submissions

1.

Kubing Rails: stressless Kubernetes deployments of Ruby apps with Kuby(evilmartians.com ↗)

10 points · by Envek · 4y ago · discuss

comment 5y ago · link · parent

> I would have guessed a post like this would be satire!

It is… burlesque!

comment 6y ago · link · parent

> the natural assumption would have been that ActiveRecord model classes should double as GraphQL result objects, and there would be a nice DSL for specifying how to safely expose those objects to the API.

GraphQL-Ruby Types _is_ that DSL. You specify what fields can be exposed to the world and this is also the place where you can hide too low-level specifics (e.g. join separate `amount` and `price` columns into specific `Money` type). Then you pass AR object to GraphQL-ruby and it does what you said in DSL.

comment 6y ago · link · parent

> have created a completely parallel schema - new classes for every object in the GraphQL graph, which are analogous but separate from the Rails models, each one acting like a combination of controller and presenter

And IMO this is good. Now you have dedicated place (namely `app/graphql` folder) for API-specific data mapping and validations. And in general GraphQL-Ruby gently pushes you to decouple your API from your database schema so you will be able to refactor and optimize things under your application hood later.

comment 6y ago · link · parent

There is also abandoned graphql-preload gem with absolutely amazing API (it wraps graphql-batch under the hood):

https://github.com/ConsultingMD/graphql-preload

It is very sad that its creators are left and current owners aren't responding.

comment 6y ago · link · parent

+1 on this. GraphQL is a great way to actually decouple your API from underlying database schema. When you start thinking not about specific REST endpoints, but about API data model in general, it turns out that it is much better to hide many database-level specifics and provide more natural data model to clients.