Skip to content

Commit

Permalink
fix: TG subscribtion
Browse files Browse the repository at this point in the history
  • Loading branch information
simonas-notcat committed Nov 28, 2019
1 parent 12f8115 commit 5334fc6
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions packages/daf-trust-graph/src/service-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { WebSocketLink } from 'apollo-link-ws'
import { getMainDefinition } from 'apollo-utilities'
import { split } from 'apollo-link'
import { createJWT } from 'did-jwt'
import { SubscriptionClient } from 'subscriptions-transport-ws'

import { ServiceController, ServiceControllerOptions, ServiceInstanceId } from 'daf-core'
import * as queries from './queries'
Expand Down Expand Up @@ -52,17 +53,23 @@ export class TrustGraphServiceController implements ServiceController {
var link = null

if (wsUri) {
const wsLink = new WebSocketLink({
uri: wsUri,
options: {
debug('Using SubscriptionClient')

const wsClient = new SubscriptionClient(
wsUri,
{
lazy: true,
reconnect: true,
connectionParams: async () => {
const token = await this.getAuthToken()
return { authorization: `Bearer ${token}` }
},
},
webSocketImpl: this.options.config.webSocketImpl,
})
this.options.config.webSocketImpl,
[],
)

const wsLink = new WebSocketLink(wsClient)

link = split(
// split based on operation type
Expand Down

0 comments on commit 5334fc6

Please sign in to comment.