-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Could we have PRE event-trigger for customize data validation? #1291
Comments
I concur it would be great to have a pre-commit webhook, but currently it is not easy to implement this in the present event triggers design. This is because the events are generated atomically with a mutation using native Postgres triggers. To accomplish pre-commit webhook, we will need to use something other than Postgres triggers so it will be a different sub-system. @coco98 @0x777 thoughts on this feature? For the time being, there are 2 solutions:
|
@tirumaraiselvan , I am happy to get answer from you. And if I choose the second option, how could I get the error message to the client side, while it stores on event logs, not return into the client. |
And How about the authentication system |
@hengsovandara You will have to handle it asynchronously. You will have to emulate a sync like process for e.g. after performing the mutation to the temp table, you should wait/block the UI and poll (or use subscriptions) for the validation status. Since validation is more naturally a sync process, hence approach 1) is recommended :) Regarding auth system, yes it is pre-hook and that is exactly the kind of system which would be needed to achieve pre-hook event triggers. Let's see if there is enough interest in this. |
@hengsovandara A 3rd way is to use CHECK constraints or postgres stored proc for validation although this is best suited for validations on data based on regexes and simple constraints. |
I have been doing on that too, but what the problem is we don't have
postgres developer and also don't want to waste time on learning while
doing a project.
…On Thu, Jan 3, 2019, 6:34 PM Tirumarai Selvan ***@***.*** wrote:
@hengsovandara <https://github.com/hengsovandara> A 3rd way is to use
postgres stored proc for validation although this is best suited for
validations on data based on regexes and constraints.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1291 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/Aadv6RBV7shqBJLBKk1v8QaAfat2tsK1ks5u_ercgaJpZM4ZnpWI>
.
|
@hengsovandara Understand :) Why don't you give Remote Schemas a try? With the boilerplates available at https://github.com/hasura/graphql-serverless, I think it should be a very easy process. It would be same as your Lambda code and the wrapper code is already present. If there is any trouble, we will be happy to solve it for you. |
I just seen the example lately. I will have a try. However, I think if
Hausra could give a option like I raised above, it would make life easier.
Thank you every much for supporting all the time.
…On Thu, Jan 3, 2019, 6:55 PM Tirumarai Selvan ***@***.*** wrote:
@hengsovandara <https://github.com/hengsovandara> Understand :)
Why don't you give Remote Schemas a try? With the boilerplates available
at https://github.com/hasura/graphql-serverless, I think it should be a
very easy process. It would be same as your Lambda code and the wrapper
code is already present. If there is any trouble, we will be happy to solve
it for you.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1291 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/Aadv6evNZ3PYUvd0JcFPQt33hzMdO0cIks5u_e-YgaJpZM4ZnpWI>
.
|
When I was using firebase, I bumped into similar issues. Reading state from a database directly, with an ACL for access control, is amazing, and saves time. You also get "real-time" updates for free on both platforms. But modifying/creating state, almost always ends up needing some custom code. Therefore the convention I came up with was simple. All state mutations go through cloud functions, and (almost all) read-only queries go straight to the DB. I suspect a simliar convention would work well with Hasura so as to not get stuck down the line; i.e. use a remote schema for EVERYTHING that modifies state in the database. Use Hasura's awesome autogenerated schema for everything else. |
If Hasura had this feature then you wouldn't need a separate remote schema server for 95% of cases. Most other business logic could be handled with events and subscriptions. Couldn't Hasura leverage the remote schema functionality internally to achieve this? Would also be great to have common field validations easily configurable: email, credit card / mod-10, US state / zip, sql injection prevention for text fields, URL format, etc. |
@brodie-hodges For common field types like email, credit card, zip, etc , you can perhaps use Postgres CHECK constraints : https://www.postgresql.org/docs/9.5/ddl-constraints.html#DDL-CONSTRAINTS-CHECK-CONSTRAINTS For more complex use-cases, we have a solution in the works called "actions" which will be out pretty soon. This will eliminate remote schemas use for tasks like these. |
@tirumaraiselvan good news brow 😉 |
@tirumaraiselvan Thanks for the update. Is this on a roadmap somewhere? |
Thanks for the update! Are there any details about upcoming "actions"? 😊 |
Thanks @tirumaraiselvan! Support for custom pre-insert/update/delete business logic validation via the upcoming "Actions" functionality will be incredibly useful. Where can we follow the roadmap for this please? I checked and the release candidate roadmap does not seem to mention Actions. |
Subscribe |
It would be great to have pre triggers for custom logic. Are there any updates on that? |
Any word on the "actions" solution @tirumaraiselvan ? |
Hi, we've been actively working on this. We'll have a preview build by the end of this week. |
Exciting :) |
@lukaspili
I’m a little thrown off by the Python example. Isn’t it supposed to be in Node?
… On Oct 11, 2019, at 3:12 PM, Michael Bosworth ***@***.***> wrote:
A high level overview of actions has been made available here: https://deploy-preview-3042--hasura-docs.netlify.com/graphql/manual/actions/index.html (found on PR #3042)
Exciting :)
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
@2upmedia I just found the PR and read the doc, I don't have more info. |
@lukaspili thanks. I'll reach out to the person that created the PR. @0x777 any ideas why there's a Python example in the documentation? |
@2upmedia, if my understanding is correct, the HTTP endpoint is something you yourself create, which means that you can use any language, be it Node, Python, or Racket. In what sense is it supposed to be Node? |
Python syntax is almost like writing some sort of pseudo code so I guess it makes sense. But yeah, your backend could be written in any language so it really doesn’t matter like @MikeBosw said. |
Also, we're planning to add support for the action handler to be a postgres function (say, plv8) or an HTTP endpoint. So you can move from one to the other quite easily. For example, start off with a postgres function if its simple data validation type code and move to a HTTP endpoint later without affecting anything. |
This makes sense now. I wasn’t aware that the action could be an HTTP endpoint. |
Stumbled across this amazing project and handling pre-processing / validation logic was my only concern when adopting it. I'm very glad to hear you are working on a solution |
@tirumaraiselvan , @coco98 , @0x777 , I've been waiting for a long time for actions feature to be released. How long will it take? It will change our DB structure dramatically. Here is an example of a use case: #3536 Thanks for building the amazing Hasura! |
Hi. |
I'm so excited for this feature! Are there any updates on that? |
Maybe these are two different things, but I'd love to be able to specify when the event should be triggered. Right now, it looks like it's being triggered after the update/mutation is made. I'd like to be able to configure the event to run before an update/mutation. This way, my webhook can determine if the update is allowed and/or modify the response for additional processing (thinking ETL cases). If my response is, say Thoughts? |
I was reading the documentation further and it seems that something similar is already in place but I'm not seeing it work as described (or I'm misunderstanding the documentation).
I see that if I return a non |
@jmonday The docs you are referring to are for Event-Triggers which are very different from Anyway, in event-triggers, you have transactionality between the database mutation and the creation of the event. But, you don't have transactionality with the invocation of the webhook (as it is an external system). |
Hey everyone Happy to announce that we have released Actions in v1.2 (currently in beta) to solve this problem. Please try out the beta from here https://github.com/hasura/graphql-engine/releases. Expecting to release stable by week-end. Why did we build Actions to solve this problem?
How does Actions work?
All this is available via the CLI as well to fit nicely with your existing dev environment. Closing this issue now, but feel free to ask any questions here or on Discord ! |
Nice @tirumaraiselvan! Amazing work on actions. For anyone else seeing this, we've been using them for a couple of weeks in production and they are super useful. Right off the bat, it saves you from having to write the graphql stuff surrounding your logic which means that a simple function like the one you were using in events pretty much works. 👏 One question I had was whether you'll be opening actions to use them as queries apart from mutations. I remember that when we discussed this @coco98 said it should be almost as easy as letting the keyword Another thing that comes to mind is being able to use the existing types within the app. Thanks! |
@dariocravero Yes, query support is almost merged: #4032 and so is re-using postgres scalars: #4125 . We will keep improving other things as we go along. |
That's class! :)
…On Tue 14 Apr 2020, 12:15 Tirumarai Selvan, ***@***.***> wrote:
@dariocravero <https://github.com/dariocravero> Yes, query support is
almost merged: #4032
<#4032> and so is re-using
postgres scalars: #4125
<#4125> . We will keep
improving other things as we go along.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1291 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAC33TEQPS4YLBE4IWOVRZ3RMQZS5ANCNFSM4GM6SWEA>
.
|
@tirumaraiselvan has any plan to add support for the Postgres functions? |
Hey folks, in our next community call on Thursday, 27th of April, we will showcase a new permission type for insert mutations which allows you to use external webhooks to perform input validations. This will allow any kind of validation to be performed during inserts without touching the user database. Sign up for the community call here. Would love to see you there! ✨ |
### What This PR updates the engine to use the NDC Spec v0.2.0-rc.1 version. This is very likely to be the final RC before release. ### How The `ndc_models` crate got updated, which then resulted in the schema migration code in `metadata_resolve` being updated. This affected a lot of test results because connectors that used deprecated type representations got migrated to other representations, and if a type representation was missing then JSON was used instead. The NDC request-sending code in `execute` was updated to send the `X-Hasura-NDC-Version` header depending on the version of request getting sent. The custom connector was updated to be compatible with the new NDC 0.2.0-rc.1 types. This resulted in the schema changing, so a lot of tests that contained the connector's schema were updated. --------- Co-authored-by: Daniel Harvey <[email protected]> V3_GIT_ORIGIN_REV_ID: b1c7081eb1ee6cffdead08328a857903102332c6
I wonder whether I could have a pre-event-trigger to customize data validation before saving record. I known that Hasura has remote-schema which could do this, however, I think I don't need to create server to run the remote-schema. I just want to create Lambda function to check validation before saving records.
The text was updated successfully, but these errors were encountered: