@graphql-mesh/plugin-hive 0.97.3 → 0.97.4
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/cjs/index.js +29 -19
- package/esm/index.js +29 -19
- package/package.json +4 -3
- package/typings/index.d.cts +6 -2
- package/typings/index.d.ts +6 -2
package/cjs/index.js
CHANGED
|
@@ -3,10 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const client_1 = require("@graphql-hive/client");
|
|
4
4
|
const cross_helpers_1 = require("@graphql-mesh/cross-helpers");
|
|
5
5
|
const string_interpolation_1 = require("@graphql-mesh/string-interpolation");
|
|
6
|
+
const utils_1 = require("@graphql-mesh/utils");
|
|
6
7
|
function useMeshHive(pluginOptions) {
|
|
7
8
|
const enabled = pluginOptions != null && 'enabled' in pluginOptions
|
|
8
|
-
?
|
|
9
|
-
|
|
9
|
+
? typeof pluginOptions.enabled === 'string'
|
|
10
|
+
? // eslint-disable-next-line no-new-func
|
|
11
|
+
new Function(`return ${pluginOptions.enabled}`)()
|
|
12
|
+
: pluginOptions.enabled
|
|
10
13
|
: true;
|
|
11
14
|
if (!enabled) {
|
|
12
15
|
return {};
|
|
@@ -27,18 +30,23 @@ function useMeshHive(pluginOptions) {
|
|
|
27
30
|
processVariables: pluginOptions.usage.processVariables,
|
|
28
31
|
};
|
|
29
32
|
if (pluginOptions.usage?.clientInfo) {
|
|
30
|
-
usage.clientInfo
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
if (typeof pluginOptions.usage.clientInfo === 'function') {
|
|
34
|
+
usage.clientInfo = pluginOptions.usage.clientInfo;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
usage.clientInfo = function (context) {
|
|
38
|
+
return {
|
|
39
|
+
name: string_interpolation_1.stringInterpolator.parse(pluginOptions.usage.clientInfo.name, {
|
|
40
|
+
context,
|
|
41
|
+
env: cross_helpers_1.process.env,
|
|
42
|
+
}),
|
|
43
|
+
version: string_interpolation_1.stringInterpolator.parse(pluginOptions.usage.clientInfo.version, {
|
|
44
|
+
context,
|
|
45
|
+
env: cross_helpers_1.process.env,
|
|
46
|
+
}),
|
|
47
|
+
};
|
|
40
48
|
};
|
|
41
|
-
}
|
|
49
|
+
}
|
|
42
50
|
}
|
|
43
51
|
}
|
|
44
52
|
let reporting;
|
|
@@ -57,12 +65,13 @@ function useMeshHive(pluginOptions) {
|
|
|
57
65
|
let agent;
|
|
58
66
|
if (pluginOptions.agent) {
|
|
59
67
|
agent = {
|
|
68
|
+
name: pluginOptions.agent.name,
|
|
60
69
|
timeout: pluginOptions.agent.timeout,
|
|
61
70
|
maxRetries: pluginOptions.agent.maxRetries,
|
|
62
71
|
minTimeout: pluginOptions.agent.minTimeout,
|
|
63
72
|
sendInterval: pluginOptions.agent.sendInterval,
|
|
64
73
|
maxSize: pluginOptions.agent.maxSize,
|
|
65
|
-
logger: pluginOptions.logger,
|
|
74
|
+
logger: pluginOptions.agent?.logger || pluginOptions.logger,
|
|
66
75
|
};
|
|
67
76
|
}
|
|
68
77
|
let selfHosting;
|
|
@@ -88,12 +97,13 @@ function useMeshHive(pluginOptions) {
|
|
|
88
97
|
reporting,
|
|
89
98
|
selfHosting,
|
|
90
99
|
});
|
|
91
|
-
|
|
92
|
-
hiveClient
|
|
100
|
+
function onTerminate() {
|
|
101
|
+
return hiveClient
|
|
93
102
|
.dispose()
|
|
94
|
-
.catch(e => pluginOptions.logger
|
|
95
|
-
|
|
96
|
-
|
|
103
|
+
.catch(e => pluginOptions.logger?.error(`Hive client failed to dispose`, e));
|
|
104
|
+
}
|
|
105
|
+
const id = pluginOptions.pubsub.subscribe('destroy', () => onTerminate().finally(() => pluginOptions.pubsub.unsubscribe(id)));
|
|
106
|
+
(0, utils_1.registerTerminateHandler)(onTerminate);
|
|
97
107
|
return {
|
|
98
108
|
onPluginInit({ addPlugin }) {
|
|
99
109
|
addPlugin((0, client_1.useYogaHive)(hiveClient));
|
package/esm/index.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { createHive, useYogaHive } from '@graphql-hive/client';
|
|
2
2
|
import { process } from '@graphql-mesh/cross-helpers';
|
|
3
3
|
import { stringInterpolator } from '@graphql-mesh/string-interpolation';
|
|
4
|
+
import { registerTerminateHandler } from '@graphql-mesh/utils';
|
|
4
5
|
export default function useMeshHive(pluginOptions) {
|
|
5
6
|
const enabled = pluginOptions != null && 'enabled' in pluginOptions
|
|
6
|
-
?
|
|
7
|
-
|
|
7
|
+
? typeof pluginOptions.enabled === 'string'
|
|
8
|
+
? // eslint-disable-next-line no-new-func
|
|
9
|
+
new Function(`return ${pluginOptions.enabled}`)()
|
|
10
|
+
: pluginOptions.enabled
|
|
8
11
|
: true;
|
|
9
12
|
if (!enabled) {
|
|
10
13
|
return {};
|
|
@@ -25,18 +28,23 @@ export default function useMeshHive(pluginOptions) {
|
|
|
25
28
|
processVariables: pluginOptions.usage.processVariables,
|
|
26
29
|
};
|
|
27
30
|
if (pluginOptions.usage?.clientInfo) {
|
|
28
|
-
usage.clientInfo
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
if (typeof pluginOptions.usage.clientInfo === 'function') {
|
|
32
|
+
usage.clientInfo = pluginOptions.usage.clientInfo;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
usage.clientInfo = function (context) {
|
|
36
|
+
return {
|
|
37
|
+
name: stringInterpolator.parse(pluginOptions.usage.clientInfo.name, {
|
|
38
|
+
context,
|
|
39
|
+
env: process.env,
|
|
40
|
+
}),
|
|
41
|
+
version: stringInterpolator.parse(pluginOptions.usage.clientInfo.version, {
|
|
42
|
+
context,
|
|
43
|
+
env: process.env,
|
|
44
|
+
}),
|
|
45
|
+
};
|
|
38
46
|
};
|
|
39
|
-
}
|
|
47
|
+
}
|
|
40
48
|
}
|
|
41
49
|
}
|
|
42
50
|
let reporting;
|
|
@@ -55,12 +63,13 @@ export default function useMeshHive(pluginOptions) {
|
|
|
55
63
|
let agent;
|
|
56
64
|
if (pluginOptions.agent) {
|
|
57
65
|
agent = {
|
|
66
|
+
name: pluginOptions.agent.name,
|
|
58
67
|
timeout: pluginOptions.agent.timeout,
|
|
59
68
|
maxRetries: pluginOptions.agent.maxRetries,
|
|
60
69
|
minTimeout: pluginOptions.agent.minTimeout,
|
|
61
70
|
sendInterval: pluginOptions.agent.sendInterval,
|
|
62
71
|
maxSize: pluginOptions.agent.maxSize,
|
|
63
|
-
logger: pluginOptions.logger,
|
|
72
|
+
logger: pluginOptions.agent?.logger || pluginOptions.logger,
|
|
64
73
|
};
|
|
65
74
|
}
|
|
66
75
|
let selfHosting;
|
|
@@ -86,12 +95,13 @@ export default function useMeshHive(pluginOptions) {
|
|
|
86
95
|
reporting,
|
|
87
96
|
selfHosting,
|
|
88
97
|
});
|
|
89
|
-
|
|
90
|
-
hiveClient
|
|
98
|
+
function onTerminate() {
|
|
99
|
+
return hiveClient
|
|
91
100
|
.dispose()
|
|
92
|
-
.catch(e => pluginOptions.logger
|
|
93
|
-
|
|
94
|
-
|
|
101
|
+
.catch(e => pluginOptions.logger?.error(`Hive client failed to dispose`, e));
|
|
102
|
+
}
|
|
103
|
+
const id = pluginOptions.pubsub.subscribe('destroy', () => onTerminate().finally(() => pluginOptions.pubsub.unsubscribe(id)));
|
|
104
|
+
registerTerminateHandler(onTerminate);
|
|
95
105
|
return {
|
|
96
106
|
onPluginInit({ addPlugin }) {
|
|
97
107
|
addPlugin(useYogaHive(hiveClient));
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-mesh/plugin-hive",
|
|
3
|
-
"version": "0.97.
|
|
3
|
+
"version": "0.97.4",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"@graphql-mesh/cross-helpers": "^0.4.1",
|
|
7
|
-
"@graphql-mesh/types": "^0.97.
|
|
7
|
+
"@graphql-mesh/types": "^0.97.4",
|
|
8
8
|
"graphql": "*",
|
|
9
9
|
"tslib": "^2.4.0"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@graphql-hive/client": "^0.28.0",
|
|
13
|
-
"@graphql-mesh/string-interpolation": "0.5.3"
|
|
13
|
+
"@graphql-mesh/string-interpolation": "0.5.3",
|
|
14
|
+
"@graphql-mesh/utils": "^0.97.4"
|
|
14
15
|
},
|
|
15
16
|
"repository": {
|
|
16
17
|
"type": "git",
|
package/typings/index.d.cts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Logger, MeshPlugin, YamlConfig } from '@graphql-mesh/types';
|
|
2
|
+
import { PubSub } from '@graphql-mesh/utils';
|
|
3
|
+
export default function useMeshHive(pluginOptions: YamlConfig.HivePlugin & {
|
|
4
|
+
logger?: Logger;
|
|
5
|
+
pubsub?: PubSub;
|
|
6
|
+
}): MeshPlugin<{}>;
|
package/typings/index.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Logger, MeshPlugin, YamlConfig } from '@graphql-mesh/types';
|
|
2
|
+
import { PubSub } from '@graphql-mesh/utils';
|
|
3
|
+
export default function useMeshHive(pluginOptions: YamlConfig.HivePlugin & {
|
|
4
|
+
logger?: Logger;
|
|
5
|
+
pubsub?: PubSub;
|
|
6
|
+
}): MeshPlugin<{}>;
|