-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat(api): graphql subscriptions #148
Conversation
Deployment Preview🏁 This PR has been closed. No deployment preview is available. |
f406fb3
to
4697c3b
Compare
3939363
to
7c109a6
Compare
@@ -0,0 +1,101 @@ | |||
/* eslint-disable @typescript-eslint/no-non-null-assertion */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make eslint-disable
line specific as allowing no-non-null-assertions om the whole file removes the type-checking for accidentially created ones too.
libs/api/shared/src/lib/kernel/graphql/subscriptions/graphql-subscription.service.ts
Outdated
Show resolved
Hide resolved
bd4d5cc
to
7384cf1
Compare
Kudos, SonarCloud Quality Gate passed! |
🎉 This PR is included in version 1.0.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This PR introduces GraphQL subscriptions over Server Sent Events.
As we probably will have an event-driven architecture, we want to use the
EventBus
from the@nestjs/cqrs
package. Subscription resolvers can hook into that event stream with theGraphQLSubscriptionService
which filters the event stream and converts it into anAsyncIterator
(which is required for GraphQL subscriptions).Now, whenever any Domain emits
SomethingCreated
and some resolver creates a subscription resolver hooked intoSomethingCreated
, it will get emitted over SSE. It is also possible to provide mappers, to map the event payload to a presentable model or filter the stream, e.g., if events are scoped for specific user roles or tenants.