This is tangenting away from modularity a bit, although in my experience modularity can definitely add some complexity to using API tooling. This is more of a Rails At Scale question.
I’m wondering tools/framework people use for creating APIs in their Rails apps. We’ve used Grape and found the developer experience to be very clunky and development has been a very slow process. Another part of our org uses Praxis because we acquired some of the authors of Praxis a few years ago. I’ve taken a look at Category: API Builders - The Ruby Toolbox and almost all of the libraries seem to be around serialization.
I’m curious what other companies are using and your experiences.
Thanks!
Sarah
We’re just using vanilla Rails controllers, but we use sorbet T::Structs for serialization and deserialization.
We have some tooling where we basically attempt to serialize the input hash into a well-typed T::Struct, and failures to serialize into the T::Struct (which represents the contract for the caller of the API) turns into a 4xx level error with information about the failure.
It ends up saving lots of code because the well-typed input objects into our service classes are also the deserializers. T::Struct comes with a from_hash method that mostly does the job.
Thanks for your response, Alex.
I guess what I’m surprised by is that good serialization is enough for you.
How do you handle things like sorting, filtering, data selection, etc?
Ah ya we have a home grown pagination tool. It basically supports us allow listing specific filtering and sorting concerns. It seems to work quite well for us and at least at this stage I wouldn’t consider adopting a separate framework for this.
We try to use GraphQL for everything. It doesn’t have one answer to all aspects, but it does come with an answer.
When modularization work leads to inter-app comms, I feel compelled to also say: don’t turn all method calls into API calls. Think about converting a portion of calls to events.