1.0.3 • Published 2 years ago

graphql-subscription-manager v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

GraphQl Subscriber

Version npm CI Coverage Status

GraphQl subscriber is is a simple to use, fast, and reliable graphQl subscription implemented based on GraphQL over WebSocket Protocol

Table of Contents

Protocol support

  • HyBi drafts 07-12 (Use the option protocolVersion: 8)
  • HyBi drafts 13-17 (Current default, alternatively option protocolVersion: 13)

Installing

npm install graphql-subscriber

Creating a subscription

const SubscriptionManager = require("graphql-subscriber");
/**
 * @note if you are connecting to an `websocket` endpoint without a port
 * number, you can omit the port `parameter`
 * */
const client = new SubscriptionManager("ws:websocket-url", 4000);
/**
 * Create a subscription query `string`. The library only accept string at the moment
 * */
const sub = `subscription  {
                parcelGetPriceDone {
                    success
                    message
                    code
                    errorCode
                    data
                }
             }`;
client.subscribe({ query: sub, operationName: "parcelGetPriceDone" }, (data) =>
  /** A callback to process the subscription data */
);

License

MIT