@quesmed/types 1.4.25 → 1.4.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quesmed/types",
3
- "version": "1.4.25",
3
+ "version": "1.4.26",
4
4
  "description": "Typescript types for Quesmed",
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -33,7 +33,8 @@
33
33
  "react-native-expo-image-cache": "^4.1.0"
34
34
  },
35
35
  "peerDependencies": {
36
- "graphql": "^16",
36
+ "graphql": "^16.2.0",
37
+ "graphql-ws": "^5.5.5",
37
38
  "react": "^17"
38
39
  }
39
40
  }
package/utils/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './commonFunctions';
2
2
  export * from './lightgallery';
3
3
  export * from './offlineLink';
4
+ export * from './webSocketLink';
4
5
  export * from './wordsToNumber';
5
6
  import uuid from './uuid4';
6
7
  export declare const Uuid4: typeof uuid;
package/utils/index.js CHANGED
@@ -17,6 +17,7 @@ exports.Uuid4 = void 0;
17
17
  __exportStar(require("./commonFunctions"), exports);
18
18
  __exportStar(require("./lightgallery"), exports);
19
19
  __exportStar(require("./offlineLink"), exports);
20
+ __exportStar(require("./webSocketLink"), exports);
20
21
  __exportStar(require("./wordsToNumber"), exports);
21
22
  const uuid4_1 = __importDefault(require("./uuid4"));
22
23
  exports.Uuid4 = uuid4_1.default;
package/utils/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './commonFunctions';
2
2
  export * from './lightgallery';
3
3
  export * from './offlineLink';
4
+ export * from './webSocketLink';
4
5
  export * from './wordsToNumber';
5
6
  import uuid from './uuid4';
6
7
  export const Uuid4 = uuid;
@@ -0,0 +1,7 @@
1
+ import { ApolloLink, FetchResult, Observable, Operation } from '@apollo/client/core';
2
+ import { ClientOptions } from 'graphql-ws';
3
+ export declare class WebSocketLink extends ApolloLink {
4
+ private client;
5
+ constructor(options: ClientOptions);
6
+ request(operation: Operation): Observable<FetchResult>;
7
+ }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WebSocketLink = void 0;
4
+ const core_1 = require("@apollo/client/core");
5
+ const graphql_1 = require("graphql");
6
+ const graphql_ws_1 = require("graphql-ws");
7
+ class WebSocketLink extends core_1.ApolloLink {
8
+ constructor(options) {
9
+ super();
10
+ this.client = (0, graphql_ws_1.createClient)(options);
11
+ }
12
+ request(operation) {
13
+ return new core_1.Observable((sink) => {
14
+ return this.client.subscribe(Object.assign(Object.assign({}, operation), { query: (0, graphql_1.print)(operation.query) }), {
15
+ next: sink.next.bind(sink),
16
+ complete: sink.complete.bind(sink),
17
+ error: sink.error.bind(sink),
18
+ });
19
+ });
20
+ }
21
+ }
22
+ exports.WebSocketLink = WebSocketLink;
@@ -0,0 +1,18 @@
1
+ import { ApolloLink, Observable, } from '@apollo/client/core';
2
+ import { print } from 'graphql';
3
+ import { createClient } from 'graphql-ws';
4
+ export class WebSocketLink extends ApolloLink {
5
+ constructor(options) {
6
+ super();
7
+ this.client = createClient(options);
8
+ }
9
+ request(operation) {
10
+ return new Observable((sink) => {
11
+ return this.client.subscribe(Object.assign(Object.assign({}, operation), { query: print(operation.query) }), {
12
+ next: sink.next.bind(sink),
13
+ complete: sink.complete.bind(sink),
14
+ error: sink.error.bind(sink),
15
+ });
16
+ });
17
+ }
18
+ }