DEV Community

Cover image for Graphile -- Farewell Business Layer

Graphile -- Farewell Business Layer

So I am super duper excited about Graphile, I just finished listening to an insightful podcast from GraphQL Radio and I enjoyed it quite a lot. But yeah let's forget about my enjoy and focus on this post.

So in this episode called Benjie Gillam on PostGraphile, The GraphQL Foundation, Independence From Facebook, Supporting Open Source, and beyond I get to learn more about Graphile and its origin.

How Graphile Came to Be

  • Originally it was called PostGraphQL.
  • Then Benji collaborate a couple of times on this open-source project and then one day he gets an email that CC him about the new fact, he is now the maintainer of PostGraphQL 😂.
  • So he works on it and in the process he renamed it to Graphile since GraphQL is a trademark.

So What the Heck does Graphile?

  • Simply put you do not need to write a model to connect to DB, then one for your service layer and eventually also one for your GraphQL. Essentially most of the times we do not need this much work. Especially if you wanna spin a stratup and just wanna ship something.
  • So Graphile sits in between and says something like this: hey, you know what? PostgreSQL is so awesome and powerful that it knows better than you how to:

    1. Plan a query in the most efficient way. This has a couple of implications:
      • No over fetching or under fetching.
      • Extremely optimized queries.
      • No need to tackle N+1 issue anymore.
    2. Handle permissions since like forever (I could not find any concrete evidence as when it was added but according to this commit in this repo it was before 2018) with GRANT and REVOKE.

My Take On This

  • Full transparency, I have not used it yet. But I am gonna try it out definitely.
  • As I wrote, this is my personal comment on this tool.
  • For a startup what matters most?

    • Shipping features fast ✔️.
    • Get a quick feedback ✔️.
    • Be reliable ✔️.
    • Have a good community ✔️.

So I would love to know if you're using it in your work place, personal project or are assessing for your next big hairy audacious project.

On Another Related Note

  • Sometimes we do have tons of business logic that we need to implement.
  • They cannot be expressed in PostgreSQL.
  • Our app's database ain't PostgreSQL.
  • Or any other reason.

I would suggest if one of those applies to you and you still have lots of CRUD like APIs. And you're asking yourself should I duplicate code or reinvent the wheel I would say you do not need to (unless you wanted to 😁).

Take a look at this project that I am actively trying to maintain it and make it something really comparable to HotChocolate in .NET world.

GitHub logo TriPSs / nestjs-query

Easy CRUD for GraphQL.

Nestjs-query Logo

Test codecov Known Vulnerabilities slack

nestjs-query

Nestjs-Query is collection of packages to make crud for graphql easier.

Why?

While working on projects in nestjs it was very easy to get up and running with graphql however, there were many patterns that were common between the resolvers. In particular querying, sorting and paging.

Installation

Install Guide.

Docs

Packages

Nestjs-query is composed of multiple packages


Instagram: https://www.instagram.com/node.js.developers.kh/
Facebook: https://www.facebook.com/kasirbarati
X: https://x.com/kasir_barati
YouTube: https://www.youtube.com/@kasir-barati
GitHub: https://github.com/kasir-barati/
Dev.to: https://dev.to/kasir-barati
LinkedIn: https://linkedin.com/in/kasir-barati


To support us you can support Benji on GitHub and to support me consider giving this repo a star.

Top comments (0)