Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .changeset/cold-bags-confess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
'@graphql-hive/gateway-runtime': minor
---

New Hive CDN mirror and circuit breaker

Hive CDN introduced a new CDN mirror and circuit breaker to mitigate the risk related to Cloudflare
services failures.

You can now provide multiple endpoint in Hive Console related features, and configure the circuit
breaker handling CDN failure and how it switches to the CDN mirror.

### Usage

To enable this feature, please provide the mirror endpoint in `supergraph` and `persistedDocument`
options:

```diff
import { defineConfig } from '@graphql-hive/gateway'

export const gatewayConfig = defineConfig({
supergraph: {
type: 'hive',
- endpoint: 'https://cdn.graphql-hive.com/artifacts/v1/<target-id>/supergraph',
+ endpoint: [
+ 'https://cdn.graphql-hive.com/artifacts/v1/<target-id>/supergraph',
+ 'https://cdn-mirror.graphql-hive.com/artifacts/v1/<target-id>/supergraph'
+ ]
},

persistedDocuments: {
- endpoint: 'https://cdn.graphql-hive.com/<target-id>',
+ endpoint: [
+ 'https://cdn.graphql-hive.com/<target-id>',
+ 'https://cdn-mirror.graphql-hive.com/<target-id>'
+ ]
}
})
```

### Configuration

The circuit breaker has production ready default configuration, but you customize its behavior:

```ts
import { defineConfig, CircuitBreakerConfiguration } from '@graphql-hive/gateway';

const circuitBreaker: CircuitBreakerConfiguration = {
resetTimeout: 30_000; // 30s
errorThresholdPercentage: 50;
volumeThreshold: 5;
}

export const gatewayConfig = defineConfig({
supergraph: {
type: 'hive',
endpoint: [...],
circuitBreaker,
},

persistedDocuments: {
type: 'hive',
endpoint: [...],
circuitBreaker,
},
});
```
2 changes: 1 addition & 1 deletion e2e/cloudflare-workers/wrangler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ compatibility_date = "2024-01-01"
"@graphql-tools/batch-delegate" = "../../packages/batch-delegate/src/index.ts"
"@graphql-tools/delegate" = "../../packages/delegate/src/index.ts"
"@graphql-hive/signal" = "../../packages/signal/src/index.ts"
"@graphql-hive/logger" = "../../packages/logger/src/index.ts"
"@graphql-hive/logger" = "../../packages/logger/src/index.ts"
2 changes: 1 addition & 1 deletion e2e/self-hosting-hive/self-hosting-hive.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('Self Hosting Hive', () => {
/\[hiveSupergraphFetcher\] GET .* succeeded with status 200/,
);
expect(gwLogs).toMatch(
/\[useHiveConsole\] POST .* succeeded with status 200/,
/\[useHiveConsole\] POST .*\/usage .* succeeded with status 200/,
);
});
});
Loading
Loading