Apollo graphql subscription over Kafka protocol


stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
00Aug 14, 2018Aug 10, 2018Minified + gzip package size for @mitrol/graphql-kafka-subscriptions in KB



Apollo graphql subscriptions over Kafka protocol

One producer and one consumer for each node instance. Communication happens over a single kafka topic.


npm install graphql-kafka-subscriptions


import { KafkaPubSub } from 'graphql-kafka-subscriptions'

export const pubsub = new KafkaPubSub({
  topic: 'anything',
  host: 'INSERT_KAFKA_IP',

With multiple Kafka nodes

export const pubsub = new KafkaPubSub({
  topic: 'anything',
  host: 'kafka-10.development.foobar.com:9092,kafka-21.development.foobar.com:9092,kafka-22.development.foobar.com:9092',
// as mentioned in the comments of https://github.com/ancashoria/graphql-kafka-subscriptions/issues/4
// you will need to upate the site calls of `publish` in your application as called out below.

// the stock PubSub::publish expects a string and an object
      pubsub.publish('messageAdded', {
        messageAdded: newMessage,
        channelId: message.channelId

// KafkaPubSub::publish expects the first parameter to be inserted into the object
        channel: 'messageAdded',
        messageAdded: newMessage,
        channelId: message.channelId

Special thanks to:

Help greatly appreciated

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.