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

feat(api): graphql subscriptions #148

Merged
merged 15 commits into from
May 2, 2023
Merged

feat(api): graphql subscriptions #148

merged 15 commits into from
May 2, 2023

Conversation

timonmasberg
Copy link
Member

@timonmasberg timonmasberg commented Apr 18, 2023

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 the GraphQLSubscriptionService which filters the event stream and converts it into an AsyncIterator (which is required for GraphQL subscriptions).

Now, whenever any Domain emits SomethingCreated and some resolver creates a subscription resolver hooked into SomethingCreated, 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.

@github-actions github-actions bot deleted a comment from timonmasberg Apr 18, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Apr 18, 2023

Deployment Preview

🏁 This PR has been closed. No deployment preview is available.

@timonmasberg timonmasberg changed the title test: add subscription to app resolver feat(api): graphql subscriptions Apr 19, 2023
@timonmasberg timonmasberg marked this pull request as ready for review April 19, 2023 18:10
@timonmasberg timonmasberg self-assigned this Apr 19, 2023
@timonmasberg timonmasberg enabled auto-merge (squash) April 19, 2023 18:17
@timonmasberg timonmasberg requested a review from JSPRH April 19, 2023 18:17
@@ -0,0 +1,101 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
Copy link
Contributor

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.

@sonarcloud
Copy link

sonarcloud bot commented May 1, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

90.3% 90.3% Coverage
0.0% 0.0% Duplication

@timonmasberg timonmasberg requested a review from JSPRH May 1, 2023 11:50
@timonmasberg timonmasberg merged commit 29a4893 into main May 2, 2023
@timonmasberg timonmasberg deleted the chore/websocket branch May 2, 2023 22:49
@timonmasberg
Copy link
Member Author

🎉 This PR is included in version 1.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

2 participants