Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Commit

Permalink
feat(NA): enclose wsclient creation inside addGraphQLWS function.
Browse files Browse the repository at this point in the history
  • Loading branch information
mistic committed Apr 20, 2017
1 parent a1fbc95 commit 10dafaf
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/helpers.ts
@@ -1,4 +1,4 @@
import { SubscriptionClient } from './client';
import { SubscriptionClient, ClientOptions } from './client';
import { ExecutionResult } from 'graphql';

/**
Expand All @@ -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<ExecutionResult> {
return wsClient.query(request);
Expand Down

0 comments on commit 10dafaf

Please sign in to comment.