Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): override CLI defaults from configuration #574

Merged
merged 7 commits into from
Jan 31, 2025
Merged

Conversation

ardatan
Copy link
Member

@ardatan ardatan commented Jan 31, 2025

Fixes #573

Ref GW-136

@dotansimha
Copy link
Member

add a changeset? @ardatan

@dotansimha
Copy link
Member

@coderabbitai full review

Copy link

coderabbitai bot commented Jan 31, 2025

📝 Walkthrough

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Resolved an issue where configuration parameters (port, host, and pollingInterval) were being incorrectly overridden by default CLI values
    • Improved configuration handling to respect user-defined settings
  • Improvements

    • Enhanced CLI option help text to include default values for better user clarity
    • Updated error messages to provide more specific feedback about configuration settings

Walkthrough

The pull request introduces modifications to the Hive Gateway's configuration and command-line interface (CLI) handling, particularly concerning the pollingInterval and port configuration. Key changes include the removal of the pollingInterval property from the gatewayConfig, enhancements to CLI help text to clarify default values, and the introduction of fallback mechanisms for determining the pollingInterval in various command files. These adjustments aim to improve configurability and user feedback without altering the fundamental functionality of the gateway.

Changes

File Change Summary
e2e/polling/gateway.config.ts Removed pollingInterval: 5_000 from gatewayConfig
packages/gateway/src/cli.ts Updated help text with default values for CLI options like --fork, --host, --port, and --polling
packages/gateway/src/commands/proxy.ts Modified pollingInterval assignment logic with fallback mechanism
packages/gateway/src/commands/subgraph.ts Updated pollingInterval configuration with more complex value determination
packages/gateway/src/commands/supergraph.ts Refined pollingInterval configuration with fallback and improved error messaging
.changeset/dull-mayflies-allow.md Introduced patch to address regression affecting port, host, and pollingInterval configuration

Assessment against linked issues

