-
Notifications
You must be signed in to change notification settings - Fork 131
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 a(n optional) generic type map to PubSub. #245
Conversation
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.
Looks good! Updating the examples on the README.md would be good as well.
Yep! I updated the README as well to feature this if it ever gets merged. |
Related: #223 |
@glasser This is something that should be added to the v3.0 release: https://github.com/apollographql/graphql-subscriptions/milestone/1 This has been out here for a while: https://github.com/contra/typed-graphql-subscriptions |
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.
Thanks for this @cursorsdottsx!
The class PubSub now has a generic type parameter so its methods `publish` and `subscribe` can be **optionally** type-checked by TypeScript.
The class PubSub now has a generic type parameter so its methods
publish
andsubscribe
can be optionally type-checked by TypeScript./label typedefs
I was using
apollo-server-express
but the classPubSub
did not have any compile time validation by TypeScript. So I extended the class and added a generic. I thought I would contribute to the project back since it will be useful to others.New usage: