Skip to content
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

[Hasura] Include Option to Specify Trigger Name in Hasura Event Handling Decoration #152

Closed
n3n opened this issue May 20, 2020 · 3 comments · Fixed by #154
Closed

[Hasura] Include Option to Specify Trigger Name in Hasura Event Handling Decoration #152

n3n opened this issue May 20, 2020 · 3 comments · Fixed by #154
Assignees
Labels
enhancement New feature or request

Comments

@n3n
Copy link
Contributor

n3n commented May 20, 2020

Hasura events can have more than one trigger for a schema/table/op. It would be better if the decorator accepts the trigger.name as an option, so we don't need to care about schema/table/op.
We can also create an event trigger to listen different column with the same schema/table/op

Example

@Injectable()
class UsersService {
  @HasuraEventHandler({
    trigger: {
      name: 'user_field_A_changed' // op "UPDATE"
    }
  })
  handleUserFieldAChanged(evt: HasuraEvent) {
    // send an email ....
  }

  @HasuraEventHandler({
    trigger:{
      name:  'user_field_B_changed' // op "UPDATE"
    }
  })
  handleUserFieldBChanged(evt: HasuraEvent) {
    // trigger to 3rd party
  }

  @HasuraEventHandler({
    trigger:{
      name:  'user_has_been_created' // op "INSERT"
    }
  })
  handleUserCreated(evt: HasuraEvent) {
    // send a welcome email ....
  }
}

Reference: https://hasura.io/docs/1.0/graphql/manual/event-triggers/payload.html#json-payload

@WonderPanda
Copy link
Collaborator

Hey @n3n Thanks for opening this issue, I think this is great feedback and it definitely makes sense that targeting the trigger name would give the user a lot more flexibility for properly subscribing to events.

I'll do my best to spend some time improving this feature this week

@WonderPanda WonderPanda self-assigned this May 20, 2020
@WonderPanda WonderPanda added the enhancement New feature or request label May 20, 2020
WonderPanda added a commit that referenced this issue May 24, 2020
deprecates the old model of binding events based on the source schema and table to one that
leverages the hasura trigger name

fixes #152
@WonderPanda
Copy link
Collaborator

Hey @n3n this feature as well as the fix that you submitted in #153 have been released and are now available in version 0.4.0. The docs have been updated to reflect this change as well as I plan to deprecate the schema/table approach in favor of the trigger name and remove it in a future release

@n3n
Copy link
Contributor Author

n3n commented May 25, 2020

Good!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants