UNPKG

2.01 kBSource Map (JSON)View Raw
1{"version":3,"file":"bundle.umd.js","sources":["../src/webSocketLink.ts"],"sourcesContent":["import { ApolloLink, Operation, FetchResult, Observable } from 'apollo-link';\n\nimport { SubscriptionClient, ClientOptions } from 'subscriptions-transport-ws';\n\nexport namespace WebSocketLink {\n /**\n * Configuration to use when constructing the subscription client (subscriptions-transport-ws).\n */\n export interface Configuration {\n /**\n * The endpoint to connect to.\n */\n uri: string;\n\n /**\n * Options to pass when constructing the subscription client.\n */\n options?: ClientOptions;\n\n /**\n * A custom WebSocket implementation to use.\n */\n webSocketImpl?: any;\n }\n}\n\n// For backwards compatibility.\nexport import WebSocketParams = WebSocketLink.Configuration;\n\nexport class WebSocketLink extends ApolloLink {\n private subscriptionClient: SubscriptionClient;\n\n constructor(\n paramsOrClient: WebSocketLink.Configuration | SubscriptionClient,\n ) {\n super();\n\n if (paramsOrClient instanceof SubscriptionClient) {\n this.subscriptionClient = paramsOrClient;\n } else {\n this.subscriptionClient = new SubscriptionClient(\n paramsOrClient.uri,\n paramsOrClient.options,\n paramsOrClient.webSocketImpl,\n );\n }\n }\n\n public request(operation: Operation): Observable<FetchResult> | null {\n return this.subscriptionClient.request(operation) as Observable<\n FetchResult\n >;\n }\n}\n"],"names":["SubscriptionClient","ApolloLink"],"mappings":";;;;;;;;;;;;;;;;AAAA;QA6BmC,iCAAU;QAG3C,uBACE,cAAgE;YADlE,YAGE,iBAAO,SAWR;YATC,IAAI,cAAc,YAAYA,2CAAkB,EAAE;gBAChD,KAAI,CAAC,kBAAkB,GAAG,cAAc,CAAC;aAC1C;iBAAM;gBACL,KAAI,CAAC,kBAAkB,GAAG,IAAIA,2CAAkB,CAC9C,cAAc,CAAC,GAAG,EAClB,cAAc,CAAC,OAAO,EACtB,cAAc,CAAC,aAAa,CAC7B,CAAC;aACH;;SACF;QAEM,+BAAO,GAAd,UAAe,SAAoB;YACjC,OAAO,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,SAAS,CAE/C,CAAC;SACH;QACH,oBAAC;IAAD,CAAC,CAxBkCC,qBAAU;;;;;;;;;;;;"}
\No newline at end of file