vesper-framework / vesper

Vesper is a NodeJS framework that helps you to create scalable, maintainable, extensible, declarative and fast GraphQL-based server applications.
http://vesper-framework.com
601 stars 36 forks source link

Ability to customize topic/trigger sbscribed to at subscription initialization time? #41

Open jhanschoo opened 6 years ago

jhanschoo commented 6 years ago

Currently, subscriptions topics seem to be determined by the GraphQL API. Controllers filter messages published to the GraphQL API-determined topic. This does not scale well in certain situations.

Consider a chatroom server, where users may create rooms and subscribe to those rooms, passing the room id as a parameter. Then by the example, the publisher must publish to ALL chatrooms, and the subscription controller filters by chatroom. This is not ideal in, say, redis implementations, since publishing is O(n) in the number of topic subscribers. The ideal way is to be able to determine which topic to subscribe to as controller. (As well as implement a filtering function)

jhanschoo commented 6 years ago

It seems like this is the line that needs to be changed.

https://github.com/vesper-framework/vesper/blob/68ba63931a6d3f370463e51321fe2902dd4fcf4e/src/SchemaBuilder.ts#L262