Skip to content

Conversation

@EmrysMyrddin
Copy link
Collaborator

@EmrysMyrddin EmrysMyrddin commented Nov 27, 2025

Description

Adds support for the new Hive CDN fetcher with the addition of a secondary mirror and a circuit breaker.

Details

This PR also ensures the schema fetcher is actually disposed, since the circuit breaker has to be disposed to properly shut down the gateway.

Ref GW-535

Todo

  • add mirror and circuit breaker options for schema fetcher
  • dispose fetcher on gateway disposal
  • add mirror and circuit breaker for Persisted Documents
  • use Hive Logger in all Hive related features

@gemini-code-assist
Copy link

Summary of Changes

Hello @EmrysMyrddin, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly upgrades the gateway's schema fetching capabilities by introducing support for a new Hive CDN fetcher. This enhancement includes the addition of a secondary CDN mirror for improved resilience and the integration of a circuit breaker mechanism to prevent service degradation during upstream issues. Furthermore, it ensures that all components, particularly the circuit breaker, are properly disposed of when the gateway shuts down, contributing to overall system stability.

Highlights

  • Hive CDN Mirror Support: The gateway now supports a secondary mirror for the Hive CDN, enhancing reliability and availability of schema fetching.
  • Circuit Breaker Implementation: A circuit breaker has been integrated into the Hive CDN fetcher, providing fault tolerance and preventing cascading failures.
  • Proper Schema Fetcher Disposal: The schema fetcher, including the new circuit breaker, is now correctly disposed of during gateway shutdown, ensuring clean resource release.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@EmrysMyrddin EmrysMyrddin marked this pull request as draft November 27, 2025 15:39
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for a secondary CDN mirror and a circuit breaker for Hive, enhancing the reliability of schema fetching. The changes primarily involve refactoring the schema and supergraph fetchers to use the new createCDNArtifactFetcher and to properly handle disposal of resources, which is a great improvement for graceful shutdown. I've identified a minor bug in URL manipulation and a couple of areas where the implementation could be safer and more readable. Overall, this is a solid feature addition.

