@graphql-hive/gateway 2.0.0-alpha-d672d11878c307e7a0fd28512903cb25f048a83f → 2.0.0-alpha-7125411993448274610947015e30dd5b3461ded1
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/CHANGELOG.md +94 -24
- package/dist/bin.cjs +2 -1
- package/dist/bin.js +2 -1
- package/dist/{cli-BQ10GobO.cjs → cli-3udwdx7_.cjs} +218 -21
- package/dist/{cli-CpJrCTMy.js → cli-DcLVI5BX.js} +219 -22
- package/dist/index.cjs +2 -1
- package/dist/index.d.cts +14 -2
- package/dist/index.d.ts +14 -2
- package/dist/index.js +2 -1
- package/package.json +19 -17
package/CHANGELOG.md
CHANGED
@@ -1,35 +1,96 @@
|
|
1
1
|
# @graphql-hive/gateway
|
2
2
|
|
3
|
-
## 2.0.0-alpha-
|
3
|
+
## 2.0.0-alpha-7125411993448274610947015e30dd5b3461ded1
|
4
4
|
|
5
5
|
### Major Changes
|
6
6
|
|
7
|
-
- [#956](https://github.com/graphql-hive/gateway/pull/956) [`
|
7
|
+
- [#956](https://github.com/graphql-hive/gateway/pull/956) [`8273fde`](https://github.com/graphql-hive/gateway/commit/8273fde686a666fa7f974ad4f9084f8b9cb0df57) Thanks [@EmrysMyrddin](https://github.com/EmrysMyrddin)! - Drop Node 18 support
|
8
8
|
|
9
9
|
Least supported Node version is now v20.
|
10
10
|
|
11
|
-
- [#956](https://github.com/graphql-hive/gateway/pull/956) [`
|
11
|
+
- [#956](https://github.com/graphql-hive/gateway/pull/956) [`32fbb7b`](https://github.com/graphql-hive/gateway/commit/32fbb7b3aefe9228c29c6f7b2a785406f21d3e24) Thanks [@EmrysMyrddin](https://github.com/EmrysMyrddin)! - Introduce and use the new Hive Logger
|
12
12
|
- [Read more about it on the Hive Logger documentation here.](https://the-guild.dev/graphql/hive/docs/logger)
|
13
13
|
- If coming from Hive Gateway v1, [read the migration guide here.](https://the-guild.dev/graphql/hive/docs/migration-guides/gateway-v1-v2)
|
14
14
|
|
15
|
-
- [#956](https://github.com/graphql-hive/gateway/pull/956) [`
|
15
|
+
- [#956](https://github.com/graphql-hive/gateway/pull/956) [`55580af`](https://github.com/graphql-hive/gateway/commit/55580af626e67cfc618b74201ef5ea3f6fd90758) Thanks [@EmrysMyrddin](https://github.com/EmrysMyrddin)! - Disable forking even if NODE_ENV=production
|
16
16
|
|
17
17
|
Forking workers for concurrent processing is a delicate process and if not done carefully can lead to performance degradations. It should be configured with careful consideration by advanced users.
|
18
18
|
|
19
|
-
- [#956](https://github.com/graphql-hive/gateway/pull/956) [`
|
19
|
+
- [#956](https://github.com/graphql-hive/gateway/pull/956) [`f63ea40`](https://github.com/graphql-hive/gateway/commit/f63ea40d976638557ef72468c8773c71a8f38f8c) Thanks [@EmrysMyrddin](https://github.com/EmrysMyrddin)! - Remove mocking plugin from Hive Gateway built-ins
|
20
20
|
|
21
21
|
There is no need to provide the `useMock` plugin alongside Hive Gateway built-ins. Not only is the mock plugin 2MB in size (minified), but installing and using it is very simple.
|
22
22
|
|
23
|
-
- [#956](https://github.com/graphql-hive/gateway/pull/956) [`
|
23
|
+
- [#956](https://github.com/graphql-hive/gateway/pull/956) [`3699f15`](https://github.com/graphql-hive/gateway/commit/3699f15d53a26cc3bd5b5f1cec57fc6902d3884e) Thanks [@EmrysMyrddin](https://github.com/EmrysMyrddin)! - Load schema on initialization
|
24
24
|
|
25
25
|
Failing to start if the schema is not loaded for whatever reason.
|
26
26
|
|
27
|
+
### Minor Changes
|
28
|
+
|
29
|
+
- [#1310](https://github.com/graphql-hive/gateway/pull/1310) [`2fa0c8f`](https://github.com/graphql-hive/gateway/commit/2fa0c8f1dd074c9da8e6ac4086eb3009be9fdf07) Thanks [@EmrysMyrddin](https://github.com/EmrysMyrddin)! - Added new `withState` plugin utility for easy data sharing between hooks.
|
30
|
+
|
31
|
+
## New plugin utility to ease data sharing between hooks
|
32
|
+
|
33
|
+
Sometimes, plugins can grow in complexity and need to share data between its hooks.
|
34
|
+
|
35
|
+
A way to solve this can be to mutate the graphql context, but this context is not always available
|
36
|
+
in all hooks in Yoga or Hive Gateway plugins. Moreover, mutating the context gives access to your
|
37
|
+
internal data to all other plugins and graphql resolvers, without mentioning performance impact on
|
38
|
+
field access on this object.
|
39
|
+
|
40
|
+
The recommended approach to this problem was to use a `WeakMap` with a stable key (often the
|
41
|
+
`context` or `request` object). While it works, it's not very convenient for plugin developers, and
|
42
|
+
is prone to error with the choice of key.
|
43
|
+
|
44
|
+
The new `withState` utility solves this DX issue by providing an easy and straightforward API for
|
45
|
+
data sharing between hooks.
|
46
|
+
|
47
|
+
```ts
|
48
|
+
import { withState } from '@graphql-hive/gateway';
|
49
|
+
|
50
|
+
type State = { foo: string };
|
51
|
+
|
52
|
+
const myPlugin = () =>
|
53
|
+
withState<Plugin, State>(() => ({
|
54
|
+
onParse({ state }) {
|
55
|
+
state.forOperation.foo = 'foo';
|
56
|
+
},
|
57
|
+
onValidate({ state }) {
|
58
|
+
const { foo } = state.forOperation;
|
59
|
+
console.log('foo', foo);
|
60
|
+
},
|
61
|
+
}));
|
62
|
+
```
|
63
|
+
|
64
|
+
The `state` payload field will be available in all relevant hooks, making it easy to access shared
|
65
|
+
data. It also forces the developer to choose the scope for the data:
|
66
|
+
- `forOperation` for a data scoped to GraphQL operation (Envelop, Yoga and Hive Gateway)
|
67
|
+
- `forRequest` for a data scoped to HTTP request (Yoga and Hive Gateway)
|
68
|
+
- `forSubgraphExecution` for a data scoped to the subgraph execution (Hive Gateway)
|
69
|
+
|
70
|
+
Not all scopes are available in all hooks, the type reflects which scopes are available
|
71
|
+
|
72
|
+
Under the hood, those states are kept in memory using `WeakMap`, which avoid any memory leaks.
|
73
|
+
|
74
|
+
It is also possible to manually retrieve the state with the `getState` function:
|
75
|
+
|
76
|
+
```ts
|
77
|
+
const myPlugin = () =>
|
78
|
+
withState((getState) => ({
|
79
|
+
onParse({ context }) {
|
80
|
+
// You can provide a payload, which will dictate which scope you have access to.
|
81
|
+
// The scope can contain `context`, `request` and `executionRequest` fields.
|
82
|
+
const state = getState({ context });
|
83
|
+
// Use the state elsewhere.
|
84
|
+
},
|
85
|
+
}));
|
86
|
+
```
|
87
|
+
|
27
88
|
### Patch Changes
|
28
89
|
|
29
|
-
- [#956](https://github.com/graphql-hive/gateway/pull/956) [`
|
90
|
+
- [#956](https://github.com/graphql-hive/gateway/pull/956) [`32fbb7b`](https://github.com/graphql-hive/gateway/commit/32fbb7b3aefe9228c29c6f7b2a785406f21d3e24) Thanks [@EmrysMyrddin](https://github.com/EmrysMyrddin)! - dependencies updates:
|
30
91
|
- Added dependency [`@graphql-hive/logger@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-hive/logger/v/workspace:^) (to `dependencies`)
|
31
92
|
|
32
|
-
- [#956](https://github.com/graphql-hive/gateway/pull/956) [`
|
93
|
+
- [#956](https://github.com/graphql-hive/gateway/pull/956) [`b97d5d7`](https://github.com/graphql-hive/gateway/commit/b97d5d7d086dcaf140da83bf0c279e4a40b50fe2) Thanks [@EmrysMyrddin](https://github.com/EmrysMyrddin)! - dependencies updates:
|
33
94
|
- Added dependency [`@opentelemetry/api@^1.9.0` ↗︎](https://www.npmjs.com/package/@opentelemetry/api/v/1.9.0) (to `dependencies`)
|
34
95
|
- Added dependency [`@opentelemetry/context-zone@^2.0.1` ↗︎](https://www.npmjs.com/package/@opentelemetry/context-zone/v/2.0.1) (to `dependencies`)
|
35
96
|
- Added dependency [`@opentelemetry/core@^2.0.1` ↗︎](https://www.npmjs.com/package/@opentelemetry/core/v/2.0.1) (to `dependencies`)
|
@@ -40,10 +101,14 @@
|
|
40
101
|
- Added dependency [`@opentelemetry/sampler-jaeger-remote@^0.202.0` ↗︎](https://www.npmjs.com/package/@opentelemetry/sampler-jaeger-remote/v/0.202.0) (to `dependencies`)
|
41
102
|
- Added dependency [`@opentelemetry/sdk-metrics@^2.0.1` ↗︎](https://www.npmjs.com/package/@opentelemetry/sdk-metrics/v/2.0.1) (to `dependencies`)
|
42
103
|
|
43
|
-
- [#956](https://github.com/graphql-hive/gateway/pull/956) [`
|
104
|
+
- [#956](https://github.com/graphql-hive/gateway/pull/956) [`76b49db`](https://github.com/graphql-hive/gateway/commit/76b49db569d9608af80a635e7cb40b1cc7d3b313) Thanks [@EmrysMyrddin](https://github.com/EmrysMyrddin)! - dependencies updates:
|
44
105
|
- Added dependency [`@opentelemetry/api-logs@^0.202.0` ↗︎](https://www.npmjs.com/package/@opentelemetry/api-logs/v/0.202.0) (to `dependencies`)
|
45
106
|
- Added dependency [`@opentelemetry/sdk-logs@^0.202.0` ↗︎](https://www.npmjs.com/package/@opentelemetry/sdk-logs/v/0.202.0) (to `dependencies`)
|
46
107
|
|
108
|
+
- [`e4f0e62`](https://github.com/graphql-hive/gateway/commit/e4f0e62acc896e04a8e3f6ef33f07ff5427e0069) Thanks [@EmrysMyrddin](https://github.com/EmrysMyrddin)! - dependencies updates:
|
109
|
+
- Added dependency [`@opentelemetry/context-async-hooks@^2.0.1` ↗︎](https://www.npmjs.com/package/@opentelemetry/context-async-hooks/v/2.0.1) (to `dependencies`)
|
110
|
+
- Added dependency [`@opentelemetry/sdk-trace-base@^2.0.1` ↗︎](https://www.npmjs.com/package/@opentelemetry/sdk-trace-base/v/2.0.1) (to `dependencies`)
|
111
|
+
|
47
112
|
- [#1318](https://github.com/graphql-hive/gateway/pull/1318) [`7dafdeb`](https://github.com/graphql-hive/gateway/commit/7dafdebc803e49373fe9d53997113483e512fdb0) Thanks [@enisdenjo](https://github.com/enisdenjo)! - dependencies updates:
|
48
113
|
- Updated dependency [`@graphql-yoga/render-graphiql@^5.15.1` ↗︎](https://www.npmjs.com/package/@graphql-yoga/render-graphiql/v/5.15.1) (from `^5.13.5`, in `dependencies`)
|
49
114
|
- Updated dependency [`graphql-yoga@^5.15.1` ↗︎](https://www.npmjs.com/package/graphql-yoga/v/5.15.1) (from `^5.13.5`, in `dependencies`)
|
@@ -55,7 +120,10 @@
|
|
55
120
|
- [#1325](https://github.com/graphql-hive/gateway/pull/1325) [`910ff77`](https://github.com/graphql-hive/gateway/commit/910ff777ce787297cece37ec66c3382bc292412b) Thanks [@dependabot](https://github.com/apps/dependabot)! - dependencies updates:
|
56
121
|
- Updated dependency [`dotenv@^17.2.0` ↗︎](https://www.npmjs.com/package/dotenv/v/17.2.0) (from `^16.4.7`, in `dependencies`)
|
57
122
|
|
58
|
-
- [#
|
123
|
+
- [#1329](https://github.com/graphql-hive/gateway/pull/1329) [`ce99e43`](https://github.com/graphql-hive/gateway/commit/ce99e43b9fec43c665836bd3a282ce6d4302481d) Thanks [@dependabot](https://github.com/apps/dependabot)! - dependencies updates:
|
124
|
+
- Updated dependency [`graphql-ws@^6.0.6` ↗︎](https://www.npmjs.com/package/graphql-ws/v/6.0.6) (from `^6.0.4`, in `dependencies`)
|
125
|
+
|
126
|
+
- [#956](https://github.com/graphql-hive/gateway/pull/956) [`001c24f`](https://github.com/graphql-hive/gateway/commit/001c24fbf6de9c240a00f2cc86fc49ff75542bce) Thanks [@EmrysMyrddin](https://github.com/EmrysMyrddin)! - dependencies updates:
|
59
127
|
- Added dependency [`@graphql-hive/logger@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-hive/logger/v/workspace:^) (to `dependencies`)
|
60
128
|
- Added dependency [`@opentelemetry/api@^1.9.0` ↗︎](https://www.npmjs.com/package/@opentelemetry/api/v/1.9.0) (to `dependencies`)
|
61
129
|
- Added dependency [`@opentelemetry/api-logs@^0.202.0` ↗︎](https://www.npmjs.com/package/@opentelemetry/api-logs/v/0.202.0) (to `dependencies`)
|
@@ -70,20 +138,22 @@
|
|
70
138
|
- Added dependency [`@opentelemetry/sdk-metrics@^2.0.1` ↗︎](https://www.npmjs.com/package/@opentelemetry/sdk-metrics/v/2.0.1) (to `dependencies`)
|
71
139
|
- Removed dependency [`@graphql-mesh/plugin-mock@^0.105.6` ↗︎](https://www.npmjs.com/package/@graphql-mesh/plugin-mock/v/0.105.6) (from `dependencies`)
|
72
140
|
|
73
|
-
-
|
74
|
-
|
75
|
-
|
76
|
-
- @graphql-
|
77
|
-
- @graphql-
|
78
|
-
- @graphql-mesh/plugin-
|
79
|
-
- @graphql-mesh/
|
80
|
-
- @graphql-mesh/
|
81
|
-
- @graphql-
|
82
|
-
- @graphql-mesh/transport-
|
83
|
-
- @graphql-mesh/
|
84
|
-
- @graphql-hive/
|
85
|
-
- @graphql-
|
86
|
-
- @graphql-hive/
|
141
|
+
- [#1333](https://github.com/graphql-hive/gateway/pull/1333) [`ffa3753`](https://github.com/graphql-hive/gateway/commit/ffa3753ccb9045c5b2d62af05edc7f1d78336cb3) Thanks [@enisdenjo](https://github.com/enisdenjo)! - Isomorphic environment variable getter with truthy value parsing
|
142
|
+
|
143
|
+
- Updated dependencies [[`32fbb7b`](https://github.com/graphql-hive/gateway/commit/32fbb7b3aefe9228c29c6f7b2a785406f21d3e24), [`7dafdeb`](https://github.com/graphql-hive/gateway/commit/7dafdebc803e49373fe9d53997113483e512fdb0), [`6215001`](https://github.com/graphql-hive/gateway/commit/6215001b1d650ad865331661532bcc4f7bad6b40), [`f12f2b7`](https://github.com/graphql-hive/gateway/commit/f12f2b78163fbef797a42b5999a0b5a8ef6b2c98), [`ce99e43`](https://github.com/graphql-hive/gateway/commit/ce99e43b9fec43c665836bd3a282ce6d4302481d), [`001c24f`](https://github.com/graphql-hive/gateway/commit/001c24fbf6de9c240a00f2cc86fc49ff75542bce), [`6215001`](https://github.com/graphql-hive/gateway/commit/6215001b1d650ad865331661532bcc4f7bad6b40), [`7dafdeb`](https://github.com/graphql-hive/gateway/commit/7dafdebc803e49373fe9d53997113483e512fdb0), [`b97d5d7`](https://github.com/graphql-hive/gateway/commit/b97d5d7d086dcaf140da83bf0c279e4a40b50fe2), [`76b49db`](https://github.com/graphql-hive/gateway/commit/76b49db569d9608af80a635e7cb40b1cc7d3b313), [`e4f0e62`](https://github.com/graphql-hive/gateway/commit/e4f0e62acc896e04a8e3f6ef33f07ff5427e0069), [`1d4bcd3`](https://github.com/graphql-hive/gateway/commit/1d4bcd3a417aa603e9b66ebc4b4dd000b25f9781), [`7cbe3f5`](https://github.com/graphql-hive/gateway/commit/7cbe3f5301cbdba1d160153761dfafaefc2aa107), [`eaf4735`](https://github.com/graphql-hive/gateway/commit/eaf4735e06023d2f0e393998a6d2075898bc82fc), [`32fbb7b`](https://github.com/graphql-hive/gateway/commit/32fbb7b3aefe9228c29c6f7b2a785406f21d3e24), [`7dafdeb`](https://github.com/graphql-hive/gateway/commit/7dafdebc803e49373fe9d53997113483e512fdb0), [`001c24f`](https://github.com/graphql-hive/gateway/commit/001c24fbf6de9c240a00f2cc86fc49ff75542bce), [`7287ffa`](https://github.com/graphql-hive/gateway/commit/7287ffa2ac0f08801c3058e96a7c4eba7102c1d0), [`6215001`](https://github.com/graphql-hive/gateway/commit/6215001b1d650ad865331661532bcc4f7bad6b40), [`ce99e43`](https://github.com/graphql-hive/gateway/commit/ce99e43b9fec43c665836bd3a282ce6d4302481d), [`ffa3753`](https://github.com/graphql-hive/gateway/commit/ffa3753ccb9045c5b2d62af05edc7f1d78336cb3), [`8273fde`](https://github.com/graphql-hive/gateway/commit/8273fde686a666fa7f974ad4f9084f8b9cb0df57), [`32fbb7b`](https://github.com/graphql-hive/gateway/commit/32fbb7b3aefe9228c29c6f7b2a785406f21d3e24), [`2fa0c8f`](https://github.com/graphql-hive/gateway/commit/2fa0c8f1dd074c9da8e6ac4086eb3009be9fdf07), [`f212e12`](https://github.com/graphql-hive/gateway/commit/f212e1289d8e0c57cb3d7ace2aca3cbbf8d38889), [`247ecfe`](https://github.com/graphql-hive/gateway/commit/247ecfe81319a4383dd33c9dba5779189e12b15d), [`9b230f3`](https://github.com/graphql-hive/gateway/commit/9b230f35b47afbf3b253e4c21720e836c5a2a8d1), [`b6c1e88`](https://github.com/graphql-hive/gateway/commit/b6c1e8812e817f616d780af4276bd7e2a7f7dbef), [`849db00`](https://github.com/graphql-hive/gateway/commit/849db001c6a8e8efeb25cc314538783a924b090e), [`c03ff30`](https://github.com/graphql-hive/gateway/commit/c03ff30aca8fab824a1e3b896f3c4359b0c84726), [`eaf4735`](https://github.com/graphql-hive/gateway/commit/eaf4735e06023d2f0e393998a6d2075898bc82fc), [`32fbb7b`](https://github.com/graphql-hive/gateway/commit/32fbb7b3aefe9228c29c6f7b2a785406f21d3e24), [`777d90b`](https://github.com/graphql-hive/gateway/commit/777d90b0ed03f113633015e48474231eda2b8398)]:
|
144
|
+
- @graphql-hive/gateway-runtime@2.0.0-alpha-7125411993448274610947015e30dd5b3461ded1
|
145
|
+
- @graphql-hive/plugin-aws-sigv4@2.0.0-alpha-7125411993448274610947015e30dd5b3461ded1
|
146
|
+
- @graphql-mesh/plugin-jwt-auth@2.0.0-alpha-7125411993448274610947015e30dd5b3461ded1
|
147
|
+
- @graphql-mesh/plugin-opentelemetry@2.0.0-alpha-7125411993448274610947015e30dd5b3461ded1
|
148
|
+
- @graphql-mesh/plugin-prometheus@2.0.0-alpha-7125411993448274610947015e30dd5b3461ded1
|
149
|
+
- @graphql-mesh/transport-http-callback@1.0.0-alpha-7125411993448274610947015e30dd5b3461ded1
|
150
|
+
- @graphql-mesh/transport-ws@2.0.0-alpha-7125411993448274610947015e30dd5b3461ded1
|
151
|
+
- @graphql-mesh/hmac-upstream-signature@2.0.0-alpha-7125411993448274610947015e30dd5b3461ded1
|
152
|
+
- @graphql-hive/plugin-deduplicate-request@2.0.0-alpha-7125411993448274610947015e30dd5b3461ded1
|
153
|
+
- @graphql-mesh/transport-http@1.0.0-alpha-7125411993448274610947015e30dd5b3461ded1
|
154
|
+
- @graphql-hive/importer@2.0.0-alpha-7125411993448274610947015e30dd5b3461ded1
|
155
|
+
- @graphql-hive/pubsub@2.0.0-alpha-7125411993448274610947015e30dd5b3461ded1
|
156
|
+
- @graphql-hive/logger@1.0.1-alpha-7125411993448274610947015e30dd5b3461ded1
|
87
157
|
|
88
158
|
## 1.15.4
|
89
159
|
|
package/dist/bin.cjs
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require('dotenv/config');
|
4
4
|
var module$1 = require('node:module');
|
5
5
|
var logger = require('@graphql-hive/logger');
|
6
|
-
var cli = require('./cli-
|
6
|
+
var cli = require('./cli-3udwdx7_.cjs');
|
7
7
|
require('node:cluster');
|
8
8
|
require('node:os');
|
9
9
|
require('node:path');
|
@@ -18,6 +18,7 @@ require('node:fs');
|
|
18
18
|
require('node:http');
|
19
19
|
require('node:https');
|
20
20
|
require('@graphql-tools/utils');
|
21
|
+
require('@opentelemetry/sdk-trace-base');
|
21
22
|
require('@graphql-tools/code-file-loader');
|
22
23
|
require('@graphql-tools/graphql-file-loader');
|
23
24
|
require('@graphql-tools/load');
|
package/dist/bin.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
import 'dotenv/config';
|
3
3
|
import module from 'node:module';
|
4
4
|
import { Logger } from '@graphql-hive/logger';
|
5
|
-
import { e as enableModuleCachingIfPossible, h as handleNodeWarnings, r as run } from './cli-
|
5
|
+
import { e as enableModuleCachingIfPossible, h as handleNodeWarnings, r as run } from './cli-DcLVI5BX.js';
|
6
6
|
import 'node:cluster';
|
7
7
|
import 'node:os';
|
8
8
|
import 'node:path';
|
@@ -17,6 +17,7 @@ import 'node:fs';
|
|
17
17
|
import 'node:http';
|
18
18
|
import 'node:https';
|
19
19
|
import '@graphql-tools/utils';
|
20
|
+
import '@opentelemetry/sdk-trace-base';
|
20
21
|
import '@graphql-tools/code-file-loader';
|
21
22
|
import '@graphql-tools/graphql-file-loader';
|
22
23
|
import '@graphql-tools/load';
|
@@ -16,6 +16,7 @@ var node_fs = require('node:fs');
|
|
16
16
|
var node_http = require('node:http');
|
17
17
|
var node_https = require('node:https');
|
18
18
|
var utils$1 = require('@graphql-tools/utils');
|
19
|
+
var sdkTraceBase = require('@opentelemetry/sdk-trace-base');
|
19
20
|
var codeFileLoader = require('@graphql-tools/code-file-loader');
|
20
21
|
var graphqlFileLoader = require('@graphql-tools/graphql-file-loader');
|
21
22
|
var load = require('@graphql-tools/load');
|
@@ -25,6 +26,34 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
25
26
|
var cluster__default = /*#__PURE__*/_interopDefault(cluster);
|
26
27
|
var module__default = /*#__PURE__*/_interopDefault(module$1);
|
27
28
|
|
29
|
+
function getEnvStr(key, opts = {}) {
|
30
|
+
const globalThat = opts.globalThis ?? globalThis;
|
31
|
+
let variable = globalThat.process?.env?.[key] || // @ts-expect-error can exist in wrangler and maybe other runtimes
|
32
|
+
globalThat.env?.[key] || // @ts-expect-error can exist in deno
|
33
|
+
globalThat.Deno?.env?.get(key) || // @ts-expect-error could be
|
34
|
+
globalThat[key];
|
35
|
+
if (variable != null) {
|
36
|
+
variable += "";
|
37
|
+
} else {
|
38
|
+
variable = void 0;
|
39
|
+
}
|
40
|
+
return variable?.trim();
|
41
|
+
}
|
42
|
+
function getEnvBool(key, opts = {}) {
|
43
|
+
return strToBool(getEnvStr(key, opts));
|
44
|
+
}
|
45
|
+
function getNodeEnv(opts = {}) {
|
46
|
+
return getEnvStr("NODE_ENV", opts);
|
47
|
+
}
|
48
|
+
function strToBool(str) {
|
49
|
+
return ["1", "t", "true", "y", "yes", "on", "enabled"].includes(
|
50
|
+
(str || "").toLowerCase()
|
51
|
+
);
|
52
|
+
}
|
53
|
+
function isDebug() {
|
54
|
+
return getEnvBool("DEBUG");
|
55
|
+
}
|
56
|
+
|
28
57
|
const unit = Object.create(null);
|
29
58
|
const m = 60000, h = m * 60, d = h * 24, y = d * 365.25;
|
30
59
|
|
@@ -492,11 +521,83 @@ function handleFork(log, config) {
|
|
492
521
|
return false;
|
493
522
|
}
|
494
523
|
|
524
|
+
async function handleOpenTelemetryConfig(ctx, cliOpts) {
|
525
|
+
const accessToken = cliOpts.hiveTraceAccessToken;
|
526
|
+
const traceEndpoint = cliOpts.hiveTraceEndpoint;
|
527
|
+
const target = cliOpts.hiveTarget;
|
528
|
+
const openTelemetry = cliOpts.openTelemetry;
|
529
|
+
const exporterType = cliOpts.openTelemetryExporterType ?? "otlp-http";
|
530
|
+
const log = ctx.log.child("[OpenTelemetry] ");
|
531
|
+
if (openTelemetry || accessToken) {
|
532
|
+
log.debug(
|
533
|
+
{ openTelemetry, exporterType, target, traceEndpoint },
|
534
|
+
"Initializing OpenTelemetry SDK"
|
535
|
+
);
|
536
|
+
return utils$1.fakePromise().then(async () => {
|
537
|
+
const { openTelemetrySetup, HiveTracingSpanProcessor, getEnvVar } = await import('@graphql-mesh/plugin-opentelemetry/setup');
|
538
|
+
const processors = [];
|
539
|
+
const logAttributes = {
|
540
|
+
traceEndpoints: [],
|
541
|
+
contextManager: false
|
542
|
+
};
|
543
|
+
let integrationName;
|
544
|
+
if (openTelemetry) {
|
545
|
+
const otelEndpoint = typeof openTelemetry === "string" ? openTelemetry : getEnvVar("OTEL_EXPORTER_OTLP_ENDPOINT", void 0);
|
546
|
+
log.debug({ exporterType, otelEndpoint }, "Setting up OTLP Exporter");
|
547
|
+
integrationName = "OpenTelemetry";
|
548
|
+
logAttributes.traceEndpoints.push({
|
549
|
+
url: otelEndpoint ?? null,
|
550
|
+
type: exporterType
|
551
|
+
});
|
552
|
+
log.debug({ type: exporterType }, "Loading OpenTelemetry exporter");
|
553
|
+
const { OTLPTraceExporter } = await import(`@opentelemetry/exporter-trace-${exporterType}`);
|
554
|
+
processors.push(
|
555
|
+
new sdkTraceBase.BatchSpanProcessor(new OTLPTraceExporter({ url: otelEndpoint }))
|
556
|
+
);
|
557
|
+
}
|
558
|
+
if (accessToken) {
|
559
|
+
log.debug({ target, traceEndpoint }, "Setting up Hive Tracing");
|
560
|
+
integrationName ??= "Hive Tracing";
|
561
|
+
if (!target) {
|
562
|
+
ctx.log.error(
|
563
|
+
'Hive tracing needs a target. Please provide it through "--hive-target <target>"'
|
564
|
+
);
|
565
|
+
process.exit(1);
|
566
|
+
}
|
567
|
+
logAttributes.traceEndpoints.push({
|
568
|
+
url: traceEndpoint,
|
569
|
+
type: "hive tracing",
|
570
|
+
target
|
571
|
+
});
|
572
|
+
processors.push(
|
573
|
+
new HiveTracingSpanProcessor({
|
574
|
+
accessToken,
|
575
|
+
target,
|
576
|
+
endpoint: traceEndpoint
|
577
|
+
})
|
578
|
+
);
|
579
|
+
}
|
580
|
+
log.debug("Trying to load AsyncLocalStorage based Context Manager");
|
581
|
+
const contextManager = await import('@opentelemetry/context-async-hooks').then((module) => {
|
582
|
+
logAttributes.contextManager = true;
|
583
|
+
return new module.AsyncLocalStorageContextManager();
|
584
|
+
}).catch(() => null);
|
585
|
+
openTelemetrySetup({
|
586
|
+
traces: { processors },
|
587
|
+
contextManager
|
588
|
+
});
|
589
|
+
log.info(logAttributes, `${integrationName} integration is enabled`);
|
590
|
+
return true;
|
591
|
+
});
|
592
|
+
}
|
593
|
+
return false;
|
594
|
+
}
|
595
|
+
|
495
596
|
function handleReportingConfig(ctx, loadedConfig, cliOpts) {
|
496
597
|
const confOpts = {
|
497
598
|
...loadedConfig.reporting?.type === "hive" ? {
|
498
599
|
hiveRegistryToken: loadedConfig.reporting.token,
|
499
|
-
|
600
|
+
hiveTarget: loadedConfig.reporting.target,
|
500
601
|
hiveUsageAccessToken: loadedConfig.reporting.token
|
501
602
|
} : {},
|
502
603
|
...loadedConfig.reporting?.type === "graphos" ? {
|
@@ -504,32 +605,45 @@ function handleReportingConfig(ctx, loadedConfig, cliOpts) {
|
|
504
605
|
apolloKey: loadedConfig.reporting.apiKey
|
505
606
|
} : {}
|
506
607
|
};
|
507
|
-
const opts = {
|
608
|
+
const opts = {
|
609
|
+
...confOpts,
|
610
|
+
...cliOpts,
|
611
|
+
hiveTarget: (
|
612
|
+
// cli arguments always take precedence over config
|
613
|
+
confOpts.hiveTarget ?? cliOpts.hiveTarget ?? cliOpts.hiveUsageTarget
|
614
|
+
)
|
615
|
+
};
|
508
616
|
if (cliOpts.hiveRegistryToken && cliOpts.hiveUsageAccessToken) {
|
509
617
|
ctx.log.error(
|
510
618
|
'Cannot use "--hive-registry-token" with "--hive-usage-access-token". Please use "--hive-usage-target" and "--hive-usage-access-token" or the config instead.'
|
511
619
|
);
|
512
620
|
process.exit(1);
|
513
621
|
}
|
514
|
-
if (cliOpts.
|
622
|
+
if (cliOpts.hiveUsageTarget && cliOpts.hiveTarget) {
|
623
|
+
ctx.log.error(
|
624
|
+
'Cannot use "--hive-usage-target" with "--hive-target". Please only use "--hive-target"'
|
625
|
+
);
|
626
|
+
process.exit(1);
|
627
|
+
}
|
628
|
+
if (cliOpts.hiveRegistryToken && opts.hiveTarget) {
|
515
629
|
ctx.log.error(
|
516
630
|
'Cannot use "--hive-registry-token" with a target. Please use "--hive-usage-target" and "--hive-usage-access-token" or the config instead.'
|
517
631
|
);
|
518
632
|
process.exit(1);
|
519
633
|
}
|
520
|
-
if (opts.
|
634
|
+
if (opts.hiveTarget && !opts.hiveAccessToken && !opts.hiveUsageAccessToken && !opts.hiveTraceAccessToken) {
|
521
635
|
ctx.log.error(
|
522
|
-
'Hive usage target needs an access token. Please provide it through
|
636
|
+
'Hive usage target needs an access token. Please provide it through "--hive-access-token <token>", or specific "--hive-usage-access-token <token>" and "--hive-trace-access-token" options, or the config.'
|
523
637
|
);
|
524
638
|
process.exit(1);
|
525
639
|
}
|
526
|
-
if (opts.hiveUsageAccessToken && !opts.
|
640
|
+
if ((opts.hiveAccessToken || opts.hiveUsageAccessToken || opts.hiveTraceAccessToken) && !opts.hiveTarget) {
|
527
641
|
ctx.log.error(
|
528
|
-
'Hive
|
642
|
+
'Hive access token needs a target. Please provide it through the "--hive-target <target>" option or the config.'
|
529
643
|
);
|
530
644
|
process.exit(1);
|
531
645
|
}
|
532
|
-
const hiveUsageAccessToken = opts.hiveUsageAccessToken || opts.hiveRegistryToken;
|
646
|
+
const hiveUsageAccessToken = opts.hiveAccessToken || opts.hiveUsageAccessToken || opts.hiveRegistryToken;
|
533
647
|
if (hiveUsageAccessToken) {
|
534
648
|
if (opts.hiveUsageTarget) {
|
535
649
|
ctx.log.info("Configuring Hive usage reporting");
|
@@ -540,7 +654,7 @@ function handleReportingConfig(ctx, loadedConfig, cliOpts) {
|
|
540
654
|
...loadedConfig.reporting,
|
541
655
|
type: "hive",
|
542
656
|
token: hiveUsageAccessToken,
|
543
|
-
target: opts.
|
657
|
+
target: opts.hiveTarget
|
544
658
|
};
|
545
659
|
}
|
546
660
|
if (opts.apolloKey) {
|
@@ -568,17 +682,30 @@ const addCommand$2 = (ctx, cli) => cli.command("proxy").description(
|
|
568
682
|
"path to the GraphQL schema file or a url from where to pull the schema"
|
569
683
|
).action(async function proxy(endpoint) {
|
570
684
|
const {
|
685
|
+
opentelemetry,
|
686
|
+
opentelemetryExporterType,
|
571
687
|
hiveCdnEndpoint,
|
572
688
|
hiveCdnKey,
|
573
689
|
hiveRegistryToken,
|
690
|
+
hiveTarget,
|
574
691
|
hiveUsageTarget,
|
692
|
+
hiveAccessToken,
|
575
693
|
hiveUsageAccessToken,
|
694
|
+
hiveTraceAccessToken,
|
695
|
+
hiveTraceEndpoint,
|
576
696
|
maskedErrors,
|
577
697
|
hivePersistedDocumentsEndpoint,
|
578
698
|
hivePersistedDocumentsToken,
|
579
699
|
...opts
|
580
700
|
} = this.optsWithGlobals();
|
581
701
|
ctx.log.info(`Starting ${ctx.productName} ${ctx.version} in proxy mode`);
|
702
|
+
const openTelemetryEnabledByCLI = await handleOpenTelemetryConfig(ctx, {
|
703
|
+
openTelemetry: opentelemetry,
|
704
|
+
openTelemetryExporterType: opentelemetryExporterType,
|
705
|
+
hiveTarget,
|
706
|
+
hiveTraceAccessToken,
|
707
|
+
hiveTraceEndpoint
|
708
|
+
});
|
582
709
|
const loadedConfig = await loadConfig({
|
583
710
|
log: ctx.log,
|
584
711
|
configPath: opts.configPath,
|
@@ -632,8 +759,11 @@ const addCommand$2 = (ctx, cli) => cli.command("proxy").description(
|
|
632
759
|
const registryConfig = {};
|
633
760
|
const reporting = handleReportingConfig(ctx, loadedConfig, {
|
634
761
|
hiveRegistryToken,
|
762
|
+
hiveTarget,
|
635
763
|
hiveUsageTarget,
|
764
|
+
hiveAccessToken,
|
636
765
|
hiveUsageAccessToken,
|
766
|
+
hiveTraceAccessToken,
|
637
767
|
// proxy can only do reporting to hive registry
|
638
768
|
apolloGraphRef: void 0,
|
639
769
|
apolloKey: void 0
|
@@ -654,7 +784,8 @@ const addCommand$2 = (ctx, cli) => cli.command("proxy").description(
|
|
654
784
|
const builtinPlugins = await getBuiltinPluginsFromConfig(
|
655
785
|
{
|
656
786
|
...loadedConfig,
|
657
|
-
...opts
|
787
|
+
...opts,
|
788
|
+
openTelemetry: openTelemetryEnabledByCLI ? { ...loadedConfig.openTelemetry, traces: true } : loadedConfig.openTelemetry
|
658
789
|
},
|
659
790
|
{
|
660
791
|
log: ctx.log,
|
@@ -729,15 +860,28 @@ const addCommand$1 = (ctx, cli) => cli.command("subgraph").description(
|
|
729
860
|
'path to the subgraph schema file or a url from where to pull the subgraph schema (default: "subgraph.graphql")'
|
730
861
|
).action(async function subgraph(schemaPathOrUrl) {
|
731
862
|
const {
|
863
|
+
opentelemetry,
|
864
|
+
opentelemetryExporterType,
|
732
865
|
maskedErrors,
|
733
866
|
hiveRegistryToken,
|
867
|
+
hiveTarget,
|
734
868
|
hiveUsageTarget,
|
869
|
+
hiveAccessToken,
|
735
870
|
hiveUsageAccessToken,
|
871
|
+
hiveTraceAccessToken,
|
872
|
+
hiveTraceEndpoint,
|
736
873
|
hivePersistedDocumentsEndpoint,
|
737
874
|
hivePersistedDocumentsToken,
|
738
875
|
...opts
|
739
876
|
} = this.optsWithGlobals();
|
740
877
|
ctx.log.info(`Starting ${ctx.productName} ${ctx.version} as subgraph`);
|
878
|
+
const openTelemetryEnabledByCLI = await handleOpenTelemetryConfig(ctx, {
|
879
|
+
openTelemetry: opentelemetry,
|
880
|
+
openTelemetryExporterType: opentelemetryExporterType,
|
881
|
+
hiveTarget,
|
882
|
+
hiveTraceAccessToken,
|
883
|
+
hiveTraceEndpoint
|
884
|
+
});
|
741
885
|
const loadedConfig = await loadConfig({
|
742
886
|
log: ctx.log,
|
743
887
|
configPath: opts.configPath,
|
@@ -753,8 +897,11 @@ const addCommand$1 = (ctx, cli) => cli.command("subgraph").description(
|
|
753
897
|
const registryConfig = {};
|
754
898
|
const reporting = handleReportingConfig(ctx, loadedConfig, {
|
755
899
|
hiveRegistryToken,
|
900
|
+
hiveTarget,
|
756
901
|
hiveUsageTarget,
|
902
|
+
hiveAccessToken,
|
757
903
|
hiveUsageAccessToken,
|
904
|
+
hiveTraceAccessToken,
|
758
905
|
// subgraph can only do reporting to hive registry
|
759
906
|
apolloGraphRef: void 0,
|
760
907
|
apolloKey: void 0
|
@@ -775,7 +922,8 @@ const addCommand$1 = (ctx, cli) => cli.command("subgraph").description(
|
|
775
922
|
const builtinPlugins = await getBuiltinPluginsFromConfig(
|
776
923
|
{
|
777
924
|
...loadedConfig,
|
778
|
-
...opts
|
925
|
+
...opts,
|
926
|
+
openTelemetry: openTelemetryEnabledByCLI ? { ...loadedConfig.openTelemetry, traces: true } : loadedConfig.openTelemetry
|
779
927
|
},
|
780
928
|
{
|
781
929
|
log: ctx.log,
|
@@ -869,11 +1017,17 @@ const addCommand = (ctx, cli) => cli.command("supergraph").description(
|
|
869
1017
|
).env("APOLLO_SCHEMA_CONFIG_DELIVERY_ENDPOINT")
|
870
1018
|
).action(async function supergraph(schemaPathOrUrl) {
|
871
1019
|
const {
|
1020
|
+
opentelemetry,
|
1021
|
+
opentelemetryExporterType,
|
872
1022
|
hiveCdnEndpoint,
|
873
1023
|
hiveCdnKey,
|
874
1024
|
hiveRegistryToken,
|
875
1025
|
hiveUsageTarget,
|
1026
|
+
hiveTarget,
|
1027
|
+
hiveAccessToken,
|
876
1028
|
hiveUsageAccessToken,
|
1029
|
+
hiveTraceAccessToken,
|
1030
|
+
hiveTraceEndpoint,
|
877
1031
|
maskedErrors,
|
878
1032
|
apolloGraphRef,
|
879
1033
|
apolloKey,
|
@@ -885,6 +1039,13 @@ const addCommand = (ctx, cli) => cli.command("supergraph").description(
|
|
885
1039
|
ctx.log.info(
|
886
1040
|
`Starting ${ctx.productName} ${ctx.version} with supergraph`
|
887
1041
|
);
|
1042
|
+
const openTelemetryEnabledByCLI = await handleOpenTelemetryConfig(ctx, {
|
1043
|
+
openTelemetry: opentelemetry,
|
1044
|
+
openTelemetryExporterType: opentelemetryExporterType,
|
1045
|
+
hiveTarget,
|
1046
|
+
hiveTraceAccessToken,
|
1047
|
+
hiveTraceEndpoint
|
1048
|
+
});
|
888
1049
|
const loadedConfig = await loadConfig({
|
889
1050
|
log: ctx.log,
|
890
1051
|
configPath: opts.configPath,
|
@@ -970,6 +1131,9 @@ const addCommand = (ctx, cli) => cli.command("supergraph").description(
|
|
970
1131
|
}
|
971
1132
|
const registryConfig = {};
|
972
1133
|
const reporting = handleReportingConfig(ctx, loadedConfig, {
|
1134
|
+
hiveTarget,
|
1135
|
+
hiveAccessToken,
|
1136
|
+
hiveTraceAccessToken,
|
973
1137
|
hiveRegistryToken,
|
974
1138
|
hiveUsageTarget,
|
975
1139
|
hiveUsageAccessToken,
|
@@ -992,7 +1156,8 @@ const addCommand = (ctx, cli) => cli.command("supergraph").description(
|
|
992
1156
|
const builtinPlugins = await getBuiltinPluginsFromConfig(
|
993
1157
|
{
|
994
1158
|
...loadedConfig,
|
995
|
-
...opts
|
1159
|
+
...opts,
|
1160
|
+
openTelemetry: openTelemetryEnabledByCLI ? { ...loadedConfig.openTelemetry, traces: true } : loadedConfig.openTelemetry
|
996
1161
|
},
|
997
1162
|
{
|
998
1163
|
log: ctx.log,
|
@@ -1044,7 +1209,7 @@ const addCommand = (ctx, cli) => cli.command("supergraph").description(
|
|
1044
1209
|
process.exit(1);
|
1045
1210
|
}
|
1046
1211
|
return runSupergraph(ctx, config);
|
1047
|
-
}).allowUnknownOption(
|
1212
|
+
}).allowUnknownOption(getNodeEnv() === "test").allowExcessArguments(getNodeEnv() === "test");
|
1048
1213
|
async function runSupergraph({ log }, config) {
|
1049
1214
|
let absSchemaPath = null;
|
1050
1215
|
if (typeof config.supergraph === "string" && utils$1.isValidPath(config.supergraph) && !utils.isUrl(config.supergraph)) {
|
@@ -1242,27 +1407,57 @@ let cli = new extraTypings.Command().configureHelp({
|
|
1242
1407
|
// see here https://github.com/tj/commander.js/blob/970ecae402b253de691e6a9066fea22f38fe7431/lib/command.js#L655
|
1243
1408
|
// @ts-expect-error
|
1244
1409
|
null
|
1410
|
+
).addOption(
|
1411
|
+
new extraTypings.Option(
|
1412
|
+
"--opentelemetry [exporter-endpoint]",
|
1413
|
+
`Enable OpenTelemetry integration with an exporter using this option's value as endpoint. By default, it uses OTLP HTTP, use "--opentelemetry-exporter-type" to change the default.`
|
1414
|
+
).env("OPENTELEMETRY")
|
1415
|
+
).addOption(
|
1416
|
+
new extraTypings.Option(
|
1417
|
+
"--opentelemetry-exporter-type <type>",
|
1418
|
+
`OpenTelemetry exporter type to use when setting up OpenTelemetry integration. Requires "--opentelemetry" to set the endpoint.`
|
1419
|
+
).choices(["otlp-http", "otlp-grpc"]).default("otlp-http").env("OPENTELEMETRY_EXPORTER_TYPE")
|
1245
1420
|
).addOption(
|
1246
1421
|
new extraTypings.Option(
|
1247
1422
|
"--hive-registry-token <token>",
|
1248
|
-
'[DEPRECATED: please use "--hive-
|
1423
|
+
'[DEPRECATED: please use "--hive-target" and "--hive-access-token"] Hive registry token for usage metrics reporting'
|
1249
1424
|
).env("HIVE_REGISTRY_TOKEN")
|
1250
1425
|
).addOption(
|
1251
1426
|
new extraTypings.Option(
|
1252
1427
|
"--hive-usage-target <target>",
|
1253
|
-
|
1428
|
+
"[DEPRECATED] please use --hive-target instead."
|
1254
1429
|
).env("HIVE_USAGE_TARGET")
|
1430
|
+
).addOption(
|
1431
|
+
new extraTypings.Option(
|
1432
|
+
"--hive-target <target>",
|
1433
|
+
'Hive registry target to which the usage and tracing data should be reported to. Requires either "--hive-access-token <token>", "--hive-usage-access-token <token>" or "--hive-trace-access-token" option'
|
1434
|
+
).env("HIVE_TARGET")
|
1435
|
+
).addOption(
|
1436
|
+
new extraTypings.Option(
|
1437
|
+
"--hive-access-token <token>",
|
1438
|
+
'Hive registry access token for usage metrics reporting and tracing. Enables both usage reporting and tracing. Requires the "--hive-target <target>" option'
|
1439
|
+
).env("HIVE_ACCESS_TOKEN")
|
1255
1440
|
).addOption(
|
1256
1441
|
new extraTypings.Option(
|
1257
1442
|
"--hive-usage-access-token <token>",
|
1258
|
-
|
1443
|
+
`Hive registry access token for usage reporting. Enables Hive usage report. Requires the "--hive-target <target>" option. It can't be used together with "--hive-access-token"`
|
1259
1444
|
).env("HIVE_USAGE_ACCESS_TOKEN")
|
1445
|
+
).addOption(
|
1446
|
+
new extraTypings.Option(
|
1447
|
+
"--hive-trace-access-token <token>",
|
1448
|
+
`Hive registry access token for tracing. Enables Hive tracing. Requires the "--hive-target <target>" option. It can't be used together with "--hive-access-token"`
|
1449
|
+
).env("HIVE_TRACE_ACCESS_TOKEN")
|
1450
|
+
).addOption(
|
1451
|
+
new extraTypings.Option(
|
1452
|
+
"--hive-trace-endpoint <endpoint>",
|
1453
|
+
`Hive registry tracing endpoint.`
|
1454
|
+
).env("HIVE_TRACE_ENDPOINT").default(`https://api.graphql-hive.com/otel/v1/traces`)
|
1260
1455
|
).option(
|
1261
1456
|
"--hive-persisted-documents-endpoint <endpoint>",
|
1262
|
-
'[EXPERIMENTAL] Hive CDN endpoint for fetching the persisted documents.
|
1457
|
+
'[EXPERIMENTAL] Hive CDN endpoint for fetching the persisted documents. Requires the "--hive-persisted-documents-token <token>" option'
|
1263
1458
|
).option(
|
1264
1459
|
"--hive-persisted-documents-token <token>",
|
1265
|
-
'[EXPERIMENTAL] Hive persisted documents CDN endpoint token.
|
1460
|
+
'[EXPERIMENTAL] Hive persisted documents CDN endpoint token. Requires the "--hive-persisted-documents-endpoint <endpoint>" option'
|
1266
1461
|
).addOption(
|
1267
1462
|
new extraTypings.Option(
|
1268
1463
|
"--hive-cdn-endpoint <endpoint>",
|
@@ -1286,9 +1481,11 @@ let cli = new extraTypings.Command().configureHelp({
|
|
1286
1481
|
).option("--disable-websockets", "Disable WebSockets support").addOption(
|
1287
1482
|
new extraTypings.Option(
|
1288
1483
|
"--jit",
|
1289
|
-
"Enable Just-In-Time compilation of GraphQL documents"
|
1484
|
+
"Enable Just-In-Time compilation of GraphQL documents (env: JIT)"
|
1290
1485
|
).env("JIT")
|
1291
|
-
)
|
1486
|
+
).on("optionEnv:jit", function() {
|
1487
|
+
this.setOptionValueWithSource("jit", getEnvBool("JIT"), "env");
|
1488
|
+
});
|
1292
1489
|
async function run(userCtx) {
|
1293
1490
|
const ctx = {
|
1294
1491
|
log: userCtx.log || new logger.Logger(),
|
@@ -1312,7 +1509,7 @@ async function run(userCtx) {
|
|
1312
1509
|
function handleNodeWarnings() {
|
1313
1510
|
const originalProcessEmitWarning = process.emitWarning.bind(process);
|
1314
1511
|
process.emitWarning = function gatewayEmitWarning(warning, ...opts) {
|
1315
|
-
if (
|
1512
|
+
if (isDebug()) {
|
1316
1513
|
originalProcessEmitWarning(warning, ...opts);
|
1317
1514
|
}
|
1318
1515
|
};
|
@@ -13,11 +13,40 @@ import { pathToFileURL } from 'node:url';
|
|
13
13
|
import { promises } from 'node:fs';
|
14
14
|
import { createServer as createServer$1 } from 'node:http';
|
15
15
|
import { createServer } from 'node:https';
|
16
|
-
import { isValidPath, asArray } from '@graphql-tools/utils';
|
16
|
+
import { fakePromise, isValidPath, asArray } from '@graphql-tools/utils';
|
17
|
+
import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';
|
17
18
|
import { CodeFileLoader } from '@graphql-tools/code-file-loader';
|
18
19
|
import { GraphQLFileLoader } from '@graphql-tools/graphql-file-loader';
|
19
20
|
import { loadTypedefs } from '@graphql-tools/load';
|
20
21
|
|
22
|
+
function getEnvStr(key, opts = {}) {
|
23
|
+
const globalThat = opts.globalThis ?? globalThis;
|
24
|
+
let variable = globalThat.process?.env?.[key] || // @ts-expect-error can exist in wrangler and maybe other runtimes
|
25
|
+
globalThat.env?.[key] || // @ts-expect-error can exist in deno
|
26
|
+
globalThat.Deno?.env?.get(key) || // @ts-expect-error could be
|
27
|
+
globalThat[key];
|
28
|
+
if (variable != null) {
|
29
|
+
variable += "";
|
30
|
+
} else {
|
31
|
+
variable = void 0;
|
32
|
+
}
|
33
|
+
return variable?.trim();
|
34
|
+
}
|
35
|
+
function getEnvBool(key, opts = {}) {
|
36
|
+
return strToBool(getEnvStr(key, opts));
|
37
|
+
}
|
38
|
+
function getNodeEnv(opts = {}) {
|
39
|
+
return getEnvStr("NODE_ENV", opts);
|
40
|
+
}
|
41
|
+
function strToBool(str) {
|
42
|
+
return ["1", "t", "true", "y", "yes", "on", "enabled"].includes(
|
43
|
+
(str || "").toLowerCase()
|
44
|
+
);
|
45
|
+
}
|
46
|
+
function isDebug() {
|
47
|
+
return getEnvBool("DEBUG");
|
48
|
+
}
|
49
|
+
|
21
50
|
const unit = Object.create(null);
|
22
51
|
const m = 60000, h = m * 60, d = h * 24, y = d * 365.25;
|
23
52
|
|
@@ -485,11 +514,83 @@ function handleFork(log, config) {
|
|
485
514
|
return false;
|
486
515
|
}
|
487
516
|
|
517
|
+
async function handleOpenTelemetryConfig(ctx, cliOpts) {
|
518
|
+
const accessToken = cliOpts.hiveTraceAccessToken;
|
519
|
+
const traceEndpoint = cliOpts.hiveTraceEndpoint;
|
520
|
+
const target = cliOpts.hiveTarget;
|
521
|
+
const openTelemetry = cliOpts.openTelemetry;
|
522
|
+
const exporterType = cliOpts.openTelemetryExporterType ?? "otlp-http";
|
523
|
+
const log = ctx.log.child("[OpenTelemetry] ");
|
524
|
+
if (openTelemetry || accessToken) {
|
525
|
+
log.debug(
|
526
|
+
{ openTelemetry, exporterType, target, traceEndpoint },
|
527
|
+
"Initializing OpenTelemetry SDK"
|
528
|
+
);
|
529
|
+
return fakePromise().then(async () => {
|
530
|
+
const { openTelemetrySetup, HiveTracingSpanProcessor, getEnvVar } = await import('@graphql-mesh/plugin-opentelemetry/setup');
|
531
|
+
const processors = [];
|
532
|
+
const logAttributes = {
|
533
|
+
traceEndpoints: [],
|
534
|
+
contextManager: false
|
535
|
+
};
|
536
|
+
let integrationName;
|
537
|
+
if (openTelemetry) {
|
538
|
+
const otelEndpoint = typeof openTelemetry === "string" ? openTelemetry : getEnvVar("OTEL_EXPORTER_OTLP_ENDPOINT", void 0);
|
539
|
+
log.debug({ exporterType, otelEndpoint }, "Setting up OTLP Exporter");
|
540
|
+
integrationName = "OpenTelemetry";
|
541
|
+
logAttributes.traceEndpoints.push({
|
542
|
+
url: otelEndpoint ?? null,
|
543
|
+
type: exporterType
|
544
|
+
});
|
545
|
+
log.debug({ type: exporterType }, "Loading OpenTelemetry exporter");
|
546
|
+
const { OTLPTraceExporter } = await import(`@opentelemetry/exporter-trace-${exporterType}`);
|
547
|
+
processors.push(
|
548
|
+
new BatchSpanProcessor(new OTLPTraceExporter({ url: otelEndpoint }))
|
549
|
+
);
|
550
|
+
}
|
551
|
+
if (accessToken) {
|
552
|
+
log.debug({ target, traceEndpoint }, "Setting up Hive Tracing");
|
553
|
+
integrationName ??= "Hive Tracing";
|
554
|
+
if (!target) {
|
555
|
+
ctx.log.error(
|
556
|
+
'Hive tracing needs a target. Please provide it through "--hive-target <target>"'
|
557
|
+
);
|
558
|
+
process.exit(1);
|
559
|
+
}
|
560
|
+
logAttributes.traceEndpoints.push({
|
561
|
+
url: traceEndpoint,
|
562
|
+
type: "hive tracing",
|
563
|
+
target
|
564
|
+
});
|
565
|
+
processors.push(
|
566
|
+
new HiveTracingSpanProcessor({
|
567
|
+
accessToken,
|
568
|
+
target,
|
569
|
+
endpoint: traceEndpoint
|
570
|
+
})
|
571
|
+
);
|
572
|
+
}
|
573
|
+
log.debug("Trying to load AsyncLocalStorage based Context Manager");
|
574
|
+
const contextManager = await import('@opentelemetry/context-async-hooks').then((module) => {
|
575
|
+
logAttributes.contextManager = true;
|
576
|
+
return new module.AsyncLocalStorageContextManager();
|
577
|
+
}).catch(() => null);
|
578
|
+
openTelemetrySetup({
|
579
|
+
traces: { processors },
|
580
|
+
contextManager
|
581
|
+
});
|
582
|
+
log.info(logAttributes, `${integrationName} integration is enabled`);
|
583
|
+
return true;
|
584
|
+
});
|
585
|
+
}
|
586
|
+
return false;
|
587
|
+
}
|
588
|
+
|
488
589
|
function handleReportingConfig(ctx, loadedConfig, cliOpts) {
|
489
590
|
const confOpts = {
|
490
591
|
...loadedConfig.reporting?.type === "hive" ? {
|
491
592
|
hiveRegistryToken: loadedConfig.reporting.token,
|
492
|
-
|
593
|
+
hiveTarget: loadedConfig.reporting.target,
|
493
594
|
hiveUsageAccessToken: loadedConfig.reporting.token
|
494
595
|
} : {},
|
495
596
|
...loadedConfig.reporting?.type === "graphos" ? {
|
@@ -497,32 +598,45 @@ function handleReportingConfig(ctx, loadedConfig, cliOpts) {
|
|
497
598
|
apolloKey: loadedConfig.reporting.apiKey
|
498
599
|
} : {}
|
499
600
|
};
|
500
|
-
const opts = {
|
601
|
+
const opts = {
|
602
|
+
...confOpts,
|
603
|
+
...cliOpts,
|
604
|
+
hiveTarget: (
|
605
|
+
// cli arguments always take precedence over config
|
606
|
+
confOpts.hiveTarget ?? cliOpts.hiveTarget ?? cliOpts.hiveUsageTarget
|
607
|
+
)
|
608
|
+
};
|
501
609
|
if (cliOpts.hiveRegistryToken && cliOpts.hiveUsageAccessToken) {
|
502
610
|
ctx.log.error(
|
503
611
|
'Cannot use "--hive-registry-token" with "--hive-usage-access-token". Please use "--hive-usage-target" and "--hive-usage-access-token" or the config instead.'
|
504
612
|
);
|
505
613
|
process.exit(1);
|
506
614
|
}
|
507
|
-
if (cliOpts.
|
615
|
+
if (cliOpts.hiveUsageTarget && cliOpts.hiveTarget) {
|
616
|
+
ctx.log.error(
|
617
|
+
'Cannot use "--hive-usage-target" with "--hive-target". Please only use "--hive-target"'
|
618
|
+
);
|
619
|
+
process.exit(1);
|
620
|
+
}
|
621
|
+
if (cliOpts.hiveRegistryToken && opts.hiveTarget) {
|
508
622
|
ctx.log.error(
|
509
623
|
'Cannot use "--hive-registry-token" with a target. Please use "--hive-usage-target" and "--hive-usage-access-token" or the config instead.'
|
510
624
|
);
|
511
625
|
process.exit(1);
|
512
626
|
}
|
513
|
-
if (opts.
|
627
|
+
if (opts.hiveTarget && !opts.hiveAccessToken && !opts.hiveUsageAccessToken && !opts.hiveTraceAccessToken) {
|
514
628
|
ctx.log.error(
|
515
|
-
'Hive usage target needs an access token. Please provide it through
|
629
|
+
'Hive usage target needs an access token. Please provide it through "--hive-access-token <token>", or specific "--hive-usage-access-token <token>" and "--hive-trace-access-token" options, or the config.'
|
516
630
|
);
|
517
631
|
process.exit(1);
|
518
632
|
}
|
519
|
-
if (opts.hiveUsageAccessToken && !opts.
|
633
|
+
if ((opts.hiveAccessToken || opts.hiveUsageAccessToken || opts.hiveTraceAccessToken) && !opts.hiveTarget) {
|
520
634
|
ctx.log.error(
|
521
|
-
'Hive
|
635
|
+
'Hive access token needs a target. Please provide it through the "--hive-target <target>" option or the config.'
|
522
636
|
);
|
523
637
|
process.exit(1);
|
524
638
|
}
|
525
|
-
const hiveUsageAccessToken = opts.hiveUsageAccessToken || opts.hiveRegistryToken;
|
639
|
+
const hiveUsageAccessToken = opts.hiveAccessToken || opts.hiveUsageAccessToken || opts.hiveRegistryToken;
|
526
640
|
if (hiveUsageAccessToken) {
|
527
641
|
if (opts.hiveUsageTarget) {
|
528
642
|
ctx.log.info("Configuring Hive usage reporting");
|
@@ -533,7 +647,7 @@ function handleReportingConfig(ctx, loadedConfig, cliOpts) {
|
|
533
647
|
...loadedConfig.reporting,
|
534
648
|
type: "hive",
|
535
649
|
token: hiveUsageAccessToken,
|
536
|
-
target: opts.
|
650
|
+
target: opts.hiveTarget
|
537
651
|
};
|
538
652
|
}
|
539
653
|
if (opts.apolloKey) {
|
@@ -561,17 +675,30 @@ const addCommand$2 = (ctx, cli) => cli.command("proxy").description(
|
|
561
675
|
"path to the GraphQL schema file or a url from where to pull the schema"
|
562
676
|
).action(async function proxy(endpoint) {
|
563
677
|
const {
|
678
|
+
opentelemetry,
|
679
|
+
opentelemetryExporterType,
|
564
680
|
hiveCdnEndpoint,
|
565
681
|
hiveCdnKey,
|
566
682
|
hiveRegistryToken,
|
683
|
+
hiveTarget,
|
567
684
|
hiveUsageTarget,
|
685
|
+
hiveAccessToken,
|
568
686
|
hiveUsageAccessToken,
|
687
|
+
hiveTraceAccessToken,
|
688
|
+
hiveTraceEndpoint,
|
569
689
|
maskedErrors,
|
570
690
|
hivePersistedDocumentsEndpoint,
|
571
691
|
hivePersistedDocumentsToken,
|
572
692
|
...opts
|
573
693
|
} = this.optsWithGlobals();
|
574
694
|
ctx.log.info(`Starting ${ctx.productName} ${ctx.version} in proxy mode`);
|
695
|
+
const openTelemetryEnabledByCLI = await handleOpenTelemetryConfig(ctx, {
|
696
|
+
openTelemetry: opentelemetry,
|
697
|
+
openTelemetryExporterType: opentelemetryExporterType,
|
698
|
+
hiveTarget,
|
699
|
+
hiveTraceAccessToken,
|
700
|
+
hiveTraceEndpoint
|
701
|
+
});
|
575
702
|
const loadedConfig = await loadConfig({
|
576
703
|
log: ctx.log,
|
577
704
|
configPath: opts.configPath,
|
@@ -625,8 +752,11 @@ const addCommand$2 = (ctx, cli) => cli.command("proxy").description(
|
|
625
752
|
const registryConfig = {};
|
626
753
|
const reporting = handleReportingConfig(ctx, loadedConfig, {
|
627
754
|
hiveRegistryToken,
|
755
|
+
hiveTarget,
|
628
756
|
hiveUsageTarget,
|
757
|
+
hiveAccessToken,
|
629
758
|
hiveUsageAccessToken,
|
759
|
+
hiveTraceAccessToken,
|
630
760
|
// proxy can only do reporting to hive registry
|
631
761
|
apolloGraphRef: void 0,
|
632
762
|
apolloKey: void 0
|
@@ -647,7 +777,8 @@ const addCommand$2 = (ctx, cli) => cli.command("proxy").description(
|
|
647
777
|
const builtinPlugins = await getBuiltinPluginsFromConfig(
|
648
778
|
{
|
649
779
|
...loadedConfig,
|
650
|
-
...opts
|
780
|
+
...opts,
|
781
|
+
openTelemetry: openTelemetryEnabledByCLI ? { ...loadedConfig.openTelemetry, traces: true } : loadedConfig.openTelemetry
|
651
782
|
},
|
652
783
|
{
|
653
784
|
log: ctx.log,
|
@@ -722,15 +853,28 @@ const addCommand$1 = (ctx, cli) => cli.command("subgraph").description(
|
|
722
853
|
'path to the subgraph schema file or a url from where to pull the subgraph schema (default: "subgraph.graphql")'
|
723
854
|
).action(async function subgraph(schemaPathOrUrl) {
|
724
855
|
const {
|
856
|
+
opentelemetry,
|
857
|
+
opentelemetryExporterType,
|
725
858
|
maskedErrors,
|
726
859
|
hiveRegistryToken,
|
860
|
+
hiveTarget,
|
727
861
|
hiveUsageTarget,
|
862
|
+
hiveAccessToken,
|
728
863
|
hiveUsageAccessToken,
|
864
|
+
hiveTraceAccessToken,
|
865
|
+
hiveTraceEndpoint,
|
729
866
|
hivePersistedDocumentsEndpoint,
|
730
867
|
hivePersistedDocumentsToken,
|
731
868
|
...opts
|
732
869
|
} = this.optsWithGlobals();
|
733
870
|
ctx.log.info(`Starting ${ctx.productName} ${ctx.version} as subgraph`);
|
871
|
+
const openTelemetryEnabledByCLI = await handleOpenTelemetryConfig(ctx, {
|
872
|
+
openTelemetry: opentelemetry,
|
873
|
+
openTelemetryExporterType: opentelemetryExporterType,
|
874
|
+
hiveTarget,
|
875
|
+
hiveTraceAccessToken,
|
876
|
+
hiveTraceEndpoint
|
877
|
+
});
|
734
878
|
const loadedConfig = await loadConfig({
|
735
879
|
log: ctx.log,
|
736
880
|
configPath: opts.configPath,
|
@@ -746,8 +890,11 @@ const addCommand$1 = (ctx, cli) => cli.command("subgraph").description(
|
|
746
890
|
const registryConfig = {};
|
747
891
|
const reporting = handleReportingConfig(ctx, loadedConfig, {
|
748
892
|
hiveRegistryToken,
|
893
|
+
hiveTarget,
|
749
894
|
hiveUsageTarget,
|
895
|
+
hiveAccessToken,
|
750
896
|
hiveUsageAccessToken,
|
897
|
+
hiveTraceAccessToken,
|
751
898
|
// subgraph can only do reporting to hive registry
|
752
899
|
apolloGraphRef: void 0,
|
753
900
|
apolloKey: void 0
|
@@ -768,7 +915,8 @@ const addCommand$1 = (ctx, cli) => cli.command("subgraph").description(
|
|
768
915
|
const builtinPlugins = await getBuiltinPluginsFromConfig(
|
769
916
|
{
|
770
917
|
...loadedConfig,
|
771
|
-
...opts
|
918
|
+
...opts,
|
919
|
+
openTelemetry: openTelemetryEnabledByCLI ? { ...loadedConfig.openTelemetry, traces: true } : loadedConfig.openTelemetry
|
772
920
|
},
|
773
921
|
{
|
774
922
|
log: ctx.log,
|
@@ -862,11 +1010,17 @@ const addCommand = (ctx, cli) => cli.command("supergraph").description(
|
|
862
1010
|
).env("APOLLO_SCHEMA_CONFIG_DELIVERY_ENDPOINT")
|
863
1011
|
).action(async function supergraph(schemaPathOrUrl) {
|
864
1012
|
const {
|
1013
|
+
opentelemetry,
|
1014
|
+
opentelemetryExporterType,
|
865
1015
|
hiveCdnEndpoint,
|
866
1016
|
hiveCdnKey,
|
867
1017
|
hiveRegistryToken,
|
868
1018
|
hiveUsageTarget,
|
1019
|
+
hiveTarget,
|
1020
|
+
hiveAccessToken,
|
869
1021
|
hiveUsageAccessToken,
|
1022
|
+
hiveTraceAccessToken,
|
1023
|
+
hiveTraceEndpoint,
|
870
1024
|
maskedErrors,
|
871
1025
|
apolloGraphRef,
|
872
1026
|
apolloKey,
|
@@ -878,6 +1032,13 @@ const addCommand = (ctx, cli) => cli.command("supergraph").description(
|
|
878
1032
|
ctx.log.info(
|
879
1033
|
`Starting ${ctx.productName} ${ctx.version} with supergraph`
|
880
1034
|
);
|
1035
|
+
const openTelemetryEnabledByCLI = await handleOpenTelemetryConfig(ctx, {
|
1036
|
+
openTelemetry: opentelemetry,
|
1037
|
+
openTelemetryExporterType: opentelemetryExporterType,
|
1038
|
+
hiveTarget,
|
1039
|
+
hiveTraceAccessToken,
|
1040
|
+
hiveTraceEndpoint
|
1041
|
+
});
|
881
1042
|
const loadedConfig = await loadConfig({
|
882
1043
|
log: ctx.log,
|
883
1044
|
configPath: opts.configPath,
|
@@ -963,6 +1124,9 @@ const addCommand = (ctx, cli) => cli.command("supergraph").description(
|
|
963
1124
|
}
|
964
1125
|
const registryConfig = {};
|
965
1126
|
const reporting = handleReportingConfig(ctx, loadedConfig, {
|
1127
|
+
hiveTarget,
|
1128
|
+
hiveAccessToken,
|
1129
|
+
hiveTraceAccessToken,
|
966
1130
|
hiveRegistryToken,
|
967
1131
|
hiveUsageTarget,
|
968
1132
|
hiveUsageAccessToken,
|
@@ -985,7 +1149,8 @@ const addCommand = (ctx, cli) => cli.command("supergraph").description(
|
|
985
1149
|
const builtinPlugins = await getBuiltinPluginsFromConfig(
|
986
1150
|
{
|
987
1151
|
...loadedConfig,
|
988
|
-
...opts
|
1152
|
+
...opts,
|
1153
|
+
openTelemetry: openTelemetryEnabledByCLI ? { ...loadedConfig.openTelemetry, traces: true } : loadedConfig.openTelemetry
|
989
1154
|
},
|
990
1155
|
{
|
991
1156
|
log: ctx.log,
|
@@ -1037,7 +1202,7 @@ const addCommand = (ctx, cli) => cli.command("supergraph").description(
|
|
1037
1202
|
process.exit(1);
|
1038
1203
|
}
|
1039
1204
|
return runSupergraph(ctx, config);
|
1040
|
-
}).allowUnknownOption(
|
1205
|
+
}).allowUnknownOption(getNodeEnv() === "test").allowExcessArguments(getNodeEnv() === "test");
|
1041
1206
|
async function runSupergraph({ log }, config) {
|
1042
1207
|
let absSchemaPath = null;
|
1043
1208
|
if (typeof config.supergraph === "string" && isValidPath(config.supergraph) && !isUrl(config.supergraph)) {
|
@@ -1235,27 +1400,57 @@ let cli = new Command().configureHelp({
|
|
1235
1400
|
// see here https://github.com/tj/commander.js/blob/970ecae402b253de691e6a9066fea22f38fe7431/lib/command.js#L655
|
1236
1401
|
// @ts-expect-error
|
1237
1402
|
null
|
1403
|
+
).addOption(
|
1404
|
+
new Option(
|
1405
|
+
"--opentelemetry [exporter-endpoint]",
|
1406
|
+
`Enable OpenTelemetry integration with an exporter using this option's value as endpoint. By default, it uses OTLP HTTP, use "--opentelemetry-exporter-type" to change the default.`
|
1407
|
+
).env("OPENTELEMETRY")
|
1408
|
+
).addOption(
|
1409
|
+
new Option(
|
1410
|
+
"--opentelemetry-exporter-type <type>",
|
1411
|
+
`OpenTelemetry exporter type to use when setting up OpenTelemetry integration. Requires "--opentelemetry" to set the endpoint.`
|
1412
|
+
).choices(["otlp-http", "otlp-grpc"]).default("otlp-http").env("OPENTELEMETRY_EXPORTER_TYPE")
|
1238
1413
|
).addOption(
|
1239
1414
|
new Option(
|
1240
1415
|
"--hive-registry-token <token>",
|
1241
|
-
'[DEPRECATED: please use "--hive-
|
1416
|
+
'[DEPRECATED: please use "--hive-target" and "--hive-access-token"] Hive registry token for usage metrics reporting'
|
1242
1417
|
).env("HIVE_REGISTRY_TOKEN")
|
1243
1418
|
).addOption(
|
1244
1419
|
new Option(
|
1245
1420
|
"--hive-usage-target <target>",
|
1246
|
-
|
1421
|
+
"[DEPRECATED] please use --hive-target instead."
|
1247
1422
|
).env("HIVE_USAGE_TARGET")
|
1423
|
+
).addOption(
|
1424
|
+
new Option(
|
1425
|
+
"--hive-target <target>",
|
1426
|
+
'Hive registry target to which the usage and tracing data should be reported to. Requires either "--hive-access-token <token>", "--hive-usage-access-token <token>" or "--hive-trace-access-token" option'
|
1427
|
+
).env("HIVE_TARGET")
|
1428
|
+
).addOption(
|
1429
|
+
new Option(
|
1430
|
+
"--hive-access-token <token>",
|
1431
|
+
'Hive registry access token for usage metrics reporting and tracing. Enables both usage reporting and tracing. Requires the "--hive-target <target>" option'
|
1432
|
+
).env("HIVE_ACCESS_TOKEN")
|
1248
1433
|
).addOption(
|
1249
1434
|
new Option(
|
1250
1435
|
"--hive-usage-access-token <token>",
|
1251
|
-
|
1436
|
+
`Hive registry access token for usage reporting. Enables Hive usage report. Requires the "--hive-target <target>" option. It can't be used together with "--hive-access-token"`
|
1252
1437
|
).env("HIVE_USAGE_ACCESS_TOKEN")
|
1438
|
+
).addOption(
|
1439
|
+
new Option(
|
1440
|
+
"--hive-trace-access-token <token>",
|
1441
|
+
`Hive registry access token for tracing. Enables Hive tracing. Requires the "--hive-target <target>" option. It can't be used together with "--hive-access-token"`
|
1442
|
+
).env("HIVE_TRACE_ACCESS_TOKEN")
|
1443
|
+
).addOption(
|
1444
|
+
new Option(
|
1445
|
+
"--hive-trace-endpoint <endpoint>",
|
1446
|
+
`Hive registry tracing endpoint.`
|
1447
|
+
).env("HIVE_TRACE_ENDPOINT").default(`https://api.graphql-hive.com/otel/v1/traces`)
|
1253
1448
|
).option(
|
1254
1449
|
"--hive-persisted-documents-endpoint <endpoint>",
|
1255
|
-
'[EXPERIMENTAL] Hive CDN endpoint for fetching the persisted documents.
|
1450
|
+
'[EXPERIMENTAL] Hive CDN endpoint for fetching the persisted documents. Requires the "--hive-persisted-documents-token <token>" option'
|
1256
1451
|
).option(
|
1257
1452
|
"--hive-persisted-documents-token <token>",
|
1258
|
-
'[EXPERIMENTAL] Hive persisted documents CDN endpoint token.
|
1453
|
+
'[EXPERIMENTAL] Hive persisted documents CDN endpoint token. Requires the "--hive-persisted-documents-endpoint <endpoint>" option'
|
1259
1454
|
).addOption(
|
1260
1455
|
new Option(
|
1261
1456
|
"--hive-cdn-endpoint <endpoint>",
|
@@ -1279,9 +1474,11 @@ let cli = new Command().configureHelp({
|
|
1279
1474
|
).option("--disable-websockets", "Disable WebSockets support").addOption(
|
1280
1475
|
new Option(
|
1281
1476
|
"--jit",
|
1282
|
-
"Enable Just-In-Time compilation of GraphQL documents"
|
1477
|
+
"Enable Just-In-Time compilation of GraphQL documents (env: JIT)"
|
1283
1478
|
).env("JIT")
|
1284
|
-
)
|
1479
|
+
).on("optionEnv:jit", function() {
|
1480
|
+
this.setOptionValueWithSource("jit", getEnvBool("JIT"), "env");
|
1481
|
+
});
|
1285
1482
|
async function run(userCtx) {
|
1286
1483
|
const ctx = {
|
1287
1484
|
log: userCtx.log || new Logger(),
|
@@ -1305,7 +1502,7 @@ async function run(userCtx) {
|
|
1305
1502
|
function handleNodeWarnings() {
|
1306
1503
|
const originalProcessEmitWarning = process.emitWarning.bind(process);
|
1307
1504
|
process.emitWarning = function gatewayEmitWarning(warning, ...opts) {
|
1308
|
-
if (
|
1505
|
+
if (isDebug()) {
|
1309
1506
|
originalProcessEmitWarning(warning, ...opts);
|
1310
1507
|
}
|
1311
1508
|
};
|
package/dist/index.cjs
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
var cli = require('./cli-
|
3
|
+
var cli = require('./cli-3udwdx7_.cjs');
|
4
4
|
var logger = require('@graphql-hive/logger');
|
5
5
|
var gatewayRuntime = require('@graphql-hive/gateway-runtime');
|
6
6
|
var pubsub = require('@graphql-hive/pubsub');
|
@@ -31,6 +31,7 @@ require('node:fs');
|
|
31
31
|
require('node:http');
|
32
32
|
require('node:https');
|
33
33
|
require('@graphql-tools/utils');
|
34
|
+
require('@opentelemetry/sdk-trace-base');
|
34
35
|
require('@graphql-tools/code-file-loader');
|
35
36
|
require('@graphql-tools/graphql-file-loader');
|
36
37
|
require('@graphql-tools/load');
|
package/dist/index.d.cts
CHANGED
@@ -107,13 +107,13 @@ interface GatewayCLIHiveReportingOptions extends Omit<GatewayHiveReportingOption
|
|
107
107
|
/**
|
108
108
|
* The target to which the usage data should be reported to.
|
109
109
|
*
|
110
|
-
* @default
|
110
|
+
* @default env.HIVE_USAGE_TARGET
|
111
111
|
*/
|
112
112
|
target?: GatewayHiveReportingOptions['target'];
|
113
113
|
/**
|
114
114
|
* Hive registry access token for usage metrics reporting.
|
115
115
|
*
|
116
|
-
* @default
|
116
|
+
* @default env.HIVE_USAGE_ACCESS_TOKEN || env.HIVE_REGISTRY_TOKEN
|
117
117
|
*/
|
118
118
|
token?: GatewayHiveReportingOptions['token'];
|
119
119
|
}
|
@@ -268,9 +268,15 @@ declare let cli: Command<[], {
|
|
268
268
|
port?: number | undefined;
|
269
269
|
polling?: number | undefined;
|
270
270
|
maskedErrors: string | boolean | string[] | [];
|
271
|
+
opentelemetry?: string | true | undefined;
|
272
|
+
opentelemetryExporterType: "otlp-http" | "otlp-grpc";
|
271
273
|
hiveRegistryToken?: string | undefined;
|
272
274
|
hiveUsageTarget?: string | undefined;
|
275
|
+
hiveTarget?: string | undefined;
|
276
|
+
hiveAccessToken?: string | undefined;
|
273
277
|
hiveUsageAccessToken?: string | undefined;
|
278
|
+
hiveTraceAccessToken?: string | undefined;
|
279
|
+
hiveTraceEndpoint: string;
|
274
280
|
hivePersistedDocumentsEndpoint?: string | undefined;
|
275
281
|
hivePersistedDocumentsToken?: string | undefined;
|
276
282
|
hiveCdnEndpoint?: string | undefined;
|
@@ -287,9 +293,15 @@ declare function run(userCtx: Partial<CLIContext>): Promise<Command<[], {
|
|
287
293
|
port?: number | undefined;
|
288
294
|
polling?: number | undefined;
|
289
295
|
maskedErrors: string | boolean | string[] | [];
|
296
|
+
opentelemetry?: string | true | undefined;
|
297
|
+
opentelemetryExporterType: "otlp-http" | "otlp-grpc";
|
290
298
|
hiveRegistryToken?: string | undefined;
|
291
299
|
hiveUsageTarget?: string | undefined;
|
300
|
+
hiveTarget?: string | undefined;
|
301
|
+
hiveAccessToken?: string | undefined;
|
292
302
|
hiveUsageAccessToken?: string | undefined;
|
303
|
+
hiveTraceAccessToken?: string | undefined;
|
304
|
+
hiveTraceEndpoint: string;
|
293
305
|
hivePersistedDocumentsEndpoint?: string | undefined;
|
294
306
|
hivePersistedDocumentsToken?: string | undefined;
|
295
307
|
hiveCdnEndpoint?: string | undefined;
|
package/dist/index.d.ts
CHANGED
@@ -107,13 +107,13 @@ interface GatewayCLIHiveReportingOptions extends Omit<GatewayHiveReportingOption
|
|
107
107
|
/**
|
108
108
|
* The target to which the usage data should be reported to.
|
109
109
|
*
|
110
|
-
* @default
|
110
|
+
* @default env.HIVE_USAGE_TARGET
|
111
111
|
*/
|
112
112
|
target?: GatewayHiveReportingOptions['target'];
|
113
113
|
/**
|
114
114
|
* Hive registry access token for usage metrics reporting.
|
115
115
|
*
|
116
|
-
* @default
|
116
|
+
* @default env.HIVE_USAGE_ACCESS_TOKEN || env.HIVE_REGISTRY_TOKEN
|
117
117
|
*/
|
118
118
|
token?: GatewayHiveReportingOptions['token'];
|
119
119
|
}
|
@@ -268,9 +268,15 @@ declare let cli: Command<[], {
|
|
268
268
|
port?: number | undefined;
|
269
269
|
polling?: number | undefined;
|
270
270
|
maskedErrors: string | boolean | string[] | [];
|
271
|
+
opentelemetry?: string | true | undefined;
|
272
|
+
opentelemetryExporterType: "otlp-http" | "otlp-grpc";
|
271
273
|
hiveRegistryToken?: string | undefined;
|
272
274
|
hiveUsageTarget?: string | undefined;
|
275
|
+
hiveTarget?: string | undefined;
|
276
|
+
hiveAccessToken?: string | undefined;
|
273
277
|
hiveUsageAccessToken?: string | undefined;
|
278
|
+
hiveTraceAccessToken?: string | undefined;
|
279
|
+
hiveTraceEndpoint: string;
|
274
280
|
hivePersistedDocumentsEndpoint?: string | undefined;
|
275
281
|
hivePersistedDocumentsToken?: string | undefined;
|
276
282
|
hiveCdnEndpoint?: string | undefined;
|
@@ -287,9 +293,15 @@ declare function run(userCtx: Partial<CLIContext>): Promise<Command<[], {
|
|
287
293
|
port?: number | undefined;
|
288
294
|
polling?: number | undefined;
|
289
295
|
maskedErrors: string | boolean | string[] | [];
|
296
|
+
opentelemetry?: string | true | undefined;
|
297
|
+
opentelemetryExporterType: "otlp-http" | "otlp-grpc";
|
290
298
|
hiveRegistryToken?: string | undefined;
|
291
299
|
hiveUsageTarget?: string | undefined;
|
300
|
+
hiveTarget?: string | undefined;
|
301
|
+
hiveAccessToken?: string | undefined;
|
292
302
|
hiveUsageAccessToken?: string | undefined;
|
303
|
+
hiveTraceAccessToken?: string | undefined;
|
304
|
+
hiveTraceEndpoint: string;
|
293
305
|
hivePersistedDocumentsEndpoint?: string | undefined;
|
294
306
|
hivePersistedDocumentsToken?: string | undefined;
|
295
307
|
hiveCdnEndpoint?: string | undefined;
|
package/dist/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
export { b as defaultOptions, d as defineConfig, e as enableModuleCachingIfPossible, a as getBuiltinPluginsFromConfig, g as getCacheInstanceFromConfig, h as handleNodeWarnings, r as run } from './cli-
|
1
|
+
export { b as defaultOptions, d as defineConfig, e as enableModuleCachingIfPossible, a as getBuiltinPluginsFromConfig, g as getCacheInstanceFromConfig, h as handleNodeWarnings, r as run } from './cli-DcLVI5BX.js';
|
2
2
|
export * from '@graphql-hive/logger';
|
3
3
|
export * from '@graphql-hive/gateway-runtime';
|
4
4
|
export { PubSub } from '@graphql-hive/pubsub';
|
@@ -30,6 +30,7 @@ import 'node:fs';
|
|
30
30
|
import 'node:http';
|
31
31
|
import 'node:https';
|
32
32
|
import '@graphql-tools/utils';
|
33
|
+
import '@opentelemetry/sdk-trace-base';
|
33
34
|
import '@graphql-tools/code-file-loader';
|
34
35
|
import '@graphql-tools/graphql-file-loader';
|
35
36
|
import '@graphql-tools/load';
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@graphql-hive/gateway",
|
3
|
-
"version": "2.0.0-alpha-
|
3
|
+
"version": "2.0.0-alpha-7125411993448274610947015e30dd5b3461ded1",
|
4
4
|
"type": "module",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -53,28 +53,28 @@
|
|
53
53
|
"@escape.tech/graphql-armor-block-field-suggestions": "^3.0.0",
|
54
54
|
"@escape.tech/graphql-armor-max-depth": "^2.4.0",
|
55
55
|
"@escape.tech/graphql-armor-max-tokens": "^2.5.0",
|
56
|
-
"@graphql-hive/gateway-runtime": "2.0.0-alpha-
|
57
|
-
"@graphql-hive/importer": "2.0.0-alpha-
|
58
|
-
"@graphql-hive/logger": "1.0.1-alpha-
|
59
|
-
"@graphql-hive/plugin-aws-sigv4": "2.0.0-alpha-
|
60
|
-
"@graphql-hive/plugin-deduplicate-request": "2.0.0-alpha-
|
61
|
-
"@graphql-hive/pubsub": "2.0.0-alpha-
|
56
|
+
"@graphql-hive/gateway-runtime": "2.0.0-alpha-7125411993448274610947015e30dd5b3461ded1",
|
57
|
+
"@graphql-hive/importer": "2.0.0-alpha-7125411993448274610947015e30dd5b3461ded1",
|
58
|
+
"@graphql-hive/logger": "1.0.1-alpha-7125411993448274610947015e30dd5b3461ded1",
|
59
|
+
"@graphql-hive/plugin-aws-sigv4": "2.0.0-alpha-7125411993448274610947015e30dd5b3461ded1",
|
60
|
+
"@graphql-hive/plugin-deduplicate-request": "2.0.0-alpha-7125411993448274610947015e30dd5b3461ded1",
|
61
|
+
"@graphql-hive/pubsub": "2.0.0-alpha-7125411993448274610947015e30dd5b3461ded1",
|
62
62
|
"@graphql-mesh/cache-cfw-kv": "^0.105.5",
|
63
63
|
"@graphql-mesh/cache-localforage": "^0.105.6",
|
64
64
|
"@graphql-mesh/cache-redis": "^0.104.5",
|
65
65
|
"@graphql-mesh/cache-upstash-redis": "^0.1.5",
|
66
66
|
"@graphql-mesh/cross-helpers": "^0.4.10",
|
67
|
-
"@graphql-mesh/hmac-upstream-signature": "2.0.0-alpha-
|
67
|
+
"@graphql-mesh/hmac-upstream-signature": "2.0.0-alpha-7125411993448274610947015e30dd5b3461ded1",
|
68
68
|
"@graphql-mesh/plugin-http-cache": "^0.105.6",
|
69
69
|
"@graphql-mesh/plugin-jit": "^0.2.5",
|
70
|
-
"@graphql-mesh/plugin-jwt-auth": "2.0.0-alpha-
|
71
|
-
"@graphql-mesh/plugin-opentelemetry": "2.0.0-alpha-
|
72
|
-
"@graphql-mesh/plugin-prometheus": "2.0.0-alpha-
|
70
|
+
"@graphql-mesh/plugin-jwt-auth": "2.0.0-alpha-7125411993448274610947015e30dd5b3461ded1",
|
71
|
+
"@graphql-mesh/plugin-opentelemetry": "2.0.0-alpha-7125411993448274610947015e30dd5b3461ded1",
|
72
|
+
"@graphql-mesh/plugin-prometheus": "2.0.0-alpha-7125411993448274610947015e30dd5b3461ded1",
|
73
73
|
"@graphql-mesh/plugin-rate-limit": "^0.104.5",
|
74
74
|
"@graphql-mesh/plugin-snapshot": "^0.104.5",
|
75
|
-
"@graphql-mesh/transport-http": "1.0.0-alpha-
|
76
|
-
"@graphql-mesh/transport-http-callback": "1.0.0-alpha-
|
77
|
-
"@graphql-mesh/transport-ws": "2.0.0-alpha-
|
75
|
+
"@graphql-mesh/transport-http": "1.0.0-alpha-7125411993448274610947015e30dd5b3461ded1",
|
76
|
+
"@graphql-mesh/transport-http-callback": "1.0.0-alpha-7125411993448274610947015e30dd5b3461ded1",
|
77
|
+
"@graphql-mesh/transport-ws": "2.0.0-alpha-7125411993448274610947015e30dd5b3461ded1",
|
78
78
|
"@graphql-mesh/types": "^0.104.5",
|
79
79
|
"@graphql-mesh/utils": "^0.104.5",
|
80
80
|
"@graphql-tools/code-file-loader": "^8.1.15",
|
@@ -84,6 +84,7 @@
|
|
84
84
|
"@graphql-yoga/render-graphiql": "^5.15.1",
|
85
85
|
"@opentelemetry/api": "^1.9.0",
|
86
86
|
"@opentelemetry/api-logs": "^0.202.0",
|
87
|
+
"@opentelemetry/context-async-hooks": "^2.0.1",
|
87
88
|
"@opentelemetry/context-zone": "^2.0.1",
|
88
89
|
"@opentelemetry/core": "^2.0.1",
|
89
90
|
"@opentelemetry/exporter-jaeger": "^2.0.1",
|
@@ -93,15 +94,16 @@
|
|
93
94
|
"@opentelemetry/sampler-jaeger-remote": "^0.202.0",
|
94
95
|
"@opentelemetry/sdk-logs": "^0.202.0",
|
95
96
|
"@opentelemetry/sdk-metrics": "^2.0.1",
|
97
|
+
"@opentelemetry/sdk-trace-base": "^2.0.1",
|
96
98
|
"commander": "^13.1.0",
|
97
99
|
"dotenv": "^17.2.0",
|
98
|
-
"graphql-ws": "^6.0.
|
100
|
+
"graphql-ws": "^6.0.6",
|
99
101
|
"graphql-yoga": "^5.15.1",
|
100
102
|
"tslib": "^2.8.1",
|
101
103
|
"ws": "^8.18.3"
|
102
104
|
},
|
103
105
|
"devDependencies": {
|
104
|
-
"@graphql-mesh/transport-common": "1.0.0-alpha-
|
106
|
+
"@graphql-mesh/transport-common": "1.0.0-alpha-7125411993448274610947015e30dd5b3461ded1",
|
105
107
|
"@graphql-mesh/transport-soap": "^0.10.6",
|
106
108
|
"@graphql-tools/executor": "^1.4.7",
|
107
109
|
"@rollup/plugin-commonjs": "^28.0.0",
|
@@ -112,7 +114,7 @@
|
|
112
114
|
"@types/adm-zip": "^0.5.5",
|
113
115
|
"@types/bun": "1.2.18",
|
114
116
|
"@types/ws": "^8.5.12",
|
115
|
-
"@whatwg-node/fetch": "^0.10.
|
117
|
+
"@whatwg-node/fetch": "^0.10.9",
|
116
118
|
"adm-zip": "^0.5.15",
|
117
119
|
"bun": "^1.2.18",
|
118
120
|
"graphql": "^16.9.0",
|