Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

While I like and enjoy many aspects of code generation such as this or Prisma, In real world scenario it just doesn’t feel right.

Imagine a very simple scenario, you want to add some validation based on business requirements, in order to do that you have to have a server with custom endpoints or a custom graphql server (thus copy most of what hasura generates) to implement your own validation

The only situation in which I consider this a really good solution is in a CQRS system where the database attached to hasura is read only via graphql and the data is inserted by other services making it a typesafe single source of truth to read from



On that last bit, we recently added actions: https://hasura.io/blog/introducing-actions/

Writes (mutations) are delegated to a REST endpoint, the GraphQL mutation response can be synchronously (blocking mutation) or asynchronously consumed (mutation + subscription).


The sync part is very interesting, I like that it’s happening after the mutation so that Im not forced to reimplement the graphql types myself.

Will give it a try, thanks


Yep! The GraphQL resolution logic and the permissions get reused automatically.


I gave it a try, to be honest, I feel it too cumbersone, I expected it to use already available mutations not just copying existing types.

What I really want/need is custom logic that run IN the resolvers of already available query/mutations with the request as input and the possibility to either return an error or modify the payload before it hit the database

but I know is still in preview, will check it again when released


Agree. This is one of the issue we have with Hasura and it's what made us switch to Postgraphile.


Often times that’s not needed if you actually use the full power of PG. CHECK constraints go a long way, and where they don‘t go, PG/PSQL goes pretty much a long way.

For internal or prototypical use cases, that can be totally sufficient, however you‘re right that you‘ll eventually want good error messages, observability and much more other custom logic.

What I‘m still searching for is something that works like Hasura or PostgREST and then offers „upgrades“, first via configuration, later via custom code hooks.

That would be pretty awesome from a migration path perspective.


Check out Postgraphile, it allows you to start off with introspection, then customise it with comments, then add custom bits in node.

Both Hasura and Postgraphile also support schema stitching from what I know, so you should be able to extend it that way also (more complicated obviously)


Related, How does one receive a webhook in Hasura? Say I need to take some action on a Stripe rest webhook. All the docs show sending events somewhere, how about receiving and transforming data from 3rd parties?


Exactly! It could be useful for simple apps if they add a way to create basic validation rules with regex.


The Hasura console actually makes it quite easy to manage check constraints and validation rules! :)

Here's an example for a regex for validating email from one of our community calls: https://youtu.be/-9jX21PKyk0?list=PLTRTpHrUcSB8Dp3hk5SiVNHNP...


Great to know, elegant approach.


Hasura runs on top of a plain old Postgres database. You can use CHECK constraints to implement validation rules, including regex rules




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: