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

Add ability to subscribe to events via the OGM #4420

Open
kozak-codes opened this issue Dec 17, 2023 · 1 comment
Open

Add ability to subscribe to events via the OGM #4420

kozak-codes opened this issue Dec 17, 2023 · 1 comment
Labels
feature request New feature or request ogm

Comments

@kozak-codes
Copy link
Contributor

Is your feature request related to a problem? Please describe.

eg:

const Message = ogm.model('Message');
Message.on('created', {
  where: {},
}, (result) => {
  // do something with your new message
})

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

@kozak-codes kozak-codes added the feature request New feature or request label Dec 17, 2023
@jbhurruth
Copy link

You can achieve this by writing a custom subscription plugin and then routing the events to your handlers. I've found the only issue is that the execution context doesn't make it through to plugin unless you make some minor patches to the library. This doesn't matter if you don't have about your event handlers and the mutations thats caused them being scoped to the same transaction.

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

No branches or pull requests

3 participants