@rxdi/graphql-pubsub 0.7.199 → 0.7.201
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/README.md +0 -1
- package/dist/config.tokens.d.ts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/services/pub-sub.service.d.ts +1 -2
- package/dist/services/pub-sub.service.js +0 -7
- package/package.json +6 -9
- package/dist/helpers/index.d.ts +0 -15
- package/dist/helpers/index.js +0 -58
- package/dist/services/remote-pubsub.service.d.ts +0 -11
- package/dist/services/remote-pubsub.service.js +0 -33
package/README.md
CHANGED
package/dist/config.tokens.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -50,4 +50,3 @@ exports.GraphQLPubSubModule = GraphQLPubSubModule = GraphQLPubSubModule_1 = __de
|
|
|
50
50
|
__exportStar(require("./config.tokens"), exports);
|
|
51
51
|
__exportStar(require("./decorators/index"), exports);
|
|
52
52
|
__exportStar(require("./services/index"), exports);
|
|
53
|
-
__exportStar(require("./helpers/index"), exports);
|
|
@@ -3,11 +3,10 @@ import { AmqpPubSub } from "@rxdi/graphql-rabbitmq-subscriptions";
|
|
|
3
3
|
import { GRAPHQL_PUB_SUB_DI_CONFIG } from "../config.tokens";
|
|
4
4
|
import { PubSubLogger } from "./logger.service";
|
|
5
5
|
export declare let pubsub: PubSub | AmqpPubSub;
|
|
6
|
-
import { RemotePubsub } from "./remote-pubsub.service";
|
|
7
6
|
export declare class PubSubService {
|
|
8
7
|
private config;
|
|
9
8
|
private logger;
|
|
10
|
-
sub: AmqpPubSub | PubSub
|
|
9
|
+
sub: AmqpPubSub | PubSub;
|
|
11
10
|
constructor(config: GRAPHQL_PUB_SUB_DI_CONFIG, logger: PubSubLogger);
|
|
12
11
|
asyncIterator<T>(event: any, options?: any): AsyncIterator<T>;
|
|
13
12
|
publish(signal: string, data: any): Promise<void>;
|
|
@@ -18,7 +18,6 @@ const graphql_rabbitmq_subscriptions_1 = require("@rxdi/graphql-rabbitmq-subscri
|
|
|
18
18
|
const core_1 = require("@rxdi/core");
|
|
19
19
|
const config_tokens_1 = require("../config.tokens");
|
|
20
20
|
const logger_service_1 = require("./logger.service");
|
|
21
|
-
const remote_pubsub_service_1 = require("./remote-pubsub.service");
|
|
22
21
|
let PubSubService = class PubSubService {
|
|
23
22
|
constructor(config, logger) {
|
|
24
23
|
this.config = config;
|
|
@@ -26,12 +25,6 @@ let PubSubService = class PubSubService {
|
|
|
26
25
|
if (this.config.pubsub) {
|
|
27
26
|
this.sub = this.config.pubsub;
|
|
28
27
|
}
|
|
29
|
-
else if (this.config.remotePubsub) {
|
|
30
|
-
this.sub = new remote_pubsub_service_1.RemotePubsub({
|
|
31
|
-
host: this.config.host,
|
|
32
|
-
port: this.config.host,
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
28
|
else if (this.config.activateRabbitMQ) {
|
|
36
29
|
this.sub = new graphql_rabbitmq_subscriptions_1.AmqpPubSub({
|
|
37
30
|
config: `amqp://${this.config.user || process.env.AMQP_USER || "guest"}:${this.config.pass || "guest"}@${this.config.host || process.env.AMQP_HOST || "localhost"}:${this.config.port || process.env.AMQP_PORT || "5672"}`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rxdi/graphql-pubsub",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.201",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/rxdi/graphql-pubsub"
|
|
@@ -30,16 +30,13 @@
|
|
|
30
30
|
},
|
|
31
31
|
"homepage": "https://github.com/rxdi/graphql-pubsub#readme",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@rxdi/graphql-rabbitmq-subscriptions": "^0.7.
|
|
34
|
-
"
|
|
35
|
-
"graphql-request": "^1.8.2",
|
|
36
|
-
"subscriptions-transport-ws": "^0.9.19",
|
|
37
|
-
"ws": "6.2.1"
|
|
33
|
+
"@rxdi/graphql-rabbitmq-subscriptions": "^0.7.200",
|
|
34
|
+
"subscriptions-transport-ws": "^0.9.19"
|
|
38
35
|
},
|
|
39
36
|
"devDependencies": {
|
|
40
|
-
"@rxdi/core": "^0.7.
|
|
41
|
-
"@rxdi/graphql": "^0.7.
|
|
42
|
-
"@rxdi/hapi": "^0.7.
|
|
37
|
+
"@rxdi/core": "^0.7.200",
|
|
38
|
+
"@rxdi/graphql": "^0.7.200",
|
|
39
|
+
"@rxdi/hapi": "^0.7.200",
|
|
43
40
|
"@types/graphql": "^14.5.0",
|
|
44
41
|
"@types/hapi": "^18.0.4",
|
|
45
42
|
"@types/jest": "^24.0.22",
|
package/dist/helpers/index.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { DocumentNode } from '@apollo/client/core';
|
|
2
|
-
import { WebSocketLink } from '@apollo/client/link/ws';
|
|
3
|
-
import { ClientOptions } from 'subscriptions-transport-ws';
|
|
4
|
-
import { Server } from '@hapi/hapi';
|
|
5
|
-
import { Observable } from 'rxjs';
|
|
6
|
-
export interface WSLinkOptions extends ClientOptions {
|
|
7
|
-
server?: any;
|
|
8
|
-
uri: string;
|
|
9
|
-
}
|
|
10
|
-
export interface ExtendedServer extends Server {
|
|
11
|
-
port: number | string;
|
|
12
|
-
}
|
|
13
|
-
export declare const createWebsocketLink: (options?: WSLinkOptions) => WebSocketLink;
|
|
14
|
-
export declare const subscribeToTopic: <T, V = any>(query: DocumentNode, variables?: V, link?: WebSocketLink) => Observable<T>;
|
|
15
|
-
export { WebSocketLink } from '@apollo/client/link/ws';
|
package/dist/helpers/index.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WebSocketLink = exports.subscribeToTopic = exports.createWebsocketLink = void 0;
|
|
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
|
-
const hapi_1 = require("@rxdi/hapi");
|
|
8
|
-
const rxjs_1 = require("rxjs");
|
|
9
|
-
const ws = require('ws');
|
|
10
|
-
const createWebsocketLink = (options = { uri: 'ws://localhost:9000/subscriptions' }) => {
|
|
11
|
-
let server;
|
|
12
|
-
try {
|
|
13
|
-
server = core_2.Container.get(options.server || hapi_1.HAPI_SERVER);
|
|
14
|
-
}
|
|
15
|
-
catch (e) { }
|
|
16
|
-
if (server) {
|
|
17
|
-
options.uri = `ws://localhost:${server.info.port || server.port}/subscriptions`;
|
|
18
|
-
}
|
|
19
|
-
if (!core_2.Container.has(ws_1.WebSocketLink)) {
|
|
20
|
-
core_2.Container.set(ws_1.WebSocketLink, new ws_1.WebSocketLink({
|
|
21
|
-
uri: options.uri,
|
|
22
|
-
options: options || {
|
|
23
|
-
reconnect: true,
|
|
24
|
-
},
|
|
25
|
-
webSocketImpl: ws,
|
|
26
|
-
}));
|
|
27
|
-
}
|
|
28
|
-
return core_2.Container.get(ws_1.WebSocketLink);
|
|
29
|
-
};
|
|
30
|
-
exports.createWebsocketLink = createWebsocketLink;
|
|
31
|
-
const subscribeToTopic = (query, variables, link) => {
|
|
32
|
-
return new rxjs_1.Observable((o) => {
|
|
33
|
-
const cmd = (0, core_1.execute)(link || (0, exports.createWebsocketLink)(), {
|
|
34
|
-
query,
|
|
35
|
-
variables,
|
|
36
|
-
}).subscribe({
|
|
37
|
-
next: o.next.bind(o),
|
|
38
|
-
error: o.error.bind(o),
|
|
39
|
-
complete: o.complete.bind(o),
|
|
40
|
-
});
|
|
41
|
-
return () => cmd.unsubscribe();
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
exports.subscribeToTopic = subscribeToTopic;
|
|
45
|
-
var ws_2 = require("@apollo/client/link/ws");
|
|
46
|
-
Object.defineProperty(exports, "WebSocketLink", { enumerable: true, get: function () { return ws_2.WebSocketLink; } });
|
|
47
|
-
// const subscription = subscribeToTopic<{data: {statusSubscription: { status: string }}}>(gql`
|
|
48
|
-
// subscription {
|
|
49
|
-
// statusSubscription {
|
|
50
|
-
// status
|
|
51
|
-
// }
|
|
52
|
-
// }
|
|
53
|
-
// `).subscribe(stream => {
|
|
54
|
-
// console.log(stream.data.statusSubscription.status);
|
|
55
|
-
// });
|
|
56
|
-
// setTimeout(() => {
|
|
57
|
-
// subscription.unsubscribe();
|
|
58
|
-
// }, 5000);
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { GraphQLClient } from 'graphql-request';
|
|
2
|
-
import { GRAPHQL_PUB_SUB_DI_CONFIG } from '../config.tokens';
|
|
3
|
-
import { PubSub } from 'graphql-subscriptions';
|
|
4
|
-
export declare class RemotePubsub extends PubSub {
|
|
5
|
-
config: GRAPHQL_PUB_SUB_DI_CONFIG;
|
|
6
|
-
client: GraphQLClient;
|
|
7
|
-
defaultQuery: string;
|
|
8
|
-
constructor(config: GRAPHQL_PUB_SUB_DI_CONFIG);
|
|
9
|
-
notifier(signal?: string, payload?: Object): Promise<unknown>;
|
|
10
|
-
publish(signal: string, data: any): Promise<any>;
|
|
11
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RemotePubsub = void 0;
|
|
4
|
-
const graphql_request_1 = require("graphql-request");
|
|
5
|
-
const graphql_subscriptions_1 = require("graphql-subscriptions");
|
|
6
|
-
class RemotePubsub extends graphql_subscriptions_1.PubSub {
|
|
7
|
-
constructor(config) {
|
|
8
|
-
super();
|
|
9
|
-
this.defaultQuery = `{
|
|
10
|
-
mutation publishSignal($signal: String!, $payload: JSON) {
|
|
11
|
-
publishSignal(signal: $signal, payload: $payload) {
|
|
12
|
-
status
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}`;
|
|
16
|
-
this.config = config;
|
|
17
|
-
this.client = new graphql_request_1.GraphQLClient(`${this.config.host}:${this.config.port}`, {
|
|
18
|
-
headers: {
|
|
19
|
-
Authorization: ''
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
notifier(signal = '', payload = {}) {
|
|
24
|
-
return this.client.request(this.config.query || this.defaultQuery, {
|
|
25
|
-
signal,
|
|
26
|
-
payload
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
publish(signal, data) {
|
|
30
|
-
return this.notifier(signal, data);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.RemotePubsub = RemotePubsub;
|