Skip to content

Conversation

@ardatan
Copy link
Member

@ardatan ardatan commented Dec 5, 2025

Breaking Changes to avoid future breaking changes, and better DX;

Switch to Builder pattern for SupergraphFetcher, PersistedDocumentsManager and UsageAgent structs.

Benefits;

  • No need to provide all parameters at once when creating an instance even for default values.

Example;

// Before
let fetcher = SupergraphFetcher::try_new_async(
        "SOME_ENDPOINT", // endpoint
         "SOME_KEY",
        "MyUserAgent/1.0".to_string(),
        Duration::from_secs(5), // connect_timeout
        Duration::from_secs(10), // request_timeout
        false, // accept_invalid_certs
        3, // retry_count
    )?;

// After
// No need to provide all parameters at once, can use default values
let fetcher = SupergraphFetcherBuilder::new()
    .endpoint("SOME_ENDPOINT".to_string())
    .key("SOME_KEY".to_string())
    .build_async()?;
  • Easier to add new configuration options in the future without breaking existing code, and increasing the number of parameters of new method;

Example;

let fetcher = SupergraphFetcher::try_new_async(
        "SOME_ENDPOINT", // endpoint
         "SOME_KEY",
        "MyUserAgent/1.0".to_string(),
        Duration::from_secs(5), // connect_timeout
        Duration::from_secs(10), // request_timeout
        false, // accept_invalid_certs
        3, // retry_count
        circuit_breaker_config, // Breaking Change -> new parameter added
    )?;

let fetcher = SupergraphFetcherBuilder::new()
    .endpoint("SOME_ENDPOINT".to_string())
    .key("SOME_KEY".to_string())
    .build_async()?; // No breaking change, circuit_breaker_config can be added later if needed

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @ardatan, 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 introduces the Builder pattern for key components within the sdk-rs crate, specifically for SupergraphFetcher, PersistedDocumentsManager, and UsageAgent. This strategic refactoring aims to enhance the maintainability and extensibility of the SDK by providing a more flexible and future-proof way to construct these objects. It simplifies their initialization by allowing optional parameters and default values, and ensures that future additions of configuration options will not introduce breaking changes to existing client code.

Highlights

  • Builder Pattern Adoption: The SupergraphFetcher, PersistedDocumentsManager, and UsageAgent structs have been refactored to utilize the Builder pattern for their instantiation. This change is considered a minor breaking change, but it is implemented to prevent more significant breaking changes in the future.
  • Improved API Flexibility: The new Builder pattern allows for more flexible object creation, as not all parameters need to be provided at once. Default values can be used for optional configurations, simplifying the API for common use cases.
  • Easier Configuration Extension: Adding new configuration options in the future will no longer require breaking existing code, as the Builder pattern allows for new methods to be added without altering the constructor signature.
  • Dependency Updates: The Cargo.lock file has been updated to increment versions for hive-apollo-router-plugin and hive-console-sdk, and a new dependency regex-automata has been added to sdk-rs.
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.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2025

🚀 Snapshot Release (alpha)

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

Package Version Info
hive 8.13.0-alpha-20251205155813-22182f8b3e54ab5846702ec5e35e229ce790abd2 npm ↗︎ unpkg ↗︎
hive-apollo-router-plugin 2.3.5-alpha-20251205155813-22182f8b3e54ab5846702ec5e35e229ce790abd2 npm ↗︎ unpkg ↗︎
hive-console-sdk-rs 0.3.0-alpha-20251205155813-22182f8b3e54ab5846702ec5e35e229ce790abd2 npm ↗︎ unpkg ↗︎

@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2025

📚 Storybook Deployment

The latest changes are available as preview in: https://pr-7379.hive-storybook.pages.dev

Copy link
Contributor

@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 the builder pattern for SupergraphFetcher, PersistedDocumentsManager, and UsageAgent, which is a great enhancement for API ergonomics and future-proofing. The implementation is solid, but I have identified a few areas for improvement. My main concerns are a potential panic in one of the builders, a performance issue in regex compilation for validation, and a common design issue in the new builders related to retry policy configuration that could be confusing for users. I've provided specific comments with suggestions to address these points. Overall, this is a valuable change.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2025

💻 Website Preview

The latest changes are available as preview in: https://pr-7379.hive-landing-page.pages.dev

@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2025

🐋 This PR was built and pushed to the following Docker images:

Targets: build

Platforms: linux/amd64

Image Tag: 22182f8b3e54ab5846702ec5e35e229ce790abd2

@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2025

🐋 This PR was built and pushed to the following Docker images:

Targets: apollo-router-hive-build

Platforms: linux/amd64

Image Tag: 9c393977b1c5dc995cde9267fded96b08e903c48

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant