Skip to content

Commit 8deb1d4

Browse files
committed
add changeset
1 parent 761959d commit 8deb1d4

File tree

2 files changed

+80
-10
lines changed

2 files changed

+80
-10
lines changed

.changeset/cold-bags-confess.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
'@graphql-hive/gateway-runtime': minor
3+
---
4+
5+
## New Hive CDN mirror and circuit breaker
6+
7+
Hive CDN introduced a new CDN mirror and circuit breaker to mitigate the risk related to Cloudflare
8+
services failures.
9+
10+
You can now provide multiple endpoint in Hive Console related features, and configure the circuit
11+
breaker handling CDN failure and how it switches to the CDN mirror.
12+
13+
### Usage
14+
15+
To enable this feature, please provide the mirror endpoint in `supergraph` and `persistedDocument`
16+
options:
17+
18+
```diff
19+
import { defineConfig } from '@graphql-hive/gateway'
20+
21+
export const gatewayConfig = defineConfig({
22+
supergraph: {
23+
type: 'hive',
24+
- endpoint: 'https://cdn.graphql-hive.com/artifacts/v1/...../supergraph',
25+
+ endpoint: [
26+
+ 'https://cdn.graphql-hive.com/artifacts/v1/...../supergraph',
27+
+ 'https://cdn-mirror.graphql-hive.com/artifacts/v1/...../supergraph'
28+
+ ]
29+
},
30+
31+
persistedDocuments: {
32+
- endpoint: 'https://cdn.graphql-hive.com/artifacts/v1/...',
33+
+ endpoint: [
34+
+ 'https://cdn.graphql-hive.com/artifacts/v1/...',
35+
+ 'https://cdn-mirror.graphql-hive.com/artifacts/v1/...'
36+
+ ]
37+
}
38+
})
39+
```
40+
41+
### Configuration
42+
43+
The circuit breaker has production ready default configuration, but you customize its behavior:
44+
45+
```ts
46+
import { defineConfig, CircuitBreakerConfiguration } from '@graphql-hive/gateway';
47+
48+
const circuitBreaker: CircuitBreakerConfiguration = {
49+
resetTimeout: 30_000; // 30s
50+
errorThresholdPercentage: 50;
51+
volumeThreshold: 5;
52+
}
53+
54+
export const gatewayConfig = defineConfig({
55+
supergraph: {
56+
type: 'hive',
57+
endpoint: [...],
58+
circuitBreaker,
59+
},
60+
61+
persistedDocuments: {
62+
type: 'hive',
63+
endpoint: [...],
64+
circuitBreaker,
65+
},
66+
});
67+
```

packages/runtime/src/types.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import { UpstreamTimeoutPluginOptions } from './plugins/useUpstreamTimeout';
5454

5555
export type { UnifiedGraphHandler, UnifiedGraphPlugin };
5656
export type { TransportEntryAdditions, UnifiedGraphConfig };
57+
export type { CircuitBreakerConfiguration };
5758

5859
export type GatewayConfig<
5960
TContext extends Record<string, any> = Record<string, any>,
@@ -87,7 +88,8 @@ export interface GatewayConfigContext {
8788
}
8889

8990
export interface GatewayContext
90-
extends GatewayConfigContext, YogaInitialContext {
91+
extends GatewayConfigContext,
92+
YogaInitialContext {
9193
/**
9294
* Environment agnostic HTTP headers provided with the request.
9395
*/
@@ -282,9 +284,8 @@ export interface GatewayConfigSubgraph<
282284
subgraph: UnifiedGraphConfig;
283285
}
284286

285-
export interface GatewayConfigSchemaBase<
286-
TContext extends Record<string, any>,
287-
> extends GatewayConfigBase<TContext> {
287+
export interface GatewayConfigSchemaBase<TContext extends Record<string, any>>
288+
extends GatewayConfigBase<TContext> {
288289
/**
289290
* Additional GraphQL schema type definitions.
290291
*/
@@ -344,11 +345,12 @@ export interface GatewayHiveCDNOptions {
344345
circuitBreaker?: CircuitBreakerConfiguration;
345346
}
346347

347-
export interface GatewayHiveReportingOptions extends Omit<
348-
HiveConsolePluginOptions,
349-
// we omit this property because we define persisted documents in GatewayHivePersistedDocumentsOptions
350-
'experimental__persistedDocuments'
351-
> {
348+
export interface GatewayHiveReportingOptions
349+
extends Omit<
350+
HiveConsolePluginOptions,
351+
// we omit this property because we define persisted documents in GatewayHivePersistedDocumentsOptions
352+
'experimental__persistedDocuments'
353+
> {
352354
type: 'hive';
353355
/** GraphQL Hive registry access token. */
354356
token: string;
@@ -374,7 +376,8 @@ export interface GatewayGraphOSOptions {
374376
apiKey: string;
375377
}
376378

377-
export interface GatewayGraphOSManagedFederationOptions extends GatewayGraphOSOptions {
379+
export interface GatewayGraphOSManagedFederationOptions
380+
extends GatewayGraphOSOptions {
378381
/**
379382
* Maximum number of retries to attempt when fetching the schema from the managed federation up link.
380383
*/

0 commit comments

Comments
 (0)