Objective Addressed Explanation
Respect port configuration [#573, GW-136] No changes directly address the port configuration issue.
Improve polling interval configuration Added fallback mechanism for pollingInterval across multiple command files.

The changes do not appear to resolve the reported issue with port configuration, where the gateway is not respecting the specified port in the configuration. While the polling interval configuration has been improved, the core problem of port selection remains unaddressed in these changes.

Possibly related PRs

  • Configure Renovate #5: This PR modifies the logic for setting the pollingInterval property, which is directly related to the removal of the pollingInterval property in the main PR.
  • Update graphql-mesh #6: Similar to the proxy changes, this PR also updates the handling of the pollingInterval, indicating a connection to the main PR's removal of this property.
  • Update graphql-tools #7: This PR also addresses the pollingInterval property, refining its assignment logic, which relates to the changes made in the main PR.
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
.changeset/dull-mayflies-allow.md (1)

5-5: Improve the description's grammar and clarity.

The description has a minor grammatical issue and could be more specific.

Apply this diff to improve the description:

-Fix the regression causing `port`, `host` and `pollingInterval` in the configuration is overriden by the default values of CLI parameters
+Fix a regression where `port`, `host`, and `pollingInterval` configuration values were being overridden by CLI default parameters
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 131cd27 and 1788b6d.

📒 Files selected for processing (1)
  • .changeset/dull-mayflies-allow.md (1 hunks)
🔇 Additional comments (1)
.changeset/dull-mayflies-allow.md (1)

1-3: LGTM! Appropriate version bump.

The patch version bump is correct as this fixes a regression without introducing breaking changes.

@theguild-bot
Copy link
Collaborator

🚀 Snapshot Release (alpha)

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

Package Version Info
@graphql-hive/gateway 1.9.1-alpha-1788b6d693689dafcf968053afe59a04d765d263 npm ↗︎ unpkg ↗︎

@dotansimha
Copy link
Member

@coderabbitai full review

@theguild-bot
Copy link
Collaborator

🚀 Snapshot Release (Binary for Linux-ARM64)

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

Download

@theguild-bot
Copy link
Collaborator

🚀 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

🚀 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

🚀 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:1.9.1-alpha-1788b6d693689dafcf968053afe59a04d765d263-bun

@theguild-bot
Copy link
Collaborator

🚀 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:1.9.1-alpha-1788b6d693689dafcf968053afe59a04d765d263

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/gateway/src/commands/supergraph.ts (1)

209-214: LGTM! Consider adding type guard for better type safety.

The fallback chain for pollingInterval correctly implements the CLI defaults override from configuration. The implementation follows a clear precedence: CLI options > config file > default values.

Consider adding a type guard to make the configuration type checking more explicit:

        pollingInterval:
          opts.polling ||
-         ('pollingInterval' in loadedConfig
+         (loadedConfig && 'pollingInterval' in loadedConfig
            ? loadedConfig.pollingInterval
            : undefined) ||
          defaultOptions.pollingInterval,
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 73abe12 and 1788b6d.

📒 Files selected for processing (6)
  • .changeset/dull-mayflies-allow.md (1 hunks)
  • e2e/polling/gateway.config.ts (0 hunks)
  • packages/gateway/src/cli.ts (3 hunks)
  • packages/gateway/src/commands/proxy.ts (2 hunks)
  • packages/gateway/src/commands/subgraph.ts (2 hunks)
  • packages/gateway/src/commands/supergraph.ts (2 hunks)
💤 Files with no reviewable changes (1)
  • e2e/polling/gateway.config.ts
🧰 Additional context used
📓 Path-based instructions (4)
packages/gateway/src/commands/proxy.ts (3)

Pattern packages/**: In this directory we keep all packages relevant to the gateway.

In most cases, when changes are made to the source code / dependencies in these directories, we also require to have a corresponding changeset file, created using yarn changeset with a full description on the changes with an example.
Also, when new features are added the packages, the changeset file should mention minor semver change. When a bug is fixed, patch needs to be used. The major bump is used for a PR that has breaking changes.


Pattern packages/gateway/**: The main runtime for the Hive gateway.
This package is CLI that runs the gateway and configures the internals of the gateway function.


Pattern **: For all PRs, we would like to verify that a Linear issue is linked. Check if there's a mention for "GW-*" in the PR description, and the us know when it's missing.

In most cases, when a PR adds a new functionality, we would like to make sure it has documentation in the corresponding console project.
Use the global knowledge feature to search for PRs in graphql-hive/console repository that adds documentation. Suggest to create a follow up issue to add the missing documentation.

packages/gateway/src/commands/supergraph.ts (3)

Pattern packages/**: In this directory we keep all packages relevant to the gateway.

In most cases, when changes are made to the source code / dependencies in these directories, we also require to have a corresponding changeset file, created using yarn changeset with a full description on the changes with an example.
Also, when new features are added the packages, the changeset file should mention minor semver change. When a bug is fixed, patch needs to be used. The major bump is used for a PR that has breaking changes.


Pattern packages/gateway/**: The main runtime for the Hive gateway.
This package is CLI that runs the gateway and configures the internals of the gateway function.


Pattern **: For all PRs, we would like to verify that a Linear issue is linked. Check if there's a mention for "GW-*" in the PR description, and the us know when it's missing.

In most cases, when a PR adds a new functionality, we would like to make sure it has documentation in the corresponding console project.
Use the global knowledge feature to search for PRs in graphql-hive/console repository that adds documentation. Suggest to create a follow up issue to add the missing documentation.

packages/gateway/src/cli.ts (3)

Pattern packages/**: In this directory we keep all packages relevant to the gateway.

In most cases, when changes are made to the source code / dependencies in these directories, we also require to have a corresponding changeset file, created using yarn changeset with a full description on the changes with an example.
Also, when new features are added the packages, the changeset file should mention minor semver change. When a bug is fixed, patch needs to be used. The major bump is used for a PR that has breaking changes.


Pattern packages/gateway/**: The main runtime for the Hive gateway.
This package is CLI that runs the gateway and configures the internals of the gateway function.


Pattern **: For all PRs, we would like to verify that a Linear issue is linked. Check if there's a mention for "GW-*" in the PR description, and the us know when it's missing.

In most cases, when a PR adds a new functionality, we would like to make sure it has documentation in the corresponding console project.
Use the global knowledge feature to search for PRs in graphql-hive/console repository that adds documentation. Suggest to create a follow up issue to add the missing documentation.

packages/gateway/src/commands/subgraph.ts (3)

Pattern packages/**: In this directory we keep all packages relevant to the gateway.

In most cases, when changes are made to the source code / dependencies in these directories, we also require to have a corresponding changeset file, created using yarn changeset with a full description on the changes with an example.
Also, when new features are added the packages, the changeset file should mention minor semver change. When a bug is fixed, patch needs to be used. The major bump is used for a PR that has breaking changes.


Pattern packages/gateway/**: The main runtime for the Hive gateway.
This package is CLI that runs the gateway and configures the internals of the gateway function.


Pattern **: For all PRs, we would like to verify that a Linear issue is linked. Check if there's a mention for "GW-*" in the PR description, and the us know when it's missing.

In most cases, when a PR adds a new functionality, we would like to make sure it has documentation in the corresponding console project.
Use the global knowledge feature to search for PRs in graphql-hive/console repository that adds documentation. Suggest to create a follow up issue to add the missing documentation.

⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: Binary built on windows-latest
  • GitHub Check: Binary built on macos-13
  • GitHub Check: Bun Docker image
  • GitHub Check: Node Docker image
  • GitHub Check: E2E / Bun Docker on Ubuntu
  • GitHub Check: E2E / Node Binary on Windows
  • GitHub Check: E2E / Node Docker on Ubuntu
🔇 Additional comments (10)
packages/gateway/src/commands/subgraph.ts (2)

85-90: LGTM! Proper fallback mechanism for pollingInterval.

The implementation correctly prioritizes values from different sources:

  1. CLI option (opts.polling)
  2. Configuration file (loadedConfig.pollingInterval)
  3. Default value (defaultOptions.pollingInterval)

143-143: LGTM! Improved error message.

The error message now includes the actual polling interval value, making it easier to debug configuration issues.

packages/gateway/src/commands/proxy.ts (2)

124-129: LGTM! Consistent implementation of pollingInterval fallback.

The implementation matches the pattern used in subgraph.ts, ensuring consistent behavior across commands.


183-183: LGTM! Consistent error message improvement.

The error message update matches the improvement made in subgraph.ts.

packages/gateway/src/cli.ts (3)

228-228: LGTM! Improved help text for --fork option.

The help text now clearly indicates the default value and its behavior in different environments.


251-253: LGTM! Improved help text for host and port options.

The help text now includes the default values, making the configuration behavior more transparent.

Also applies to: 257-260


273-273: LGTM! Improved help text for polling option.

The help text now uses a human-readable duration format for better clarity.

.changeset/dull-mayflies-allow.md (1)

1-5: LGTM! Clear and accurate changeset.

The changeset correctly:

  1. Uses a patch version bump for a bug fix
  2. Clearly describes the regression being fixed
packages/gateway/src/commands/supergraph.ts (2)

259-259: LGTM! Improved error message clarity.

The error message now includes the actual polling interval value, making it easier for users to understand why their configuration was rejected.


209-214: Add a changeset file for the package changes.

Since this PR fixes a bug in the gateway package, a changeset file needs to be created using yarn changeset with a patch semver change. Please include a description of the changes with an example.

Run the following script to check if a changeset file exists:

✅ Verification successful

Changeset requirement is already satisfied

A changeset file exists with the appropriate patch version bump and clear description of the bug fix for the gateway package.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for changeset files in the PR

# Look for .md files in .changeset directory
fd -e md . .changeset/

Length of output: 58


Script:

#!/bin/bash
# Check contents of the changeset file
cat .changeset/dull-mayflies-allow.md

Length of output: 217

@theguild-bot
Copy link
Collaborator

🚀 Snapshot Release (Binary for macOS-X64)

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

Download

@ardatan ardatan merged commit 8c466f4 into main Jan 31, 2025
60 checks passed
@ardatan ardatan deleted the no-default branch January 31, 2025 11:45
@theguild-bot
Copy link
Collaborator

🚀 Snapshot Release (Binary for Windows-X64)

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

Download

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.

Hive Gateway no longer respects my port config
3 participants