Using Subscriptions
Gqlts has a built-in subscription client that returns an observable, Additional options are passed down to graphql-ws
import { createClient, everything } from './generated'
const client = createClient({
url: 'ws://my-url',
headers: {
Authorization: 'Bearer ...',
},
})
const { unsubscribe } = await client
.subscription({
user: {
...everything,
},
})
.subscribe({
next: (x) => console.log('next', x),
error: console.error,
})