All Projects → tomasAlabes → graphql-kafkajs-subscriptions

tomasAlabes / graphql-kafkajs-subscriptions

Licence: MIT license
Apollo graphql subscriptions using kafkajs

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to graphql-kafkajs-subscriptions

Graphql Postgres Subscriptions
A graphql subscriptions implementation using postgres and apollo's graphql-subscriptions
Stars: ✭ 133 (+565%)
Mutual labels:  graphql-subscriptions
Aws Mobile Appsync Sdk Ios
iOS SDK for AWS AppSync.
Stars: ✭ 231 (+1055%)
Mutual labels:  graphql-subscriptions
serverless-graphql-subscriptions
Graphql subscriptions with apollo-server-lambda
Stars: ✭ 67 (+235%)
Mutual labels:  graphql-subscriptions
Graphql Genie
Simply pass in your GraphQL type defintions and get a fully featured GraphQL API with referential integrity, inverse updates, subscriptions and role based access control that can be used client side or server side.
Stars: ✭ 147 (+635%)
Mutual labels:  graphql-subscriptions
Djangochannelsgraphqlws
Django Channels based WebSocket GraphQL server with Graphene-like subscriptions
Stars: ✭ 203 (+915%)
Mutual labels:  graphql-subscriptions
go-graphql-subscription-example
☝️ go-graphql subscription over Kafka/Redis/NSQ example
Stars: ✭ 34 (+70%)
Mutual labels:  graphql-subscriptions
Graphql Subscriptions
📰 A small module that implements GraphQL subscriptions for Node.js
Stars: ✭ 1,390 (+6850%)
Mutual labels:  graphql-subscriptions
LiveGQL
Use GraphQL Subscriptions on iOS 👌
Stars: ✭ 84 (+320%)
Mutual labels:  graphql-subscriptions
36 Graphql Concepts
📜 36 concepts every GraphQL developer should know.
Stars: ✭ 209 (+945%)
Mutual labels:  graphql-subscriptions
golang-gqlgen-reactjs-subscription-demo
GraphQL Subscription with Golang/React JS & React Apollo Client Subscription
Stars: ✭ 29 (+45%)
Mutual labels:  graphql-subscriptions
Graphql Kafka Subscriptions
Apollo graphql subscriptions over Kafka protocol
Stars: ✭ 154 (+670%)
Mutual labels:  graphql-subscriptions
Grial
A Node.js framework for creating GraphQL API servers easily and without a lot of boilerplate.
Stars: ✭ 194 (+870%)
Mutual labels:  graphql-subscriptions
graphql-nats-subscriptions
A graphql subscriptions implementation using nats and apollo's graphql-subscriptions
Stars: ✭ 27 (+35%)
Mutual labels:  graphql-subscriptions
Graphql Mqtt Subscriptions
graphql-subscriptions implementation for MQTT protocol
Stars: ✭ 133 (+565%)
Mutual labels:  graphql-subscriptions
nextjs-typescript-postgresql-graphql-realtime-chat
WunderGraph Realtime Chat Example using NextJS, TypeScript, PostgreSQL, GraphQL
Stars: ✭ 53 (+165%)
Mutual labels:  graphql-subscriptions
Graphql Google Pubsub
A graphql-subscriptions PubSub Engine using Google PubSub
Stars: ✭ 108 (+440%)
Mutual labels:  graphql-subscriptions
nextjs-graphql-auth
Authentication system using NextJS, GraphQL, Apollo Client, Apollo Server, MongoDB, Nginx, Docker, Docker-Compose and Kubernetes
Stars: ✭ 27 (+35%)
Mutual labels:  graphql-subscriptions
py-graphql-client
Dead-simple GraphQL client with subscriptions over websockets
Stars: ✭ 36 (+80%)
Mutual labels:  graphql-subscriptions
kobby
Kobby is a codegen plugin of Kotlin DSL Client by GraphQL schema. The generated DSL supports execution of complex GraphQL queries, mutation and subscriptions in Kotlin with syntax similar to native GraphQL syntax.
Stars: ✭ 52 (+160%)
Mutual labels:  graphql-subscriptions
ios-graphql
iOS code examples with GraphQL, Apollo & more
Stars: ✭ 78 (+290%)
Mutual labels:  graphql-subscriptions

graphql-kafkajs-subscriptions

Apollo graphql subscriptions over Kafka, using kafkajs. Inspired on graphql-kafka-subscriptions.

Communication is done through 1 kafka topic specified in the KafkaPubSub create function. Then channels are used to identify the right subscription.

Installation

  npm install graphql-kafkajs-subscriptions
  yarn add graphql-kafkajs-subscriptions

Usage

Kafka Pub Sub

import { Kafka } from 'kafkajs';
import { KafkaPubSub } from 'graphql-kafkajs-subscriptions'

export const pubsub = KafkaPubSub.create({
  topic: 'my-topic',
  kafka: new Kafka({/* ... */})
  groupIdPrefix: "my-group-id-prefix", // used for kafka pub/sub,
  producerConfig: {}, // optional kafkajs producer configuration
  consumerConfig: {} // optional kafkajs consumer configuration
})

Subscription Resolver

{
    collaboration: {
      resolve: (payload: KafkaMessage) => {
        // payload.value will be whatever you sent
        return payload.value;
      },
      subscribe: (_, args) => {
        return pubsub.asyncIterator<YourType>("my channel");
      }
    }
  };

You can also use the subscription payload for the channel.

{
    collaboration: {
      resolve: (payload: KafkaMessage) => {
        // what you publish will end up passing through here and to the client
        return payload.value;
      },
      subscribe: (_, args) => {
        // this is called from the client
        return pubsub.asyncIterator<YourType>(`channel-${args.myId}`);
      }
    }
  };

Publication

Somewhere in your code, you call this:

pubsub.publish("my channel", {
  /* your event data */
});

Use the rest of the kafkajs options:

const event = {/* ... */};
const headers = {
  header1: "value"
};
const producerOptions = { /* options from kafka.js.org/docs/producing: acks, timeout, etc */ };

pubsub.publish("my channel", event, headers, producerOptions);

This ends up publishing the event to kafka (to the topic you used to create the kafkaPubSub) and received by all consumers. The consumer which is listening to my channel will send it to the client.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].