? url
: joinUrl(
url.endsWith('/services')
? url.substring(0, url.length - 8)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

There seems to be a small off-by-one error here. The length of '/services' is 9, but you are subtracting 8. This will leave a trailing slash in the URL before it's passed to joinUrl. While joinUrl might handle this gracefully, it's more precise to subtract the correct length to avoid potential issues.

Suggested change
? url.substring(0, url.length - 8)
? url.substring(0, url.length - 9)

),
);
const fetcher = createCDNArtifactFetcher({
endpoint: endpoints as [string, string],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The type assertion as [string, string] is not always correct. When a single endpoint string is provided in the configuration, the endpoints array will only contain one element. This cast can hide a type mismatch and lead to potential runtime errors if createCDNArtifactFetcher expects a tuple of two strings. A more accurate type assertion would be safer.

Suggested change
endpoint: endpoints as [string, string],
endpoint: endpoints as [string, ...string[]],

);

const fetcher = createCDNArtifactFetcher({
endpoint: endpoints as [string, string],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Similar to the other usage of createCDNArtifactFetcher, the type assertion as [string, string] is not always correct here. If a single endpoint string is provided, the endpoints array will have only one element. This could lead to runtime issues. A more accurate type assertion would be safer.

Suggested change
endpoint: endpoints as [string, string],
endpoint: endpoints as [string, ...string[]],

@theguild-bot
Copy link
Collaborator

theguild-bot commented Nov 27, 2025

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
@graphql-tools/batch-delegate 10.0.6-alpha-69c4d19643f57268271203fbf82c3b8687f13723 npm ↗︎ unpkg ↗︎
@graphql-tools/delegate 12.0.0-alpha-69c4d19643f57268271203fbf82c3b8687f13723 npm ↗︎ unpkg ↗︎
@graphql-tools/federation 4.2.4-alpha-69c4d19643f57268271203fbf82c3b8687f13723 npm ↗︎ unpkg ↗︎
@graphql-mesh/fusion-runtime 1.6.0-alpha-69c4d19643f57268271203fbf82c3b8687f13723 npm ↗︎ unpkg ↗︎
@graphql-hive/gateway 2.1.20-alpha-69c4d19643f57268271203fbf82c3b8687f13723 npm ↗︎ unpkg ↗︎
@graphql-hive/nestjs 2.0.25-alpha-69c4d19643f57268271203fbf82c3b8687f13723 npm ↗︎ unpkg ↗︎
@graphql-hive/plugin-aws-sigv4 2.0.18-alpha-69c4d19643f57268271203fbf82c3b8687f13723 npm ↗︎ unpkg ↗︎
@graphql-hive/plugin-opentelemetry 1.2.2-alpha-69c4d19643f57268271203fbf82c3b8687f13723 npm ↗︎ unpkg ↗︎
@graphql-mesh/plugin-prometheus 2.1.6-alpha-69c4d19643f57268271203fbf82c3b8687f13723 npm ↗︎ unpkg ↗︎
@graphql-hive/router-runtime 1.1.0-alpha-69c4d19643f57268271203fbf82c3b8687f13723 npm ↗︎ unpkg ↗︎
@graphql-hive/gateway-runtime 2.4.0-alpha-69c4d19643f57268271203fbf82c3b8687f13723 npm ↗︎ unpkg ↗︎
@graphql-tools/stitch 10.1.4-alpha-69c4d19643f57268271203fbf82c3b8687f13723 npm ↗︎ unpkg ↗︎
@graphql-tools/stitching-directives 4.0.6-alpha-69c4d19643f57268271203fbf82c3b8687f13723 npm ↗︎ unpkg ↗︎
@graphql-hive/gateway-testing 3.0.0-alpha-69c4d19643f57268271203fbf82c3b8687f13723 npm ↗︎ unpkg ↗︎
@graphql-tools/wrap 11.1.0-alpha-69c4d19643f57268271203fbf82c3b8687f13723 npm ↗︎ unpkg ↗︎

@theguild-bot
Copy link
Collaborator

theguild-bot commented Nov 27, 2025

🚀 Snapshot Release (Binary for Linux-X64)

The latest changes of this PR are available for download (based on the declared changesets).

Download

@theguild-bot
Copy link
Collaborator

theguild-bot commented Nov 27, 2025

🚀 Snapshot Release (Binary for macOS-ARM64)

The latest changes of this PR are available for download (based on the declared changesets).

Download

@theguild-bot
Copy link
Collaborator

theguild-bot commented Nov 27, 2025

🚀 Snapshot Release (Binary for Linux-ARM64)

The latest changes of this PR are available for download (based on the declared changesets).

Download

);

const fetcher = createCDNArtifactFetcher({
endpoint: endpoints as [string, string],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe asArray can be used here instead of casting.

}
},
onDispose() {
async onDispose() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
async onDispose() {
onDispose() {

async onDispose() {
pausePolling();
return transportExecutorStack.disposeAsync();
await transportExecutorStack.disposeAsync();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
await transportExecutorStack.disposeAsync();
return handleMaybePromise(() => transportExecutorStack.disposeAsync(), () => schemaFetcher.dispose?.());

@theguild-bot
Copy link
Collaborator

theguild-bot commented Nov 27, 2025

🚀 Snapshot Release (Node Docker Image)

The latest changes of this PR are available as image on GitHub Container Registry (based on the declared changesets):

ghcr.io/graphql-hive/gateway:2.1.20-alpha-69c4d19643f57268271203fbf82c3b8687f13723

@theguild-bot
Copy link
Collaborator

theguild-bot commented Nov 27, 2025

🚀 Snapshot Release (Bun Docker Image)

The latest changes of this PR are available as image on GitHub Container Registry (based on the declared changesets):

ghcr.io/graphql-hive/gateway:2.1.20-alpha-69c4d19643f57268271203fbf82c3b8687f13723-bun

@theguild-bot
Copy link
Collaborator

theguild-bot commented Nov 27, 2025

🚀 Snapshot Release (Binary for Windows-X64)

The latest changes of this PR are available for download (based on the declared changesets).

Download

@theguild-bot
Copy link
Collaborator

theguild-bot commented Nov 27, 2025

🚀 Snapshot Release (Binary for macOS-X64)

The latest changes of this PR are available for download (based on the declared changesets).

Download

@n1ru4l
Copy link
Contributor

n1ru4l commented Nov 27, 2025

Since it is not in the todos: Just to make sure: the mirror must also be providable for persisted documents

@EmrysMyrddin EmrysMyrddin marked this pull request as ready for review November 28, 2025 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants