import { ApolloLink , Operation , FetchResult , Observable } from 'apollo-link' ; import { SubscriptionClient , ClientOptions } from 'subscriptions-transport-ws' ; export namespace WebSocketLink { /**
     * Configuration to use when constructing the subscription client (subscriptions-transport-ws).
     */ export interface Configuration { /**
         * The endpoint to connect to.
         */ uri : string ; /**
         * Options to pass when constructing the subscription client.
         */ options ? : ClientOptions ; /**
         * A custom WebSocket implementation to use.
         */ webSocketImpl ? : any ; } } export import WebSocketParams = WebSocketLink . Configuration ; export class WebSocketLink extends ApolloLink { private subscriptionClient : SubscriptionClient ; constructor ( paramsOrClient ) { super ( ) ; if ( paramsOrClient instanceof SubscriptionClient ) { this . subscriptionClient = paramsOrClient ; } else { this . subscriptionClient = new SubscriptionClient ( paramsOrClient . uri , paramsOrClient . options , paramsOrClient . webSocketImpl ) ; } } public request ( operation ) { return this . subscriptionClient . request ( operation ) as Observable < FetchResult > ; } }