@graphql-hive/gateway-runtime 2.4.0-alpha-905497611eff623b4c782baf8e5a2d3f3aa2446e → 2.4.0-alpha-f5c948dc129d453f43378098ef0956fa6f6531c2
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 +66 -25
- package/dist/index.cjs +145 -95
- package/dist/index.d.cts +9 -3
- package/dist/index.d.ts +9 -3
- package/dist/index.js +148 -98
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,49 +1,90 @@
|
|
|
1
1
|
# @graphql-hive/gateway-runtime
|
|
2
2
|
|
|
3
|
-
## 2.4.0-alpha-
|
|
3
|
+
## 2.4.0-alpha-f5c948dc129d453f43378098ef0956fa6f6531c2
|
|
4
4
|
### Minor Changes
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
- [#
|
|
8
|
+
- [#1738](https://github.com/graphql-hive/gateway/pull/1738) [`5a2207f`](https://github.com/graphql-hive/gateway/commit/5a2207f13466d56376ae246d4226b6d214b6b3a3) Thanks [@EmrysMyrddin](https://github.com/EmrysMyrddin)! - New Hive CDN mirror and circuit breaker
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
Hive CDN introduced a new CDN mirror and circuit breaker to mitigate the risk related to Cloudflare
|
|
11
|
+
services failures.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
You can now provide multiple endpoint in Hive Console related features, and configure the circuit
|
|
14
|
+
breaker handling CDN failure and how it switches to the CDN mirror.
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
### Usage
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
- `locations`: The list of related locations in the document source
|
|
20
|
-
- `coordinate`: The schema coordinate of the resolver which is the source of the error
|
|
18
|
+
To enable this feature, please provide the mirror endpoint in `supergraph` and `persistedDocument`
|
|
19
|
+
options:
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
```diff
|
|
22
|
+
import { defineConfig } from '@graphql-hive/gateway'
|
|
23
|
+
|
|
24
|
+
export const gatewayConfig = defineConfig({
|
|
25
|
+
supergraph: {
|
|
26
|
+
type: 'hive',
|
|
27
|
+
- endpoint: 'https://cdn.graphql-hive.com/artifacts/v1/<target-id>/supergraph',
|
|
28
|
+
+ endpoint: [
|
|
29
|
+
+ 'https://cdn.graphql-hive.com/artifacts/v1/<target-id>/supergraph',
|
|
30
|
+
+ 'https://cdn-mirror.graphql-hive.com/artifacts/v1/<target-id>/supergraph'
|
|
31
|
+
+ ]
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
persistedDocuments: {
|
|
35
|
+
- endpoint: 'https://cdn.graphql-hive.com/<target-id>',
|
|
36
|
+
+ endpoint: [
|
|
37
|
+
+ 'https://cdn.graphql-hive.com/<target-id>',
|
|
38
|
+
+ 'https://cdn-mirror.graphql-hive.com/<target-id>'
|
|
39
|
+
+ ]
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Configuration
|
|
45
|
+
|
|
46
|
+
The circuit breaker has production ready default configuration, but you customize its behavior:
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import { defineConfig, CircuitBreakerConfiguration } from '@graphql-hive/gateway';
|
|
50
|
+
|
|
51
|
+
const circuitBreaker: CircuitBreakerConfiguration = {
|
|
52
|
+
resetTimeout: 30_000; // 30s
|
|
53
|
+
errorThresholdPercentage: 50;
|
|
54
|
+
volumeThreshold: 5;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const gatewayConfig = defineConfig({
|
|
58
|
+
supergraph: {
|
|
59
|
+
type: 'hive',
|
|
60
|
+
endpoint: [...],
|
|
61
|
+
circuitBreaker,
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
persistedDocuments: {
|
|
65
|
+
type: 'hive',
|
|
66
|
+
endpoint: [...],
|
|
67
|
+
circuitBreaker,
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
```
|
|
25
71
|
|
|
26
72
|
### Patch Changes
|
|
27
73
|
|
|
28
74
|
|
|
29
75
|
|
|
30
|
-
- [#1636](https://github.com/graphql-hive/gateway/pull/1636) [`1495bd9`](https://github.com/graphql-hive/gateway/commit/1495bd90d9603bb1c66676a2d31990b16c3f3c4d) Thanks [@EmrysMyrddin](https://github.com/EmrysMyrddin)! - dependencies updates:
|
|
31
|
-
|
|
32
|
-
- Updated dependency [`graphql-yoga@^5.17.0` ↗︎](https://www.npmjs.com/package/graphql-yoga/v/5.17.0) (from `^5.16.2`, in `dependencies`)
|
|
33
|
-
|
|
34
|
-
|
|
35
76
|
- [#1747](https://github.com/graphql-hive/gateway/pull/1747) [`8fdaef5`](https://github.com/graphql-hive/gateway/commit/8fdaef56d70998dacaed829c278fa7079062ad67) Thanks [@dependabot](https://github.com/apps/dependabot)! - dependencies updates:
|
|
36
77
|
|
|
37
78
|
- Updated dependency [`@graphql-hive/core@^0.18.0` ↗︎](https://www.npmjs.com/package/@graphql-hive/core/v/0.18.0) (from `^0.15.1`, in `dependencies`)
|
|
38
79
|
- Updated dependency [`@graphql-hive/yoga@^0.46.0` ↗︎](https://www.npmjs.com/package/@graphql-hive/yoga/v/0.46.0) (from `^0.43.1`, in `dependencies`)
|
|
39
|
-
- Updated dependencies [[`
|
|
40
|
-
- @graphql-
|
|
41
|
-
- @graphql-tools/delegate@12.0.2-alpha-905497611eff623b4c782baf8e5a2d3f3aa2446e
|
|
80
|
+
- Updated dependencies [[`da8b8e3`](https://github.com/graphql-hive/gateway/commit/da8b8e3f3545487249b11c6577e3889f68527249)]:
|
|
81
|
+
- @graphql-tools/delegate@12.0.2-alpha-f5c948dc129d453f43378098ef0956fa6f6531c2
|
|
42
82
|
- @graphql-mesh/hmac-upstream-signature@2.0.8
|
|
43
|
-
- @graphql-tools/batch-delegate@10.0.8-alpha-
|
|
44
|
-
- @graphql-tools/federation@4.2.6-alpha-
|
|
45
|
-
- @graphql-
|
|
46
|
-
- @graphql-tools/
|
|
83
|
+
- @graphql-tools/batch-delegate@10.0.8-alpha-f5c948dc129d453f43378098ef0956fa6f6531c2
|
|
84
|
+
- @graphql-tools/federation@4.2.6-alpha-f5c948dc129d453f43378098ef0956fa6f6531c2
|
|
85
|
+
- @graphql-mesh/fusion-runtime@1.6.2-alpha-f5c948dc129d453f43378098ef0956fa6f6531c2
|
|
86
|
+
- @graphql-tools/stitch@10.1.6-alpha-f5c948dc129d453f43378098ef0956fa6f6531c2
|
|
87
|
+
- @graphql-tools/wrap@11.1.2-alpha-f5c948dc129d453f43378098ef0956fa6f6531c2
|
|
47
88
|
|
|
48
89
|
## 2.3.7
|
|
49
90
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -143,8 +143,7 @@ const getExecuteFnFromExecutor = utils.memoize1(
|
|
|
143
143
|
operationName: args.operationName ?? void 0,
|
|
144
144
|
rootValue: args.rootValue,
|
|
145
145
|
context: args.contextValue,
|
|
146
|
-
signal: args.signal
|
|
147
|
-
schemaCoordinateInErrors: args.schemaCoordinateInErrors
|
|
146
|
+
signal: args.signal
|
|
148
147
|
});
|
|
149
148
|
};
|
|
150
149
|
}
|
|
@@ -609,6 +608,7 @@ function getReportingPlugin(config, configContext, allowArbitraryDocuments = fal
|
|
|
609
608
|
endpoint: config.persistedDocuments.endpoint,
|
|
610
609
|
accessToken: config.persistedDocuments.token
|
|
611
610
|
},
|
|
611
|
+
circuitBreaker: config.persistedDocuments.circuitBreaker,
|
|
612
612
|
// Trick to satisfy the Hive Console plugin types
|
|
613
613
|
allowArbitraryDocuments
|
|
614
614
|
}
|
|
@@ -2044,6 +2044,7 @@ function createGatewayRuntime(config) {
|
|
|
2044
2044
|
endpoint: config.persistedDocuments.endpoint,
|
|
2045
2045
|
accessToken: config.persistedDocuments.token
|
|
2046
2046
|
},
|
|
2047
|
+
circuitBreaker: config.persistedDocuments.circuitBreaker,
|
|
2047
2048
|
// @ts-expect-error - Hive Console plugin options are not compatible yet
|
|
2048
2049
|
allowArbitraryDocuments: allowArbitraryDocumentsForPersistedDocuments
|
|
2049
2050
|
}
|
|
@@ -2063,7 +2064,7 @@ function createGatewayRuntime(config) {
|
|
|
2063
2064
|
clearTimeout(currentTimeout);
|
|
2064
2065
|
}
|
|
2065
2066
|
if (pollingInterval) {
|
|
2066
|
-
currentTimeout = setTimeout(schemaFetcher, pollingInterval);
|
|
2067
|
+
currentTimeout = setTimeout(schemaFetcher.fetch, pollingInterval);
|
|
2067
2068
|
}
|
|
2068
2069
|
}, pausePolling2 = function() {
|
|
2069
2070
|
if (currentTimeout) {
|
|
@@ -2087,79 +2088,103 @@ function createGatewayRuntime(config) {
|
|
|
2087
2088
|
let initialFetch$;
|
|
2088
2089
|
let schemaFetcher;
|
|
2089
2090
|
if (config.schema && typeof config.schema === "object" && "type" in config.schema) {
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2091
|
+
let ensureSdl2 = function(endpoint2) {
|
|
2092
|
+
endpoint2 = endpoint2.replace(/\/services$/, "/sdl");
|
|
2093
|
+
if (!/\/sdl(\.graphql)*$/.test(endpoint2)) {
|
|
2094
|
+
endpoint2 = core$1.joinUrl(endpoint2, "sdl");
|
|
2095
|
+
}
|
|
2096
|
+
return endpoint2;
|
|
2097
|
+
};
|
|
2098
|
+
const { endpoint, key, circuitBreaker } = config.schema;
|
|
2099
|
+
const fetcher = core$1.createCDNArtifactFetcher({
|
|
2100
|
+
endpoint: Array.isArray(endpoint) ? (
|
|
2101
|
+
// no endpoint.map just to make ts happy without casting
|
|
2102
|
+
[ensureSdl2(endpoint[0]), ensureSdl2(endpoint[1])]
|
|
2103
|
+
) : ensureSdl2(endpoint),
|
|
2104
|
+
circuitBreaker,
|
|
2105
|
+
accessKey: key,
|
|
2094
2106
|
logger: configContext.log.child("[hiveSchemaFetcher] ")
|
|
2095
2107
|
});
|
|
2096
|
-
schemaFetcher =
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2108
|
+
schemaFetcher = {
|
|
2109
|
+
fetch: function fetchSchemaFromCDN() {
|
|
2110
|
+
pausePolling2();
|
|
2111
|
+
initialFetch$ = promiseHelpers.handleMaybePromise(
|
|
2112
|
+
fetcher.fetch,
|
|
2113
|
+
({ contents }) => {
|
|
2114
|
+
{
|
|
2115
|
+
unifiedGraph = graphql.buildSchema(contents, {
|
|
2116
|
+
assumeValid: true,
|
|
2117
|
+
assumeValidSDL: true
|
|
2118
|
+
});
|
|
2119
|
+
}
|
|
2120
|
+
continuePolling2();
|
|
2121
|
+
return true;
|
|
2122
|
+
}
|
|
2123
|
+
);
|
|
2124
|
+
return initialFetch$;
|
|
2125
|
+
},
|
|
2126
|
+
dispose: () => fetcher.dispose()
|
|
2109
2127
|
};
|
|
2110
2128
|
} else if (config.schema) {
|
|
2111
2129
|
if (!isDynamicUnifiedGraphSchema(config.schema)) {
|
|
2112
2130
|
delete config.pollingInterval;
|
|
2113
2131
|
}
|
|
2114
|
-
schemaFetcher =
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2132
|
+
schemaFetcher = {
|
|
2133
|
+
fetch: function fetchSchema() {
|
|
2134
|
+
pausePolling2();
|
|
2135
|
+
initialFetch$ = promiseHelpers.handleMaybePromise(
|
|
2136
|
+
() => handleUnifiedGraphConfig(
|
|
2137
|
+
// @ts-expect-error TODO: what's up with type narrowing
|
|
2138
|
+
config.schema,
|
|
2139
|
+
configContext
|
|
2140
|
+
),
|
|
2141
|
+
(schema) => {
|
|
2142
|
+
if (graphql.isSchema(schema)) {
|
|
2143
|
+
unifiedGraph = schema;
|
|
2144
|
+
} else if (utils.isDocumentNode(schema)) {
|
|
2145
|
+
unifiedGraph = graphql.buildASTSchema(schema, {
|
|
2146
|
+
assumeValid: true,
|
|
2147
|
+
assumeValidSDL: true
|
|
2148
|
+
});
|
|
2149
|
+
} else {
|
|
2150
|
+
unifiedGraph = graphql.buildSchema(schema, {
|
|
2151
|
+
noLocation: true,
|
|
2152
|
+
assumeValid: true,
|
|
2153
|
+
assumeValidSDL: true
|
|
2154
|
+
});
|
|
2155
|
+
}
|
|
2156
|
+
continuePolling2();
|
|
2157
|
+
return true;
|
|
2136
2158
|
}
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
);
|
|
2141
|
-
return initialFetch$;
|
|
2159
|
+
);
|
|
2160
|
+
return initialFetch$;
|
|
2161
|
+
}
|
|
2142
2162
|
};
|
|
2143
2163
|
} else {
|
|
2144
|
-
schemaFetcher =
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2164
|
+
schemaFetcher = {
|
|
2165
|
+
fetch: function fetchSchemaWithExecutor() {
|
|
2166
|
+
pausePolling2();
|
|
2167
|
+
return promiseHelpers.handleMaybePromise(
|
|
2168
|
+
() => wrap.schemaFromExecutor(proxyExecutor, configContext, {
|
|
2169
|
+
assumeValid: true
|
|
2170
|
+
}),
|
|
2171
|
+
(schema) => {
|
|
2172
|
+
unifiedGraph = schema;
|
|
2173
|
+
continuePolling2();
|
|
2174
|
+
return true;
|
|
2175
|
+
}
|
|
2176
|
+
);
|
|
2177
|
+
}
|
|
2156
2178
|
};
|
|
2157
2179
|
}
|
|
2158
|
-
const instrumentedFetcher = schemaFetcher;
|
|
2159
|
-
schemaFetcher =
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2180
|
+
const instrumentedFetcher = schemaFetcher.fetch;
|
|
2181
|
+
schemaFetcher = {
|
|
2182
|
+
...schemaFetcher,
|
|
2183
|
+
fetch: (...args) => core.getInstrumented(null).asyncFn(
|
|
2184
|
+
instrumentation?.schema,
|
|
2185
|
+
instrumentedFetcher
|
|
2186
|
+
)(...args)
|
|
2187
|
+
};
|
|
2163
2188
|
getSchema = () => {
|
|
2164
2189
|
if (unifiedGraph != null) {
|
|
2165
2190
|
return unifiedGraph;
|
|
@@ -2170,10 +2195,10 @@ function createGatewayRuntime(config) {
|
|
|
2170
2195
|
() => unifiedGraph
|
|
2171
2196
|
);
|
|
2172
2197
|
}
|
|
2173
|
-
return promiseHelpers.handleMaybePromise(schemaFetcher, () => unifiedGraph);
|
|
2198
|
+
return promiseHelpers.handleMaybePromise(schemaFetcher.fetch, () => unifiedGraph);
|
|
2174
2199
|
};
|
|
2175
2200
|
const shouldSkipValidation = "skipValidation" in config ? config.skipValidation : false;
|
|
2176
|
-
|
|
2201
|
+
unifiedGraphPlugin = {
|
|
2177
2202
|
onValidate({ params, setResult }) {
|
|
2178
2203
|
if (shouldSkipValidation || !params.schema) {
|
|
2179
2204
|
setResult([]);
|
|
@@ -2181,10 +2206,12 @@ function createGatewayRuntime(config) {
|
|
|
2181
2206
|
},
|
|
2182
2207
|
onDispose() {
|
|
2183
2208
|
pausePolling2();
|
|
2184
|
-
return
|
|
2209
|
+
return promiseHelpers.handleMaybePromise(
|
|
2210
|
+
() => transportExecutorStack.disposeAsync(),
|
|
2211
|
+
() => schemaFetcher.dispose?.()
|
|
2212
|
+
);
|
|
2185
2213
|
}
|
|
2186
2214
|
};
|
|
2187
|
-
unifiedGraphPlugin = executorPlugin;
|
|
2188
2215
|
readinessChecker = () => promiseHelpers.handleMaybePromise(
|
|
2189
2216
|
() => proxyExecutor({
|
|
2190
2217
|
document: graphql.parse(`query ReadinessCheck { __typename }`, {
|
|
@@ -2195,7 +2222,7 @@ function createGatewayRuntime(config) {
|
|
|
2195
2222
|
);
|
|
2196
2223
|
schemaInvalidator = () => {
|
|
2197
2224
|
unifiedGraph = void 0;
|
|
2198
|
-
initialFetch$ = schemaFetcher();
|
|
2225
|
+
initialFetch$ = schemaFetcher.fetch();
|
|
2199
2226
|
};
|
|
2200
2227
|
} else if ("subgraph" in config) {
|
|
2201
2228
|
let getSubschemaConfig2 = function() {
|
|
@@ -2410,31 +2437,46 @@ function createGatewayRuntime(config) {
|
|
|
2410
2437
|
let unifiedGraphFetcher;
|
|
2411
2438
|
if (typeof config.supergraph === "object" && "type" in config.supergraph) {
|
|
2412
2439
|
if (config.supergraph.type === "hive") {
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2440
|
+
let ensureSupergraph2 = function(endpoint2) {
|
|
2441
|
+
if (!/\/supergraph(\.graphql)*$/.test(endpoint2)) {
|
|
2442
|
+
endpoint2 = core$1.joinUrl(endpoint2, "supergraph");
|
|
2443
|
+
}
|
|
2444
|
+
return endpoint2;
|
|
2445
|
+
};
|
|
2446
|
+
const { endpoint, key, circuitBreaker } = config.supergraph;
|
|
2447
|
+
const fetcher = core$1.createCDNArtifactFetcher({
|
|
2448
|
+
endpoint: Array.isArray(endpoint) ? (
|
|
2449
|
+
// no endpoint.map just to make ts happy without casting
|
|
2450
|
+
[ensureSupergraph2(endpoint[0]), ensureSupergraph2(endpoint[1])]
|
|
2451
|
+
) : ensureSupergraph2(endpoint),
|
|
2452
|
+
accessKey: key,
|
|
2453
|
+
logger: configContext.log.child("[hiveSupergraphFetcher] "),
|
|
2420
2454
|
// @ts-expect-error - MeshFetch is not compatible with `typeof fetch`
|
|
2421
|
-
|
|
2455
|
+
fetch: configContext.fetch,
|
|
2456
|
+
circuitBreaker,
|
|
2422
2457
|
name: "hive-gateway",
|
|
2423
2458
|
version: globalThis.__VERSION__
|
|
2424
2459
|
});
|
|
2425
|
-
unifiedGraphFetcher =
|
|
2460
|
+
unifiedGraphFetcher = {
|
|
2461
|
+
fetch: () => fetcher.fetch().then(({ contents }) => contents),
|
|
2462
|
+
dispose: () => fetcher.dispose()
|
|
2463
|
+
};
|
|
2426
2464
|
} else if (config.supergraph.type === "graphos") {
|
|
2427
2465
|
const graphosFetcherContainer = createGraphOSFetcher({
|
|
2428
2466
|
graphosOpts: config.supergraph,
|
|
2429
2467
|
configContext,
|
|
2430
2468
|
pollingInterval: config.pollingInterval
|
|
2431
2469
|
});
|
|
2432
|
-
unifiedGraphFetcher =
|
|
2470
|
+
unifiedGraphFetcher = {
|
|
2471
|
+
fetch: graphosFetcherContainer.unifiedGraphFetcher
|
|
2472
|
+
};
|
|
2433
2473
|
} else {
|
|
2434
|
-
unifiedGraphFetcher =
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2474
|
+
unifiedGraphFetcher = {
|
|
2475
|
+
fetch: () => {
|
|
2476
|
+
throw new Error(
|
|
2477
|
+
`Unknown supergraph configuration: ${config.supergraph}`
|
|
2478
|
+
);
|
|
2479
|
+
}
|
|
2438
2480
|
};
|
|
2439
2481
|
}
|
|
2440
2482
|
} else {
|
|
@@ -2446,20 +2488,25 @@ function createGatewayRuntime(config) {
|
|
|
2446
2488
|
`Polling interval not set for supergraph, if you want to get updates of supergraph, we recommend setting a polling interval`
|
|
2447
2489
|
);
|
|
2448
2490
|
}
|
|
2449
|
-
unifiedGraphFetcher =
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2491
|
+
unifiedGraphFetcher = {
|
|
2492
|
+
fetch: () => handleUnifiedGraphConfig(
|
|
2493
|
+
// @ts-expect-error TODO: what's up with type narrowing
|
|
2494
|
+
config.supergraph,
|
|
2495
|
+
configContext
|
|
2496
|
+
)
|
|
2497
|
+
};
|
|
2454
2498
|
}
|
|
2455
|
-
const instrumentedGraphFetcher = unifiedGraphFetcher;
|
|
2456
|
-
unifiedGraphFetcher =
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2499
|
+
const instrumentedGraphFetcher = unifiedGraphFetcher.fetch;
|
|
2500
|
+
unifiedGraphFetcher = {
|
|
2501
|
+
...unifiedGraphFetcher,
|
|
2502
|
+
fetch: (...args) => core.getInstrumented(null).asyncFn(
|
|
2503
|
+
instrumentation?.schema,
|
|
2504
|
+
instrumentedGraphFetcher
|
|
2505
|
+
)(...args)
|
|
2506
|
+
};
|
|
2460
2507
|
const unifiedGraphManager = new fusionRuntime.UnifiedGraphManager({
|
|
2461
2508
|
handleUnifiedGraph: config.unifiedGraphHandler,
|
|
2462
|
-
getUnifiedGraph: unifiedGraphFetcher,
|
|
2509
|
+
getUnifiedGraph: unifiedGraphFetcher.fetch,
|
|
2463
2510
|
onUnifiedGraphChange(newUnifiedGraph) {
|
|
2464
2511
|
unifiedGraph = newUnifiedGraph;
|
|
2465
2512
|
replaceSchema(newUnifiedGraph);
|
|
@@ -2509,7 +2556,10 @@ function createGatewayRuntime(config) {
|
|
|
2509
2556
|
getExecutor = () => unifiedGraphManager.getExecutor();
|
|
2510
2557
|
unifiedGraphPlugin = {
|
|
2511
2558
|
onDispose() {
|
|
2512
|
-
return
|
|
2559
|
+
return promiseHelpers.handleMaybePromise(
|
|
2560
|
+
() => utils$1.dispose(unifiedGraphManager),
|
|
2561
|
+
() => unifiedGraphFetcher.dispose?.()
|
|
2562
|
+
);
|
|
2513
2563
|
}
|
|
2514
2564
|
};
|
|
2515
2565
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -5,6 +5,8 @@ import { Plugin as Plugin$1 } from '@envelop/core';
|
|
|
5
5
|
export { withState } from '@envelop/core';
|
|
6
6
|
import { GenericAuthPluginOptions } from '@envelop/generic-auth';
|
|
7
7
|
export { ResolveUserFn, ValidateUserFn } from '@envelop/generic-auth';
|
|
8
|
+
import { HivePluginOptions, CircuitBreakerConfiguration } from '@graphql-hive/core';
|
|
9
|
+
export { CircuitBreakerConfiguration } from '@graphql-hive/core';
|
|
8
10
|
import { Logger, LogLevel } from '@graphql-hive/logger';
|
|
9
11
|
export * from '@graphql-hive/logger';
|
|
10
12
|
import { PubSub } from '@graphql-hive/pubsub';
|
|
@@ -22,7 +24,6 @@ import { UsePersistedOperationsOptions } from '@graphql-yoga/plugin-persisted-op
|
|
|
22
24
|
import { GraphQLResolveInfo } from 'graphql/type';
|
|
23
25
|
import { Agent } from 'node:http';
|
|
24
26
|
import { Agent as Agent$1 } from 'node:https';
|
|
25
|
-
import { HivePluginOptions } from '@graphql-hive/core';
|
|
26
27
|
import { FetchAPI } from '@whatwg-node/server';
|
|
27
28
|
export * from '@whatwg-node/disposablestack';
|
|
28
29
|
import { Context, ConnectionInitMessage, ServerOptions } from 'graphql-ws';
|
|
@@ -414,11 +415,12 @@ interface GatewayHiveCDNOptions {
|
|
|
414
415
|
/**
|
|
415
416
|
* GraphQL Hive CDN endpoint URL.
|
|
416
417
|
*/
|
|
417
|
-
endpoint: string;
|
|
418
|
+
endpoint: string | [string, string];
|
|
418
419
|
/**
|
|
419
420
|
* GraphQL Hive CDN access key.
|
|
420
421
|
*/
|
|
421
422
|
key: string;
|
|
423
|
+
circuitBreaker?: CircuitBreakerConfiguration;
|
|
422
424
|
}
|
|
423
425
|
interface GatewayHiveReportingOptions extends Omit<HiveConsolePluginOptions, 'experimental__persistedDocuments'> {
|
|
424
426
|
type: 'hive';
|
|
@@ -507,7 +509,11 @@ interface GatewayHivePersistedDocumentsOptions {
|
|
|
507
509
|
/**
|
|
508
510
|
* GraphQL Hive persisted documents CDN endpoint URL.
|
|
509
511
|
*/
|
|
510
|
-
endpoint: string;
|
|
512
|
+
endpoint: string | [string, string];
|
|
513
|
+
/**
|
|
514
|
+
* Circuit Breaker configuration to customize CDN failures handling and switch to mirror endpoint.
|
|
515
|
+
*/
|
|
516
|
+
circuitBreaker?: CircuitBreakerConfiguration;
|
|
511
517
|
/**
|
|
512
518
|
* GraphQL Hive persisted documents CDN access token.
|
|
513
519
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ import { Plugin as Plugin$1 } from '@envelop/core';
|
|
|
5
5
|
export { withState } from '@envelop/core';
|
|
6
6
|
import { GenericAuthPluginOptions } from '@envelop/generic-auth';
|
|
7
7
|
export { ResolveUserFn, ValidateUserFn } from '@envelop/generic-auth';
|
|
8
|
+
import { HivePluginOptions, CircuitBreakerConfiguration } from '@graphql-hive/core';
|
|
9
|
+
export { CircuitBreakerConfiguration } from '@graphql-hive/core';
|
|
8
10
|
import { Logger, LogLevel } from '@graphql-hive/logger';
|
|
9
11
|
export * from '@graphql-hive/logger';
|
|
10
12
|
import { PubSub } from '@graphql-hive/pubsub';
|
|
@@ -22,7 +24,6 @@ import { UsePersistedOperationsOptions } from '@graphql-yoga/plugin-persisted-op
|
|
|
22
24
|
import { GraphQLResolveInfo } from 'graphql/type';
|
|
23
25
|
import { Agent } from 'node:http';
|
|
24
26
|
import { Agent as Agent$1 } from 'node:https';
|
|
25
|
-
import { HivePluginOptions } from '@graphql-hive/core';
|
|
26
27
|
import { FetchAPI } from '@whatwg-node/server';
|
|
27
28
|
export * from '@whatwg-node/disposablestack';
|
|
28
29
|
import { Context, ConnectionInitMessage, ServerOptions } from 'graphql-ws';
|
|
@@ -414,11 +415,12 @@ interface GatewayHiveCDNOptions {
|
|
|
414
415
|
/**
|
|
415
416
|
* GraphQL Hive CDN endpoint URL.
|
|
416
417
|
*/
|
|
417
|
-
endpoint: string;
|
|
418
|
+
endpoint: string | [string, string];
|
|
418
419
|
/**
|
|
419
420
|
* GraphQL Hive CDN access key.
|
|
420
421
|
*/
|
|
421
422
|
key: string;
|
|
423
|
+
circuitBreaker?: CircuitBreakerConfiguration;
|
|
422
424
|
}
|
|
423
425
|
interface GatewayHiveReportingOptions extends Omit<HiveConsolePluginOptions, 'experimental__persistedDocuments'> {
|
|
424
426
|
type: 'hive';
|
|
@@ -507,7 +509,11 @@ interface GatewayHivePersistedDocumentsOptions {
|
|
|
507
509
|
/**
|
|
508
510
|
* GraphQL Hive persisted documents CDN endpoint URL.
|
|
509
511
|
*/
|
|
510
|
-
endpoint: string;
|
|
512
|
+
endpoint: string | [string, string];
|
|
513
|
+
/**
|
|
514
|
+
* Circuit Breaker configuration to customize CDN failures handling and switch to mirror endpoint.
|
|
515
|
+
*/
|
|
516
|
+
circuitBreaker?: CircuitBreakerConfiguration;
|
|
511
517
|
/**
|
|
512
518
|
* GraphQL Hive persisted documents CDN access token.
|
|
513
519
|
*/
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { isOriginalGraphQLError, getInstrumented as getInstrumented$1 } from '@e
|
|
|
2
2
|
export { withState } from '@envelop/core';
|
|
3
3
|
import { useDisableIntrospection } from '@envelop/disable-introspection';
|
|
4
4
|
import { useGenericAuth } from '@envelop/generic-auth';
|
|
5
|
-
import {
|
|
5
|
+
import { createCDNArtifactFetcher, joinUrl } from '@graphql-hive/core';
|
|
6
6
|
import { Logger, LegacyLogger } from '@graphql-hive/logger';
|
|
7
7
|
export * from '@graphql-hive/logger';
|
|
8
8
|
import { millisecondsToStr, getOnSubgraphExecute, UnifiedGraphManager, restoreExtraDirectives, getTransportEntryMapUsingFusionAndFederationDirectives, getStitchingDirectivesTransformerForSubschema, handleFederationSubschema, handleResolveToDirectives } from '@graphql-mesh/fusion-runtime';
|
|
@@ -15,7 +15,7 @@ import { batchDelegateToSchema } from '@graphql-tools/batch-delegate';
|
|
|
15
15
|
import { getTypeInfo, EMPTY_OBJECT, delegateToSchema, defaultMergedResolver } from '@graphql-tools/delegate';
|
|
16
16
|
import { defaultPrintFn as defaultPrintFn$1 } from '@graphql-tools/executor-common';
|
|
17
17
|
import { getDirectiveExtensions, memoize1, mergeDeep, isValidPath, pathToArray, memoize3, getDirective, createGraphQLError, isAsyncIterable, mapAsyncIterator, createDeferred, isPromise, isDocumentNode, asArray, printSchemaWithDirectives, parseSelectionSet } from '@graphql-tools/utils';
|
|
18
|
-
import {
|
|
18
|
+
import { schemaFromExecutor, wrapSchema } from '@graphql-tools/wrap';
|
|
19
19
|
import { useCSRFPrevention } from '@graphql-yoga/plugin-csrf-prevention';
|
|
20
20
|
import { useDeferStream } from '@graphql-yoga/plugin-defer-stream';
|
|
21
21
|
import { usePersistedOperations } from '@graphql-yoga/plugin-persisted-operations';
|
|
@@ -23,7 +23,7 @@ import { AsyncDisposableStack } from '@whatwg-node/disposablestack';
|
|
|
23
23
|
export * from '@whatwg-node/disposablestack';
|
|
24
24
|
import { handleMaybePromise, iterateAsync } from '@whatwg-node/promise-helpers';
|
|
25
25
|
import { useCookies } from '@whatwg-node/server-plugin-cookies';
|
|
26
|
-
import { print, visit, visitWithTypeInfo, getArgumentValues, getNamedType, isIntrospectionType, isListType, isCompositeType, getOperationAST, isSchema, parse,
|
|
26
|
+
import { print, visit, visitWithTypeInfo, getArgumentValues, getNamedType, isIntrospectionType, isListType, isCompositeType, getOperationAST, isSchema, parse, buildSchema, buildASTSchema } from 'graphql';
|
|
27
27
|
import { isAsyncIterable as isAsyncIterable$1, useReadinessCheck, useExecutionCancellation, createYoga, chain, mergeSchemas } from 'graphql-yoga';
|
|
28
28
|
import { DEFAULT_UPLINKS, fetchSupergraphSdlFromManagedFederation } from '@graphql-tools/federation';
|
|
29
29
|
import { useApolloUsageReport } from '@graphql-yoga/plugin-apollo-usage-report';
|
|
@@ -142,8 +142,7 @@ const getExecuteFnFromExecutor = memoize1(
|
|
|
142
142
|
operationName: args.operationName ?? void 0,
|
|
143
143
|
rootValue: args.rootValue,
|
|
144
144
|
context: args.contextValue,
|
|
145
|
-
signal: args.signal
|
|
146
|
-
schemaCoordinateInErrors: args.schemaCoordinateInErrors
|
|
145
|
+
signal: args.signal
|
|
147
146
|
});
|
|
148
147
|
};
|
|
149
148
|
}
|
|
@@ -608,6 +607,7 @@ function getReportingPlugin(config, configContext, allowArbitraryDocuments = fal
|
|
|
608
607
|
endpoint: config.persistedDocuments.endpoint,
|
|
609
608
|
accessToken: config.persistedDocuments.token
|
|
610
609
|
},
|
|
610
|
+
circuitBreaker: config.persistedDocuments.circuitBreaker,
|
|
611
611
|
// Trick to satisfy the Hive Console plugin types
|
|
612
612
|
allowArbitraryDocuments
|
|
613
613
|
}
|
|
@@ -2043,6 +2043,7 @@ function createGatewayRuntime(config) {
|
|
|
2043
2043
|
endpoint: config.persistedDocuments.endpoint,
|
|
2044
2044
|
accessToken: config.persistedDocuments.token
|
|
2045
2045
|
},
|
|
2046
|
+
circuitBreaker: config.persistedDocuments.circuitBreaker,
|
|
2046
2047
|
// @ts-expect-error - Hive Console plugin options are not compatible yet
|
|
2047
2048
|
allowArbitraryDocuments: allowArbitraryDocumentsForPersistedDocuments
|
|
2048
2049
|
}
|
|
@@ -2062,7 +2063,7 @@ function createGatewayRuntime(config) {
|
|
|
2062
2063
|
clearTimeout(currentTimeout);
|
|
2063
2064
|
}
|
|
2064
2065
|
if (pollingInterval) {
|
|
2065
|
-
currentTimeout = setTimeout(schemaFetcher, pollingInterval);
|
|
2066
|
+
currentTimeout = setTimeout(schemaFetcher.fetch, pollingInterval);
|
|
2066
2067
|
}
|
|
2067
2068
|
}, pausePolling2 = function() {
|
|
2068
2069
|
if (currentTimeout) {
|
|
@@ -2086,79 +2087,103 @@ function createGatewayRuntime(config) {
|
|
|
2086
2087
|
let initialFetch$;
|
|
2087
2088
|
let schemaFetcher;
|
|
2088
2089
|
if (config.schema && typeof config.schema === "object" && "type" in config.schema) {
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2090
|
+
let ensureSdl2 = function(endpoint2) {
|
|
2091
|
+
endpoint2 = endpoint2.replace(/\/services$/, "/sdl");
|
|
2092
|
+
if (!/\/sdl(\.graphql)*$/.test(endpoint2)) {
|
|
2093
|
+
endpoint2 = joinUrl(endpoint2, "sdl");
|
|
2094
|
+
}
|
|
2095
|
+
return endpoint2;
|
|
2096
|
+
};
|
|
2097
|
+
const { endpoint, key, circuitBreaker } = config.schema;
|
|
2098
|
+
const fetcher = createCDNArtifactFetcher({
|
|
2099
|
+
endpoint: Array.isArray(endpoint) ? (
|
|
2100
|
+
// no endpoint.map just to make ts happy without casting
|
|
2101
|
+
[ensureSdl2(endpoint[0]), ensureSdl2(endpoint[1])]
|
|
2102
|
+
) : ensureSdl2(endpoint),
|
|
2103
|
+
circuitBreaker,
|
|
2104
|
+
accessKey: key,
|
|
2093
2105
|
logger: configContext.log.child("[hiveSchemaFetcher] ")
|
|
2094
2106
|
});
|
|
2095
|
-
schemaFetcher =
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2107
|
+
schemaFetcher = {
|
|
2108
|
+
fetch: function fetchSchemaFromCDN() {
|
|
2109
|
+
pausePolling2();
|
|
2110
|
+
initialFetch$ = handleMaybePromise(
|
|
2111
|
+
fetcher.fetch,
|
|
2112
|
+
({ contents }) => {
|
|
2113
|
+
{
|
|
2114
|
+
unifiedGraph = buildSchema(contents, {
|
|
2115
|
+
assumeValid: true,
|
|
2116
|
+
assumeValidSDL: true
|
|
2117
|
+
});
|
|
2118
|
+
}
|
|
2119
|
+
continuePolling2();
|
|
2120
|
+
return true;
|
|
2121
|
+
}
|
|
2122
|
+
);
|
|
2123
|
+
return initialFetch$;
|
|
2124
|
+
},
|
|
2125
|
+
dispose: () => fetcher.dispose()
|
|
2108
2126
|
};
|
|
2109
2127
|
} else if (config.schema) {
|
|
2110
2128
|
if (!isDynamicUnifiedGraphSchema(config.schema)) {
|
|
2111
2129
|
delete config.pollingInterval;
|
|
2112
2130
|
}
|
|
2113
|
-
schemaFetcher =
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2131
|
+
schemaFetcher = {
|
|
2132
|
+
fetch: function fetchSchema() {
|
|
2133
|
+
pausePolling2();
|
|
2134
|
+
initialFetch$ = handleMaybePromise(
|
|
2135
|
+
() => handleUnifiedGraphConfig(
|
|
2136
|
+
// @ts-expect-error TODO: what's up with type narrowing
|
|
2137
|
+
config.schema,
|
|
2138
|
+
configContext
|
|
2139
|
+
),
|
|
2140
|
+
(schema) => {
|
|
2141
|
+
if (isSchema(schema)) {
|
|
2142
|
+
unifiedGraph = schema;
|
|
2143
|
+
} else if (isDocumentNode(schema)) {
|
|
2144
|
+
unifiedGraph = buildASTSchema(schema, {
|
|
2145
|
+
assumeValid: true,
|
|
2146
|
+
assumeValidSDL: true
|
|
2147
|
+
});
|
|
2148
|
+
} else {
|
|
2149
|
+
unifiedGraph = buildSchema(schema, {
|
|
2150
|
+
noLocation: true,
|
|
2151
|
+
assumeValid: true,
|
|
2152
|
+
assumeValidSDL: true
|
|
2153
|
+
});
|
|
2154
|
+
}
|
|
2155
|
+
continuePolling2();
|
|
2156
|
+
return true;
|
|
2135
2157
|
}
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
);
|
|
2140
|
-
return initialFetch$;
|
|
2158
|
+
);
|
|
2159
|
+
return initialFetch$;
|
|
2160
|
+
}
|
|
2141
2161
|
};
|
|
2142
2162
|
} else {
|
|
2143
|
-
schemaFetcher =
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2163
|
+
schemaFetcher = {
|
|
2164
|
+
fetch: function fetchSchemaWithExecutor() {
|
|
2165
|
+
pausePolling2();
|
|
2166
|
+
return handleMaybePromise(
|
|
2167
|
+
() => schemaFromExecutor(proxyExecutor, configContext, {
|
|
2168
|
+
assumeValid: true
|
|
2169
|
+
}),
|
|
2170
|
+
(schema) => {
|
|
2171
|
+
unifiedGraph = schema;
|
|
2172
|
+
continuePolling2();
|
|
2173
|
+
return true;
|
|
2174
|
+
}
|
|
2175
|
+
);
|
|
2176
|
+
}
|
|
2155
2177
|
};
|
|
2156
2178
|
}
|
|
2157
|
-
const instrumentedFetcher = schemaFetcher;
|
|
2158
|
-
schemaFetcher =
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2179
|
+
const instrumentedFetcher = schemaFetcher.fetch;
|
|
2180
|
+
schemaFetcher = {
|
|
2181
|
+
...schemaFetcher,
|
|
2182
|
+
fetch: (...args) => getInstrumented$1(null).asyncFn(
|
|
2183
|
+
instrumentation?.schema,
|
|
2184
|
+
instrumentedFetcher
|
|
2185
|
+
)(...args)
|
|
2186
|
+
};
|
|
2162
2187
|
getSchema = () => {
|
|
2163
2188
|
if (unifiedGraph != null) {
|
|
2164
2189
|
return unifiedGraph;
|
|
@@ -2169,10 +2194,10 @@ function createGatewayRuntime(config) {
|
|
|
2169
2194
|
() => unifiedGraph
|
|
2170
2195
|
);
|
|
2171
2196
|
}
|
|
2172
|
-
return handleMaybePromise(schemaFetcher, () => unifiedGraph);
|
|
2197
|
+
return handleMaybePromise(schemaFetcher.fetch, () => unifiedGraph);
|
|
2173
2198
|
};
|
|
2174
2199
|
const shouldSkipValidation = "skipValidation" in config ? config.skipValidation : false;
|
|
2175
|
-
|
|
2200
|
+
unifiedGraphPlugin = {
|
|
2176
2201
|
onValidate({ params, setResult }) {
|
|
2177
2202
|
if (shouldSkipValidation || !params.schema) {
|
|
2178
2203
|
setResult([]);
|
|
@@ -2180,10 +2205,12 @@ function createGatewayRuntime(config) {
|
|
|
2180
2205
|
},
|
|
2181
2206
|
onDispose() {
|
|
2182
2207
|
pausePolling2();
|
|
2183
|
-
return
|
|
2208
|
+
return handleMaybePromise(
|
|
2209
|
+
() => transportExecutorStack.disposeAsync(),
|
|
2210
|
+
() => schemaFetcher.dispose?.()
|
|
2211
|
+
);
|
|
2184
2212
|
}
|
|
2185
2213
|
};
|
|
2186
|
-
unifiedGraphPlugin = executorPlugin;
|
|
2187
2214
|
readinessChecker = () => handleMaybePromise(
|
|
2188
2215
|
() => proxyExecutor({
|
|
2189
2216
|
document: parse(`query ReadinessCheck { __typename }`, {
|
|
@@ -2194,7 +2221,7 @@ function createGatewayRuntime(config) {
|
|
|
2194
2221
|
);
|
|
2195
2222
|
schemaInvalidator = () => {
|
|
2196
2223
|
unifiedGraph = void 0;
|
|
2197
|
-
initialFetch$ = schemaFetcher();
|
|
2224
|
+
initialFetch$ = schemaFetcher.fetch();
|
|
2198
2225
|
};
|
|
2199
2226
|
} else if ("subgraph" in config) {
|
|
2200
2227
|
let getSubschemaConfig2 = function() {
|
|
@@ -2409,31 +2436,46 @@ function createGatewayRuntime(config) {
|
|
|
2409
2436
|
let unifiedGraphFetcher;
|
|
2410
2437
|
if (typeof config.supergraph === "object" && "type" in config.supergraph) {
|
|
2411
2438
|
if (config.supergraph.type === "hive") {
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2439
|
+
let ensureSupergraph2 = function(endpoint2) {
|
|
2440
|
+
if (!/\/supergraph(\.graphql)*$/.test(endpoint2)) {
|
|
2441
|
+
endpoint2 = joinUrl(endpoint2, "supergraph");
|
|
2442
|
+
}
|
|
2443
|
+
return endpoint2;
|
|
2444
|
+
};
|
|
2445
|
+
const { endpoint, key, circuitBreaker } = config.supergraph;
|
|
2446
|
+
const fetcher = createCDNArtifactFetcher({
|
|
2447
|
+
endpoint: Array.isArray(endpoint) ? (
|
|
2448
|
+
// no endpoint.map just to make ts happy without casting
|
|
2449
|
+
[ensureSupergraph2(endpoint[0]), ensureSupergraph2(endpoint[1])]
|
|
2450
|
+
) : ensureSupergraph2(endpoint),
|
|
2451
|
+
accessKey: key,
|
|
2452
|
+
logger: configContext.log.child("[hiveSupergraphFetcher] "),
|
|
2419
2453
|
// @ts-expect-error - MeshFetch is not compatible with `typeof fetch`
|
|
2420
|
-
|
|
2454
|
+
fetch: configContext.fetch,
|
|
2455
|
+
circuitBreaker,
|
|
2421
2456
|
name: "hive-gateway",
|
|
2422
2457
|
version: globalThis.__VERSION__
|
|
2423
2458
|
});
|
|
2424
|
-
unifiedGraphFetcher =
|
|
2459
|
+
unifiedGraphFetcher = {
|
|
2460
|
+
fetch: () => fetcher.fetch().then(({ contents }) => contents),
|
|
2461
|
+
dispose: () => fetcher.dispose()
|
|
2462
|
+
};
|
|
2425
2463
|
} else if (config.supergraph.type === "graphos") {
|
|
2426
2464
|
const graphosFetcherContainer = createGraphOSFetcher({
|
|
2427
2465
|
graphosOpts: config.supergraph,
|
|
2428
2466
|
configContext,
|
|
2429
2467
|
pollingInterval: config.pollingInterval
|
|
2430
2468
|
});
|
|
2431
|
-
unifiedGraphFetcher =
|
|
2469
|
+
unifiedGraphFetcher = {
|
|
2470
|
+
fetch: graphosFetcherContainer.unifiedGraphFetcher
|
|
2471
|
+
};
|
|
2432
2472
|
} else {
|
|
2433
|
-
unifiedGraphFetcher =
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2473
|
+
unifiedGraphFetcher = {
|
|
2474
|
+
fetch: () => {
|
|
2475
|
+
throw new Error(
|
|
2476
|
+
`Unknown supergraph configuration: ${config.supergraph}`
|
|
2477
|
+
);
|
|
2478
|
+
}
|
|
2437
2479
|
};
|
|
2438
2480
|
}
|
|
2439
2481
|
} else {
|
|
@@ -2445,20 +2487,25 @@ function createGatewayRuntime(config) {
|
|
|
2445
2487
|
`Polling interval not set for supergraph, if you want to get updates of supergraph, we recommend setting a polling interval`
|
|
2446
2488
|
);
|
|
2447
2489
|
}
|
|
2448
|
-
unifiedGraphFetcher =
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2490
|
+
unifiedGraphFetcher = {
|
|
2491
|
+
fetch: () => handleUnifiedGraphConfig(
|
|
2492
|
+
// @ts-expect-error TODO: what's up with type narrowing
|
|
2493
|
+
config.supergraph,
|
|
2494
|
+
configContext
|
|
2495
|
+
)
|
|
2496
|
+
};
|
|
2453
2497
|
}
|
|
2454
|
-
const instrumentedGraphFetcher = unifiedGraphFetcher;
|
|
2455
|
-
unifiedGraphFetcher =
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2498
|
+
const instrumentedGraphFetcher = unifiedGraphFetcher.fetch;
|
|
2499
|
+
unifiedGraphFetcher = {
|
|
2500
|
+
...unifiedGraphFetcher,
|
|
2501
|
+
fetch: (...args) => getInstrumented$1(null).asyncFn(
|
|
2502
|
+
instrumentation?.schema,
|
|
2503
|
+
instrumentedGraphFetcher
|
|
2504
|
+
)(...args)
|
|
2505
|
+
};
|
|
2459
2506
|
const unifiedGraphManager = new UnifiedGraphManager({
|
|
2460
2507
|
handleUnifiedGraph: config.unifiedGraphHandler,
|
|
2461
|
-
getUnifiedGraph: unifiedGraphFetcher,
|
|
2508
|
+
getUnifiedGraph: unifiedGraphFetcher.fetch,
|
|
2462
2509
|
onUnifiedGraphChange(newUnifiedGraph) {
|
|
2463
2510
|
unifiedGraph = newUnifiedGraph;
|
|
2464
2511
|
replaceSchema(newUnifiedGraph);
|
|
@@ -2508,7 +2555,10 @@ function createGatewayRuntime(config) {
|
|
|
2508
2555
|
getExecutor = () => unifiedGraphManager.getExecutor();
|
|
2509
2556
|
unifiedGraphPlugin = {
|
|
2510
2557
|
onDispose() {
|
|
2511
|
-
return
|
|
2558
|
+
return handleMaybePromise(
|
|
2559
|
+
() => dispose(unifiedGraphManager),
|
|
2560
|
+
() => unifiedGraphFetcher.dispose?.()
|
|
2561
|
+
);
|
|
2512
2562
|
}
|
|
2513
2563
|
};
|
|
2514
2564
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-hive/gateway-runtime",
|
|
3
|
-
"version": "2.4.0-alpha-
|
|
3
|
+
"version": "2.4.0-alpha-f5c948dc129d453f43378098ef0956fa6f6531c2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -55,20 +55,20 @@
|
|
|
55
55
|
"@graphql-hive/signal": "^2.0.0",
|
|
56
56
|
"@graphql-hive/yoga": "^0.46.0",
|
|
57
57
|
"@graphql-mesh/cross-helpers": "^0.4.10",
|
|
58
|
-
"@graphql-mesh/fusion-runtime": "1.6.2-alpha-
|
|
58
|
+
"@graphql-mesh/fusion-runtime": "1.6.2-alpha-f5c948dc129d453f43378098ef0956fa6f6531c2",
|
|
59
59
|
"@graphql-mesh/hmac-upstream-signature": "^2.0.8",
|
|
60
60
|
"@graphql-mesh/plugin-response-cache": "^0.104.18",
|
|
61
61
|
"@graphql-mesh/transport-common": "^1.0.12",
|
|
62
62
|
"@graphql-mesh/types": "^0.104.16",
|
|
63
63
|
"@graphql-mesh/utils": "^0.104.16",
|
|
64
|
-
"@graphql-tools/batch-delegate": "10.0.8-alpha-
|
|
65
|
-
"@graphql-tools/delegate": "12.0.2-alpha-
|
|
64
|
+
"@graphql-tools/batch-delegate": "10.0.8-alpha-f5c948dc129d453f43378098ef0956fa6f6531c2",
|
|
65
|
+
"@graphql-tools/delegate": "12.0.2-alpha-f5c948dc129d453f43378098ef0956fa6f6531c2",
|
|
66
66
|
"@graphql-tools/executor-common": "^1.0.5",
|
|
67
67
|
"@graphql-tools/executor-http": "^3.0.7",
|
|
68
|
-
"@graphql-tools/federation": "4.2.6-alpha-
|
|
69
|
-
"@graphql-tools/stitch": "10.1.6-alpha-
|
|
68
|
+
"@graphql-tools/federation": "4.2.6-alpha-f5c948dc129d453f43378098ef0956fa6f6531c2",
|
|
69
|
+
"@graphql-tools/stitch": "10.1.6-alpha-f5c948dc129d453f43378098ef0956fa6f6531c2",
|
|
70
70
|
"@graphql-tools/utils": "^10.10.3",
|
|
71
|
-
"@graphql-tools/wrap": "11.1.2-alpha-
|
|
71
|
+
"@graphql-tools/wrap": "11.1.2-alpha-f5c948dc129d453f43378098ef0956fa6f6531c2",
|
|
72
72
|
"@graphql-yoga/plugin-apollo-usage-report": "^0.12.0",
|
|
73
73
|
"@graphql-yoga/plugin-csrf-prevention": "^3.16.2",
|
|
74
74
|
"@graphql-yoga/plugin-defer-stream": "^3.16.2",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"@whatwg-node/server": "^0.10.17",
|
|
80
80
|
"@whatwg-node/server-plugin-cookies": "^1.0.5",
|
|
81
81
|
"graphql-ws": "^6.0.6",
|
|
82
|
-
"graphql-yoga": "^5.
|
|
82
|
+
"graphql-yoga": "^5.16.2",
|
|
83
83
|
"tslib": "^2.8.1"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|