0.1.7 • Published 4 years ago

@niemen/graphql-nats-streaming-subscriptions v0.1.7

Weekly downloads
13
License
MIT
Repository
github
Last release
4 years ago

graphql-nats-streaming-subscriptions

This package implements the PubSubEngine Interface from the graphql-subscriptions package and also the new AsyncIterator interface. It allows you to connect your subscriptions manger to a nats streaming based Pub Sub mechanism to support multiple subscription manager instances.

Usage

const { NatsPubSub } = require('@niemen/graphql-nats-streaming-subscriptions');
const { connect } = require('node-nats-streaming');

const NATS_CLUSTER = 'faas-cluster';
const CLIENT_ID = 'streaming-client';
const NATS_URL = 'nats://nats.io:4222';

const client = connect(NATS_CLUSTER, CLIENT_ID, { url: NATS_URL });
const pubSub = new NatsPubSub(client);

const resolver = {
     Subscription: {
        NatsStreaming: {
            resolve: (msg) => {
                //get message data
                const data = msg;
                return msg;
            },
            subscribe: () => pubSub.asyncIterator(['topic1', 'topice2'])
        }
    }
}
// for more options see: https://github.com/nats-io/stan.js
0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago