4 ms·
You should solve this by making one request to a db api layer (use GraphQL!) And have that layer do the back and forth with the db, from right next to it. Hold
by eloff 7y ago
You should solve this by making one request to a db api layer (use GraphQL!) And have that layer do the back and forth with the db, from right next to it.
Holding transactions open for long distance round trips is going to get you into trouble in a myriad of ways. It does not scale.
- michaeldwan 7y agoThis is exactly what we do! We have a Rails app exposing a graphql api for our cli and web app. The web app is a React SPA monster that we're replacing with another Rails app that runs at the edge and serves the customer UI, docs, marketing pages, and some other things. It's really pleasant. We love graphql.
- jpochtar 7y agoWhy not just have the rails app exposing GQL also expose the customer UI/etc?
- mrkurt 7y agoThat's actually the plan! The Ruby Graphql gem lets you resolve queries directly so the app can have an "edge" or "core" mode and make the right call (edge over HTTP, core direct to DB).
- michaeldwan 7y agoMostly because the path to here was not a straight one :) Our main Rails app does a bunch of things that can't run globally and it takes a long time to build while the customer facing app is a lightweight Rails app that consolidated several static and single page react apps into one less gross place.