1.3.0 • Published 2 years ago

@thekonz/apollo-lighthouse-subscription-link v1.3.0

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

Apollo Lighthouse Subscription Link

An apollo link to subscribe to Lighthouse graphql subscriptions using Laravel Echo presence channels.

Installation

npm install @thekonz/apollo-lighthouse-subscription-link
# or
yarn add @thekonz/apollo-lighthouse-subscription-link

Lighthouse compatibility

Lighthouse versionLink versionComment
5.2 and below1.1 and below
5.3 and above1.2 and aboveThe event name changed from 'lighthouse.subscription' to 'lighthouse-subscription'
5.3 and above1.3 and aboveSupport for 'lighthouse.subscription.version' = 2

Usage

import ApolloClient from "@apollo/client";
import gql from "graphql-tag";
import Echo from "laravel-echo";

import { createLighthouseSubscriptionLink } from "@thekonz/apollo-lighthouse-subscription-link";

const echoClient = new Echo({...});

const client = new ApolloClient({
  link: ApolloLink.from([
    createLighthouseSubscriptionLink(echoClient),
    httpLink, // your existing http link to your graphql api
  ]),
  cache: new InMemoryCache(),
});

const subscriber = client
  .subscribe({
    query: gql`
      subscription {
        postUpdated {
          id
          title
        }
      }
    `,
  })
  .subscribe((postUpdated) => {
    console.log(postUpdated); // { id: 2, title: "New title" }
  });

// stop listening to events
subscriber.unsubscribe()

Contributing and issues

Feel free to contribute to this package using the issue system and pull requests on the develop branch.

Automated unit tests must be added or changed to cover your changes or reproduce bugs.

2.0.0-rc.0

2 years ago

2.0.0-rc.1

2 years ago

1.3.0

2 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.5

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.0

4 years ago