@rxdi/graphql-pubsub 0.7.134 → 0.7.137
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/dist/helpers/index.d.ts +3 -3
- package/dist/helpers/index.js +16 -17
- package/package.json +7 -7
package/dist/helpers/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DocumentNode } from 'apollo
|
|
2
|
-
import { WebSocketLink } from 'apollo
|
|
1
|
+
import { DocumentNode } from '@apollo/client/core';
|
|
2
|
+
import { WebSocketLink } from '@apollo/client/link/ws';
|
|
3
3
|
import { ClientOptions } from 'subscriptions-transport-ws';
|
|
4
4
|
import { Server } from 'hapi';
|
|
5
5
|
import { Observable } from 'rxjs';
|
|
@@ -12,4 +12,4 @@ export interface ExtendedServer extends Server {
|
|
|
12
12
|
}
|
|
13
13
|
export declare const createWebsocketLink: (options?: WSLinkOptions) => WebSocketLink;
|
|
14
14
|
export declare const subscribeToTopic: <T, V = any>(query: DocumentNode, variables?: V, link?: WebSocketLink) => Observable<T>;
|
|
15
|
-
export { WebSocketLink } from 'apollo
|
|
15
|
+
export { WebSocketLink } from '@apollo/client/link/ws';
|
package/dist/helpers/index.js
CHANGED
|
@@ -1,50 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WebSocketLink = exports.subscribeToTopic = exports.createWebsocketLink = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
4
|
+
const core_1 = require("@apollo/client/core");
|
|
5
|
+
const ws_1 = require("@apollo/client/link/ws");
|
|
6
|
+
const core_2 = require("@rxdi/core");
|
|
7
7
|
const hapi_1 = require("@rxdi/hapi");
|
|
8
8
|
const rxjs_1 = require("rxjs");
|
|
9
9
|
const ws = require('ws');
|
|
10
10
|
const createWebsocketLink = (options = { uri: 'ws://localhost:9000/subscriptions' }) => {
|
|
11
11
|
let server;
|
|
12
12
|
try {
|
|
13
|
-
server =
|
|
13
|
+
server = core_2.Container.get(options.server || hapi_1.HAPI_SERVER);
|
|
14
14
|
}
|
|
15
15
|
catch (e) { }
|
|
16
16
|
if (server) {
|
|
17
|
-
options.uri = `ws://localhost:${server.info.port ||
|
|
18
|
-
server.port}/subscriptions`;
|
|
17
|
+
options.uri = `ws://localhost:${server.info.port || server.port}/subscriptions`;
|
|
19
18
|
}
|
|
20
|
-
if (!
|
|
21
|
-
|
|
19
|
+
if (!core_2.Container.has(ws_1.WebSocketLink)) {
|
|
20
|
+
core_2.Container.set(ws_1.WebSocketLink, new ws_1.WebSocketLink({
|
|
22
21
|
uri: options.uri,
|
|
23
22
|
options: options || {
|
|
24
|
-
reconnect: true
|
|
23
|
+
reconnect: true,
|
|
25
24
|
},
|
|
26
|
-
webSocketImpl: ws
|
|
25
|
+
webSocketImpl: ws,
|
|
27
26
|
}));
|
|
28
27
|
}
|
|
29
|
-
return
|
|
28
|
+
return core_2.Container.get(ws_1.WebSocketLink);
|
|
30
29
|
};
|
|
31
30
|
exports.createWebsocketLink = createWebsocketLink;
|
|
32
31
|
const subscribeToTopic = (query, variables, link) => {
|
|
33
|
-
return new rxjs_1.Observable(o => {
|
|
34
|
-
const cmd = (0,
|
|
32
|
+
return new rxjs_1.Observable((o) => {
|
|
33
|
+
const cmd = (0, core_1.execute)(link || (0, exports.createWebsocketLink)(), {
|
|
35
34
|
query,
|
|
36
|
-
variables
|
|
35
|
+
variables,
|
|
37
36
|
}).subscribe({
|
|
38
37
|
next: o.next.bind(o),
|
|
39
38
|
error: o.error.bind(o),
|
|
40
|
-
complete: o.complete.bind(o)
|
|
39
|
+
complete: o.complete.bind(o),
|
|
41
40
|
});
|
|
42
41
|
return () => cmd.unsubscribe();
|
|
43
42
|
});
|
|
44
43
|
};
|
|
45
44
|
exports.subscribeToTopic = subscribeToTopic;
|
|
46
|
-
var
|
|
47
|
-
Object.defineProperty(exports, "WebSocketLink", { enumerable: true, get: function () { return
|
|
45
|
+
var ws_2 = require("@apollo/client/link/ws");
|
|
46
|
+
Object.defineProperty(exports, "WebSocketLink", { enumerable: true, get: function () { return ws_2.WebSocketLink; } });
|
|
48
47
|
// const subscription = subscribeToTopic<{data: {statusSubscription: { status: string }}}>(gql`
|
|
49
48
|
// subscription {
|
|
50
49
|
// statusSubscription {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rxdi/graphql-pubsub",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.137",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/rxdi/graphql-pubsub"
|
|
@@ -30,16 +30,16 @@
|
|
|
30
30
|
},
|
|
31
31
|
"homepage": "https://github.com/rxdi/graphql-pubsub#readme",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@rxdi/graphql-rabbitmq-subscriptions": "^0.7.
|
|
34
|
-
"apollo
|
|
33
|
+
"@rxdi/graphql-rabbitmq-subscriptions": "^0.7.136",
|
|
34
|
+
"@apollo/client": "^3.4.16",
|
|
35
35
|
"graphql-request": "^1.8.2",
|
|
36
|
-
"subscriptions-transport-ws": "^0.9.
|
|
36
|
+
"subscriptions-transport-ws": "^0.9.19",
|
|
37
37
|
"ws": "6.2.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@rxdi/core": "^0.7.
|
|
41
|
-
"@rxdi/graphql": "^0.7.
|
|
42
|
-
"@rxdi/hapi": "^0.7.
|
|
40
|
+
"@rxdi/core": "^0.7.136",
|
|
41
|
+
"@rxdi/graphql": "^0.7.136",
|
|
42
|
+
"@rxdi/hapi": "^0.7.136",
|
|
43
43
|
"@types/graphql": "^14.5.0",
|
|
44
44
|
"@types/hapi": "^18.0.4",
|
|
45
45
|
"@types/jest": "^24.0.22",
|