@envelop/statsd 0.2.0 → 0.3.2-alpha-33ac2d1.0
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/index.d.ts +1 -1
- package/index.js +3 -25
- package/index.mjs +1 -23
- package/package.json +5 -3
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -2,31 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
const core = require('@envelop/core');
|
|
5
6
|
const graphql = require('graphql');
|
|
6
7
|
|
|
7
|
-
/**
|
|
8
|
-
* Returns true if the provided object implements the AsyncIterator protocol via
|
|
9
|
-
* implementing a `Symbol.asyncIterator` method.
|
|
10
|
-
*
|
|
11
|
-
* Source: https://github.com/graphql/graphql-js/blob/main/src/jsutils/isAsyncIterable.ts
|
|
12
|
-
*/
|
|
13
|
-
function isAsyncIterable(maybeAsyncIterable) {
|
|
14
|
-
return (maybeAsyncIterable != null &&
|
|
15
|
-
typeof maybeAsyncIterable === 'object' &&
|
|
16
|
-
typeof maybeAsyncIterable[Symbol.asyncIterator] === 'function');
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* This enum is used only internally in order to create nominal type for the disabled plugin
|
|
21
|
-
*/
|
|
22
|
-
var EnableIfBranded;
|
|
23
|
-
(function (EnableIfBranded) {
|
|
24
|
-
EnableIfBranded[EnableIfBranded["DisabledPlugin"] = 0] = "DisabledPlugin";
|
|
25
|
-
})(EnableIfBranded || (EnableIfBranded = {}));
|
|
26
|
-
function isIntrospectionOperationString(operation) {
|
|
27
|
-
return (typeof operation === 'string' ? operation : operation.body).indexOf('__schema') !== -1;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
8
|
const metricNames = {
|
|
31
9
|
operationCount: 'operations.count',
|
|
32
10
|
errorCount: 'operations.error_count',
|
|
@@ -61,7 +39,7 @@ const useStatsD = (options) => {
|
|
|
61
39
|
});
|
|
62
40
|
},
|
|
63
41
|
onParse({ extendContext, params }) {
|
|
64
|
-
if (skipIntrospection && isIntrospectionOperationString(params.source)) {
|
|
42
|
+
if (skipIntrospection && core.isIntrospectionOperationString(params.source)) {
|
|
65
43
|
return;
|
|
66
44
|
}
|
|
67
45
|
return function onParseDone(payload) {
|
|
@@ -100,7 +78,7 @@ const useStatsD = (options) => {
|
|
|
100
78
|
return {
|
|
101
79
|
onExecuteDone({ result }) {
|
|
102
80
|
const latency = Date.now() - args.contextValue[statsDPluginExecutionStartTimeSymbol];
|
|
103
|
-
if (isAsyncIterable(result)) {
|
|
81
|
+
if (core.isAsyncIterable(result)) {
|
|
104
82
|
// eslint-disable-next-line no-console
|
|
105
83
|
console.warn(`Plugin "statsd" encountered a AsyncIterator which is not supported yet, so tracing data is not available for the operation.`);
|
|
106
84
|
return;
|
package/index.mjs
CHANGED
|
@@ -1,28 +1,6 @@
|
|
|
1
|
+
import { isIntrospectionOperationString, isAsyncIterable } from '@envelop/core';
|
|
1
2
|
import { Kind } from 'graphql';
|
|
2
3
|
|
|
3
|
-
/**
|
|
4
|
-
* Returns true if the provided object implements the AsyncIterator protocol via
|
|
5
|
-
* implementing a `Symbol.asyncIterator` method.
|
|
6
|
-
*
|
|
7
|
-
* Source: https://github.com/graphql/graphql-js/blob/main/src/jsutils/isAsyncIterable.ts
|
|
8
|
-
*/
|
|
9
|
-
function isAsyncIterable(maybeAsyncIterable) {
|
|
10
|
-
return (maybeAsyncIterable != null &&
|
|
11
|
-
typeof maybeAsyncIterable === 'object' &&
|
|
12
|
-
typeof maybeAsyncIterable[Symbol.asyncIterator] === 'function');
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* This enum is used only internally in order to create nominal type for the disabled plugin
|
|
17
|
-
*/
|
|
18
|
-
var EnableIfBranded;
|
|
19
|
-
(function (EnableIfBranded) {
|
|
20
|
-
EnableIfBranded[EnableIfBranded["DisabledPlugin"] = 0] = "DisabledPlugin";
|
|
21
|
-
})(EnableIfBranded || (EnableIfBranded = {}));
|
|
22
|
-
function isIntrospectionOperationString(operation) {
|
|
23
|
-
return (typeof operation === 'string' ? operation : operation.body).indexOf('__schema') !== -1;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
4
|
const metricNames = {
|
|
27
5
|
operationCount: 'operations.count',
|
|
28
6
|
errorCount: 'operations.error_count',
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@envelop/statsd",
|
|
3
|
-
"version": "0.2.0",
|
|
3
|
+
"version": "0.3.2-alpha-33ac2d1.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
|
+
"@envelop/core": "1.6.6-alpha-33ac2d1.0",
|
|
6
7
|
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0",
|
|
7
|
-
"hot-shots": "^8.0.0"
|
|
8
|
+
"hot-shots": "^8.0.0 || ^9.0.0"
|
|
8
9
|
},
|
|
9
10
|
"repository": {
|
|
10
11
|
"type": "git",
|
|
@@ -34,6 +35,7 @@
|
|
|
34
35
|
"./*": {
|
|
35
36
|
"require": "./*.js",
|
|
36
37
|
"import": "./*.mjs"
|
|
37
|
-
}
|
|
38
|
+
},
|
|
39
|
+
"./package.json": "./package.json"
|
|
38
40
|
}
|
|
39
41
|
}
|