apollo-pusher-link
v0.1.1
Published
pusher link for apollo client
Downloads
535
Readme
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*/