@envelop/apollo-tracing 4.0.0-alpha-d0d0776.0 → 4.0.0-alpha-5b6bfa8.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/README.md CHANGED
@@ -17,15 +17,15 @@ yarn add @envelop/apollo-tracing
17
17
  ## Usage Example
18
18
 
19
19
  ```ts
20
- import { envelop } from '@envelop/core';
21
- import { useApolloTracing } from '@envelop/apollo-tracing';
20
+ import { envelop } from '@envelop/core'
21
+ import { useApolloTracing } from '@envelop/apollo-tracing'
22
22
 
23
23
  const getEnveloped = envelop({
24
24
  plugins: [
25
25
  // ... other plugins ...
26
- useApolloTracing(),
27
- ],
28
- });
26
+ useApolloTracing()
27
+ ]
28
+ })
29
29
  ```
30
30
 
31
31
  ## Notes
@@ -1,10 +1,8 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const core = require('@envelop/core');
6
- const graphql = require('graphql');
7
-
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useApolloTracing = void 0;
4
+ const core_1 = require("@envelop/core");
5
+ const graphql_1 = require("@graphql-tools/graphql");
8
6
  const HR_TO_NS = 1e9;
9
7
  const NS_TO_MS = 1e6;
10
8
  function durationHrTimeToNanos(hrtime) {
@@ -56,9 +54,11 @@ const useApolloTracing = () => {
56
54
  execution: {
57
55
  resolvers: ctx.resolversTiming.map(resolverCall => {
58
56
  const startOffset = durationHrTimeToNanos(resolverCall.startOffset);
59
- const duration = resolverCall.endOffset ? durationHrTimeToNanos(resolverCall.endOffset) - startOffset : 0;
57
+ const duration = resolverCall.endOffset
58
+ ? durationHrTimeToNanos(resolverCall.endOffset) - startOffset
59
+ : 0;
60
60
  return {
61
- path: [...graphql.responsePathAsArray(resolverCall.path)],
61
+ path: [...(0, graphql_1.responsePathAsArray)(resolverCall.path)],
62
62
  parentType: resolverCall.parentType.toString(),
63
63
  fieldName: resolverCall.fieldName,
64
64
  returnType: resolverCall.returnType.toString(),
@@ -68,7 +68,7 @@ const useApolloTracing = () => {
68
68
  }),
69
69
  },
70
70
  };
71
- return core.handleStreamOrSingleExecutionResult(payload, ({ result }) => {
71
+ return (0, core_1.handleStreamOrSingleExecutionResult)(payload, ({ result }) => {
72
72
  result.extensions = result.extensions || {};
73
73
  result.extensions.tracing = tracing;
74
74
  });
@@ -77,5 +77,4 @@ const useApolloTracing = () => {
77
77
  },
78
78
  };
79
79
  };
80
-
81
80
  exports.useApolloTracing = useApolloTracing;
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -1,6 +1,5 @@
1
1
  import { handleStreamOrSingleExecutionResult } from '@envelop/core';
2
- import { responsePathAsArray } from 'graphql';
3
-
2
+ import { responsePathAsArray } from '@graphql-tools/graphql';
4
3
  const HR_TO_NS = 1e9;
5
4
  const NS_TO_MS = 1e6;
6
5
  function durationHrTimeToNanos(hrtime) {
@@ -17,7 +16,7 @@ const deltaFrom = (hrtime) => {
17
16
  };
18
17
  };
19
18
  const apolloTracingSymbol = Symbol('apolloTracing');
20
- const useApolloTracing = () => {
19
+ export const useApolloTracing = () => {
21
20
  return {
22
21
  onResolverCalled: ({ info, context }) => {
23
22
  const ctx = context[apolloTracingSymbol];
@@ -52,7 +51,9 @@ const useApolloTracing = () => {
52
51
  execution: {
53
52
  resolvers: ctx.resolversTiming.map(resolverCall => {
54
53
  const startOffset = durationHrTimeToNanos(resolverCall.startOffset);
55
- const duration = resolverCall.endOffset ? durationHrTimeToNanos(resolverCall.endOffset) - startOffset : 0;
54
+ const duration = resolverCall.endOffset
55
+ ? durationHrTimeToNanos(resolverCall.endOffset) - startOffset
56
+ : 0;
56
57
  return {
57
58
  path: [...responsePathAsArray(resolverCall.path)],
58
59
  parentType: resolverCall.parentType.toString(),
@@ -73,5 +74,3 @@ const useApolloTracing = () => {
73
74
  },
74
75
  };
75
76
  };
76
-
77
- export { useApolloTracing };
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@envelop/apollo-tracing",
3
- "version": "4.0.0-alpha-d0d0776.0",
3
+ "version": "4.0.0-alpha-5b6bfa8.0",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
- "@envelop/core": "3.0.0-alpha-d0d0776.0",
7
- "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
6
+ "@envelop/core": "3.0.0-alpha-5b6bfa8.0",
7
+ "@graphql-tools/graphql": "0.1.0-alpha-33fb2950.0"
8
8
  },
9
9
  "dependencies": {
10
10
  "apollo-tracing": "^0.15.0"
@@ -16,33 +16,42 @@
16
16
  },
17
17
  "author": "Dotan Simha <dotansimha@gmail.com>",
18
18
  "license": "MIT",
19
- "main": "index.js",
20
- "module": "index.mjs",
21
- "typings": "index.d.ts",
19
+ "main": "cjs/index.js",
20
+ "module": "esm/index.js",
21
+ "typings": "typings/index.d.ts",
22
22
  "typescript": {
23
- "definition": "index.d.ts"
23
+ "definition": "typings/index.d.ts"
24
24
  },
25
+ "type": "module",
25
26
  "exports": {
26
27
  ".": {
27
28
  "require": {
28
- "default": "./index.js",
29
- "types": "./index.d.ts"
29
+ "types": "./typings/index.d.ts",
30
+ "default": "./cjs/index.js"
30
31
  },
31
32
  "import": {
32
- "default": "./index.mjs",
33
- "types": "./index.d.ts"
33
+ "types": "./typings/index.d.ts",
34
+ "default": "./esm/index.js"
35
+ },
36
+ "default": {
37
+ "types": "./typings/index.d.ts",
38
+ "default": "./esm/index.js"
34
39
  }
35
40
  },
36
41
  "./*": {
37
42
  "require": {
38
- "default": "./*.js",
39
- "types": "./*.d.ts"
43
+ "types": "./typings/*.d.ts",
44
+ "default": "./cjs/*.js"
40
45
  },
41
46
  "import": {
42
- "default": "./*.mjs",
43
- "types": "./*.d.ts"
47
+ "types": "./typings/*.d.ts",
48
+ "default": "./esm/*.js"
49
+ },
50
+ "default": {
51
+ "types": "./typings/*.d.ts",
52
+ "default": "./esm/*.js"
44
53
  }
45
54
  },
46
55
  "./package.json": "./package.json"
47
56
  }
48
- }
57
+ }
File without changes