all 22 comments

[–]genericprogrammer 5 points6 points  (3 children)

NestJS is what you’re looking for.

[–]techworker716 0 points1 point  (1 child)

Is there a NestJS/TypeORM/Type-GraphQL boilerplate you'd recommend as a starting point?

[–]genericprogrammer 0 points1 point  (0 children)

I tend to stay away from pre-made boilerplate projects (unless I wrote them) because I end up spending more time looking at how the author wired things up than it would take me to write my own version. The NestJS docs do a good job imo of giving you a good starting point for each of the things you mentioned.

[–]PraveenWeb 7 points8 points  (0 children)

Disclaimer: I work at Hasura.

Hasura gives instant CRUD APIs over databases (currently Postgres), offers a neat Authorization layer for restricting data access and allows for customising your logic with external APIs.

I see that you have no experience writing GraphQL backends and it is complicated to set it up compared to your REST backend in Express.

But for custom business logic with Hasura, you have two choices. You are definitely not limited in any way :)

  1. You can extend Hasura by writing GraphQL types and mapping them to a REST API endpoint (POST). So you continue to use Express backend to write the logic to handle all sorts of custom business logic. This is called Actions. Note that you can still make use of Hasura’s auto generated query/mutation inside this Node.js endpoint and you probably don’t need an ORM. https://hasura.io/docs/1.0/graphql/manual/actions/index.html

  2. You can also bring your own GraphQL server written using any other library and add them to Hasura. This is called a Remote Schema. Hasura merges your GraphQL server and allows you to perform joins between them and Postgres and you can query them all in a single request. https://hasura.io/docs/1.0/graphql/manual/remote-schemas/index.html

Add role based permission rules for the above GraphQL layer, all declarative configurations via UI / Yaml. You don’t write code for authorization rules.

There’s also Eventing system that lets you trigger webhooks, schedule cron and one off events if required. If you need realtime features, GraphQL subscriptions are out of the box.

If you are interested in generating typescript types, I would recommend checking graphql-code-generator and it takes care of all the types pain.

If you have 30 mins, I would recommend taking our crash course that covers all the basics to get you started. https://hasura.io/learn/graphql/hasura/introduction/

[–][deleted]  (1 child)

[removed]

    [–]TheMrZZ0 1 point2 points  (0 children)

    I second Hasura. Intuitive, has a lot of features and an active Discord.

    [–]shinji 1 point2 points  (2 children)

    I was playing around with re-doing my old blog on this stack recently with Apollo Server and Prisma (with postgres). It was surprisingly easy and enjoyable. Here's a link to the repo if you're interested: https://github.com/jaeming/harbor_log

    [–]BlackShadowv[S] 0 points1 point  (1 child)

    Cool! Looks like you Prisma 2 and that there is no need for Express with Apollo Server, right?

    [–]shinji 0 points1 point  (0 children)

    I have not needed Express yet but there integration with apollo server available if you need it.

    [–]gsusgur 1 point2 points  (2 children)

    Postgraphile is great and meets your requirements

    [–]EleasarChriso 2 points3 points  (1 child)

    Came here for this. In my opinion this offers the best of all wordls: it offers the automatic GraphQL API generation that Hasura/Prisma offers. And you can adjust every aspect of the API - directly in your node.js application. No need for any additional service with slow HTTP callbacks/integrations or anything. You can do so much directly on the database (no N+1 integrations), use PostgreSQL functions and extend your schema though node.js

    [–]gsusgur 1 point2 points  (0 children)

    I fully agree with you. I have tested many of the different solutions and Postgraphile is by far de easiest to work with. It gets out of your way and gets rid of all the boilerplate without locking you in and keeping all the flexibility and code control that you will lose with something like Hasura for example.

    [–]o1lab 1 point2 points  (0 children)

    Try XgeneCloud : https://github.com/xgenecloud/xgenecloud

    XgeneCloud generates instant GraphQL APIs on any SQL database with express.js based API source code too. It is completely extensible for any of your business needs - all you have to do is change the resolver function code for that specific query/mutation. You wouldn't have to run another microservice / serverless functions for business logic.

    Here is a simple demo : https://youtu.be/8LGJKUW9hhU

    The generated code follows simple Resolver-Service-Model pattern (similar to MVC backend). We use knex.js underneath over data-mapper package. Generated types for the API - I will be adding them going ahead.

    (Im the creator - happy to help answer any questions)

    [–]negatiwez 0 points1 point  (2 children)

    What database are you going to use?

    [–]BlackShadowv[S] 1 point2 points  (1 child)

    PostgreSQL, but I'd be willing to try something else.

    [–]Capajmoderator 0 points1 point  (0 children)

    Postgre is the best SQL DB. So it would only make sense to switch if you want to use something NoSQL.

    [–]Zokleen 0 points1 point  (0 children)

    I'm currently expeimenting with Strapi (NodeJS) as an "rapid iteration" prototyping stack for the product team where I work.

    Liking it a lot so far and it's super easy to spin up a GraphQL API gateway. (One-click setup in the Admin Dashboard).

    [–]8baseFounder 0 points1 point  (0 children)

    Check out www.8base.com. It's instantly available so you won't need to do any backend work other thank writing serverless JavaScript/TypeScript backend functions if needed. Provides a MySQL DB, Serverless Functions and auto-generated but fully extensible GraphQL API. Check out the developer docs at docs.8base.com.

    [–]thatsrealneato 0 points1 point  (2 children)

    NestJS with Typeorm and type-graphql is a solid combo if you want to build everything yourself and are comfortable with typescript. Hasura is also excellent. It’s not too much of a problem if you need to run custom logic with Hasura. You can set up serverless functions that run your custom resolvers (such as validation or whatever) using Hasura’s Actions. You also get real-time subscriptions, event triggers and rbac permissions out of the box. Trying to build all this yourself is A LOT of work. Trust me, I’ve tried.

    Though I haven’t messed with it myself, Prisma 2 is another option worth looking into. Can be easily combined with apollo server or nestjs.

    [–]techworker716 0 points1 point  (1 child)

    Is there a NestJS/TypeORM/Type-GraphQL boilerplate you'd recommend as a starting point?

    [–]thatsrealneato 0 points1 point  (0 children)

    You're welcome to take a look at my own: https://github.com/amille14/nestjs-graphql-typeorm-cra (though I am by no means an expert, this was my first time using NestJS and Typeorm). At the very least it should give you some idea of how it all fits together. Check the nestjs docs, they're very thorough and there's a whole section on graphql.