diff --git a/src/helpers.ts b/src/helpers.ts index 2a85941eb..e7d82d4e9 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -1,4 +1,4 @@ -import { SubscriptionClient } from './client'; +import { SubscriptionClient, ClientOptions } from './client'; import { ExecutionResult } from 'graphql'; /** @@ -22,7 +22,12 @@ export function addGraphQLSubscriptions(networkInterface: any, wsClient: Subscri }); } -export function addGraphQLWS(networkInterface: any, wsClient: SubscriptionClient): any { +export function addGraphQLWS(networkInterface: any, wsClientOptions: ClientOptions): any { + if (typeof networkInterface._uri !== 'string') { + throw new Error('Given networkInterface should have an uri defined to config the websocket.'); + } + + const wsClient = new SubscriptionClient(networkInterface._uri, wsClientOptions); return Object.assign(addGraphQLSubscriptions(networkInterface, wsClient), { query(request: any): Promise { return wsClient.query(request);