@aaronpowell/graphql-signalr-subscriptions
TypeScript icon, indicating that this package has built-in type declarations

0.3.0 • Public • Published

SignalR GraphQL Subscriptions npm - SignalR package

This package contains support for Apollo GraphQL Subscriptions, using the Azure SignalR Service.

Installation

Install via npm or GitHub Packages:

$> npm install --save @aaronpowell/graphql-signalr-subscriptions

Usage

You'll need a SignalR Service account (if you don't have an Azure account sign up for free). Copy the connection string and provide it when you create an instance of SignalRPubSub:

import { SignalRPubSub } from "@aaronpowell/graphql-signalr-subscriptions";

const signalrPubSub = new SignalRPubSub("<connection string>");

When your server is ready, you can start the pubsub client:

signalrPubSub
  .start()
  .then(() => console.log("SignalR PubSub is up and running"))
  .catch((error) => console.error(error));

From within a resolver, you use it the same as any other pubsub implementation:

export const resolvers = {
  Query: {
    hello() {
      signalrPubSub.publish("TESTING", { getMessage: "Hello I'm a message" });
      return "Some message";
    },
  },
  Subscription: {
    getMessage: {
      subscribe: () => signalrPubSub.asyncIterator(["TESTING"]),
    },
  },
};

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.3.0
    4
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.3.0
    4
  • 0.2.0
    0
  • 0.1.1
    0

Package Sidebar

Install

npm i @aaronpowell/graphql-signalr-subscriptions

Weekly Downloads

4

Version

0.3.0

License

MIT

Unpacked Size

31.8 kB

Total Files

22

Last publish

Collaborators

  • aaronpowell