16 ms·
As a full-stack dev, I'm going to always reach for things like Hasura for building my backend from now on. It auto generates a full CRUD GraphQL API from my Pos
by rhlsthrm 6y ago
As a full-stack dev, I'm going to always reach for things like Hasura for building my backend from now on. It auto generates a full CRUD GraphQL API from my Postgres DB schema. Most of the backend boilerplate is eliminated this way. If I need to add additional business logic, I can use serverless functions that run between the GraphQL query from the front end and the DB operations (actions in Hasura). Most of the heavy lifting is through the front end anyways, and this keeps everything neatly in sync.
- dgellow 6y agoWhat about authentication, authorization? Also, how do you handle transactional logic?
- rhlsthrm 6y agoThey have great recipes for authentication/authorization. It's much better IMO because it actually provides per-request authorization. There is also great support for transactions using the GraphQL mutations. I'm not affiliated with Hasura in any way, it's just changed the way I view backend development. Backends (in most cases, my day job is actually not part of this generalization) should basically be a thin wrapper around your database, and any work you can outsource to the database, you should do that rather than building business logic.
- eatonphil 6y agoThose aren't hard to do if you declare up front what schema you need to conform to. I'm working on a REST code generator (generates a Go backend and a typescript/react frontend) that reads your postgres/MySQL schema and some additional metadata you provide (should auth be enabled? Which table is the users table and which columns are username and password stored as bcrypt). I'm still working on authorization part but basically optional per-endpoint logic DSL for simple stuff and optional Go hooks for more complex stuff. https://eatonphil.github.io/dbcore/ https://eatonphil.github.io/dbcore/
- dmitriid 6y agoWe're exploring a GraphQL serv(er/ice) for an internal back office system. It needs to combine multiple APIs into a single GraphQL interface. And everything just breaks apart :) (we have PoCs in C# and Java for now).
- gavinray 6y agoYou can use Remote Schemas in Hasura to combine multiple API's, and Remote Joins to join relational data across data sources: https://hasura.io/docs/1.0/graphql/manual/remote-schemas/index.html https://hasura.io/docs/1.0/graphql/manual/remote-schemas/ind... https://hasura.io/blog/remote-joins-a-graphql-api-to-join-database-and-other-data-sources/ https://hasura.io/blog/remote-joins-a-graphql-api-to-join-da... If you need to convert your API's into a GraphQL first, you can wrap the endpoints with resolvers yourself, or use automated tooling: https://github.com/Urigo/graphql-mesh https://github.com/Urigo/graphql-mesh https://github.com/IBM/openapi-to-graphql https://github.com/IBM/openapi-to-graphql
- dmitriid 6y agoI took a quick peek, it's no different than writing your own resolvers in any other implementation.
- eveningcoffee 6y agoIt is not really a backend when it does not involve business logic but just an access layer for the DB. It is pretty much a client server model.
- xgenecloud 6y agohey, you might want to check xgenecloud where it is seamless to add business logic for generated APIs. XgeneCloud makes it really simple to add business logic for generated APIs (REST and GraphQL both) over any SQL databases. We just launched this week [2] [1] : https://github.com/xgenecloud/xgenecloud https://github.com/xgenecloud/xgenecloud [2] : https://news.ycombinator.com/item?id=23466782 https://news.ycombinator.com/item?id=23466782 Website : https://xgenecloud.com https://xgenecloud.com (disclaimer: founder here)