@graphql-hive/gateway 2.0.0-next-d56e4a16201542cdbc486c0feb6d482a2a1a57a0 → 2.0.0-next-357c4246368d3cc93e4bd2d3df6e8a8f016491cd
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 +96 -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
@@ -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-next-
|
3
|
+
"version": "2.0.0-next-357c4246368d3cc93e4bd2d3df6e8a8f016491cd",
|
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-next-
|
57
|
-
"@graphql-hive/importer": "2.0.0-next-
|
58
|
-
"@graphql-hive/logger": "1.0.1-next-
|
59
|
-
"@graphql-hive/plugin-aws-sigv4": "2.0.0-next-
|
60
|
-
"@graphql-hive/plugin-deduplicate-request": "2.0.0-next-
|
61
|
-
"@graphql-hive/pubsub": "2.0.0-next-
|
56
|
+
"@graphql-hive/gateway-runtime": "2.0.0-next-357c4246368d3cc93e4bd2d3df6e8a8f016491cd",
|
57
|
+
"@graphql-hive/importer": "2.0.0-next-357c4246368d3cc93e4bd2d3df6e8a8f016491cd",
|
58
|
+
"@graphql-hive/logger": "1.0.1-next-357c4246368d3cc93e4bd2d3df6e8a8f016491cd",
|
59
|
+
"@graphql-hive/plugin-aws-sigv4": "2.0.0-next-357c4246368d3cc93e4bd2d3df6e8a8f016491cd",
|
60
|
+
"@graphql-hive/plugin-deduplicate-request": "2.0.0-next-357c4246368d3cc93e4bd2d3df6e8a8f016491cd",
|
61
|
+
"@graphql-hive/pubsub": "2.0.0-next-357c4246368d3cc93e4bd2d3df6e8a8f016491cd",
|
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-next-
|
67
|
+
"@graphql-mesh/hmac-upstream-signature": "2.0.0-next-357c4246368d3cc93e4bd2d3df6e8a8f016491cd",
|
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-next-
|
71
|
-
"@graphql-mesh/plugin-opentelemetry": "2.0.0-next-
|
72
|
-
"@graphql-mesh/plugin-prometheus": "2.0.0-next-
|
70
|
+
"@graphql-mesh/plugin-jwt-auth": "2.0.0-next-357c4246368d3cc93e4bd2d3df6e8a8f016491cd",
|
71
|
+
"@graphql-mesh/plugin-opentelemetry": "2.0.0-next-357c4246368d3cc93e4bd2d3df6e8a8f016491cd",
|
72
|
+
"@graphql-mesh/plugin-prometheus": "2.0.0-next-357c4246368d3cc93e4bd2d3df6e8a8f016491cd",
|
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-next-
|
76
|
-
"@graphql-mesh/transport-http-callback": "1.0.0-next-
|
77
|
-
"@graphql-mesh/transport-ws": "2.0.0-next-
|
75
|
+
"@graphql-mesh/transport-http": "1.0.0-next-357c4246368d3cc93e4bd2d3df6e8a8f016491cd",
|
76
|
+
"@graphql-mesh/transport-http-callback": "1.0.0-next-357c4246368d3cc93e4bd2d3df6e8a8f016491cd",
|
77
|
+
"@graphql-mesh/transport-ws": "2.0.0-next-357c4246368d3cc93e4bd2d3df6e8a8f016491cd",
|
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-next-
|
106
|
+
"@graphql-mesh/transport-common": "1.0.0-next-357c4246368d3cc93e4bd2d3df6e8a8f016491cd",
|
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",
|