0.1.1 • Published 1 year ago

apollo-pusher-link v0.1.1

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

apollo-pusher-link

Installation

yarn add apollo-pusher-link
# or
npm i apollo-pusher-link

Configuration

import { from } from '@apollo/client'
import Pusher from 'pusher-js'

const pusherClient = new Pusher(APP_KEY, {
  cluster: APP_CLUSTER,
  authEndpoint: AUTH_ENDPOINT,
})

const pusherLink = new PusherLink({ pusher: pusherClient })

const link = from([
  pusherLink,
  // ... other links
])

const client = new ApolloClient({
  link,
  // Provide required constructor fields
  // uri:
  // cache:
})

Usage

const subscription = client.subscribe({
  variables: { /*variables*/ },
  query: gql`
    subscription someSubscription {
      someSubscription {
        id
      }
    }
`,
})

const unsubscribe = subscription.subscribe({ next: ({ data, errors }) => {
  // Do something
}})

// unsubscribe() /*run unsubscribe when needed*/ 

License

MIT

0.1.1

1 year ago

0.1.0

2 years ago