Skip to content

sgil-carecloud/graphql-kafka-subscriptions

 
 

Repository files navigation

graphql-kafka-subscriptions

Apollo graphql subscriptions over Kafka protocol

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

Installation

npm install graphql-kafka-subscriptions

Usage

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

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

export const pubsub = new KafkaPubSub({
  topic: 'anything',
  host: 'INSERT_KAFKA_IP:port,INSERT_KAFKA_IP:port,INSERT_KAFKA_IP:port',
})
// 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
      pubsub.publish({
        channel: 'messageAdded',
        messageAdded: newMessage,
        channelId: message.channelId
      });

(https://github.com/ancashoria/graphql-kafka-subscriptions.git) Special thanks to:

Help greatly appreciated

About

Apollo graphql subscriptions over Kafka protocol

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%