ancashoria / graphql-kafka-subscriptions

Apollo graphql subscriptions over Kafka protocol
MIT License
187 stars 55 forks source link

Channel should not be a requirement #49

Closed davis-anthony closed 2 years ago

davis-anthony commented 2 years ago

It is possible that an existing kafka producer for a topic may not use channels. Topics can have messages that are not targetted to a channel. It should be possible to setup the KafkaPubSub with a configuration or the asyncIterator with some sort of null value or empty array to allow all messages found on a topic to be considered valid payloads to process.

davis-anthony commented 2 years ago

OK, I figured this out on my own. For anybody else who didn't get this (since the documentation is lacking) when you subscribe to a topic without using channels, use the topic name for the channel.

pubsub.subscribe(topic, onMessage) ... const resolvers: IResolvers = { Subscription: { postAdded: { subscribe: () => pubsub.asyncIterator([topic]), resolve: (payload) => payload }, } };