hasura / hasura/graphql-engine
[Feature Request] Graphql mutation/query as option webhook for triggers and actions
- Dominant language
- TypeScript
- Stars
- 32.1k
- Forks
- 3k
- PR merge metrics
- PR metrics pending
Description
Hi to all,
I love Hasuram thanks for all of your work. I would like to be able to configure GraphQL mutations/query as a side effect of a trigger or action call as an alternative to a webhook. Why?
From a business perspective, we sometimes need some operations to be atomic. I will put an example but is not my real scenario, suppose that we have an e-commerce site, then on a product purchase we may want to create the customer information about the purchase and update our stock.
Today I see 2 ways to achieve this is:
1- Running a mutation that updates both tables, customer_purchases, and product_stock (Let's forget about permissions of a regular user on this table this is just one example)
2- Using an Action or Trigger with a webhook.
The first one puts us in a situation where someone with a token may call a mutation with just the first part of the logic putting our data in an inconsistent state. And the second one while covering all aspects is an overkill for a simple situation like that one.
So maybe instead of that, we can insert into the customer_purchases set a trigger that then runs a GraphQL mutation that updates the stock. (We also gain some permission control with this over the 2-in-1 mutation)
Or we can create an action which instead of calling the webhook it calls the defined mutation.
While I bet this has more uses cases with mutations, now that we have Actions with type Query we could implement the same using GraphQL queries.
I am new in Graphql world so maybe it is not how things are done in general but I think at least from developer happiness will help a lot.
Contributor guide
Research direction
The issue does not name files, tests, or entry points. Start by reviewing the existing Actions, database triggers, webhook configuration, and GraphQL mutation/query execution paths. Done would require a decided design and documented behavior for invoking configured GraphQL operations atomically from triggers or actions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100