graphql
graphql copied to clipboard
Add ability to subscribe to events via the OGM
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.
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.