Skip to content

Conversation

enisdenjo
Copy link
Member

@enisdenjo enisdenjo commented Mar 11, 2025

Ref GW-240

Docs: graphql-hive/console#6612.

Waiting for graphql-hive/console#6591.

  • Moved the Hive plugin from Mesh to the Gateway, improved control and faster iterations
  • Introduce new --hive-usage-target and --hive-usage-access-token CLI and configuration options
  • Deprecate --hive-registry-token and advise user to migrate

@enisdenjo enisdenjo requested review from ardatan and n1ru4l March 11, 2025 13:00
Copy link
Contributor

coderabbitai bot commented Mar 11, 2025

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Introduced a new reporting option to specify a custom target for usage data.
    • Updated CLI commands with dedicated options for usage target and access token, deprecating the previous token setting.
  • Chores

    • Updated dependency management by replacing an outdated integration with a more current alternative.
  • Refactor

    • Streamlined reporting configuration across commands for improved error handling and consistency.

Walkthrough

This pull request updates dependency management, refines reporting configuration handling, and introduces new functionality for Hive integrations. Key changes include updating dependencies in the runtime package, modifying how reporting configurations are processed across several modules, adding a new Hive console plugin, and enhancing CLI options for reporting. Additionally, documentation changes via changeset files reflect these updates.

Changes

File(s) Change Summary
packages/runtime/package.json, .changeset/@graphql-hive_gateway-runtime-809-dependencies.md Updated dependencies by adding @graphql-hive/yoga@^0.41.0 and removing @graphql-mesh/plugin-hive@^0.104.0.
packages/runtime/src/createGatewayRuntime.ts, packages/runtime/src/getReportingPlugin.ts Modified reporting plugin invocation by replacing useMeshHive with useHiveConsole, updating the usage property handling, and introducing a new configuration property.
packages/runtime/src/plugins/useHiveConsole.ts Added a new file that exports the useHiveConsole function and associated type, enabling a Hive console plugin integration.
packages/runtime/src/types.ts Introduced an optional target?: string property to the GatewayHiveReportingOptions interface for flexible reporting.
packages/gateway/src/cli.ts Updated the CLI interface by modifying GatewayCLIHiveReportingOptions to omit certain properties, adding an optional target property, deprecating --hive-registry-token, and introducing --hive-usage-target and --hive-usage-access-token options.
packages/gateway/src/commands/handleReportingConfig.ts Enhanced reporting configuration by incorporating a spread operator to merge additional properties from loadedConfig.reporting for both hive and graphos types.
packages/gateway/src/commands/proxy.ts, packages/gateway/src/commands/supergraph.ts, packages/gateway/src/commands/subgraph.ts Integrated the handleReportingConfig function for centralized reporting configuration, introducing new variables (hiveUsageTarget and hiveUsageAccessToken) to replace previous inline logic.
.changeset/plenty-llamas-push.md, .changeset/wet-kiwis-peel.md Documented the addition of the new reporting option target and noted the CLI deprecation of --hive-registry-token in favor of the new --hive-usage-target and --hive-usage-access-token options.

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6451d25 and 3aa59ad.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (13)
  • .changeset/@graphql-hive_gateway-runtime-809-dependencies.md (1 hunks)
  • .changeset/plenty-llamas-push.md (1 hunks)
  • .changeset/wet-kiwis-peel.md (1 hunks)
  • packages/gateway/src/cli.ts (2 hunks)
  • packages/gateway/src/commands/handleReportingConfig.ts (1 hunks)
  • packages/gateway/src/commands/proxy.ts (4 hunks)
  • packages/gateway/src/commands/subgraph.ts (4 hunks)
  • packages/gateway/src/commands/supergraph.ts (3 hunks)
  • packages/runtime/package.json (1 hunks)
  • packages/runtime/src/createGatewayRuntime.ts (2 hunks)
  • packages/runtime/src/getReportingPlugin.ts (2 hunks)
  • packages/runtime/src/plugins/useHiveConsole.ts (1 hunks)
  • packages/runtime/src/types.ts (2 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
  • @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.

@theguild-bot
Copy link
Collaborator

theguild-bot commented Mar 11, 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-hive/gateway 1.12.0-alpha-3aa59addc2562eb1e5c602a132ab458aec001ec0 npm ↗︎ unpkg ↗︎
@graphql-hive/nestjs 1.0.1-alpha-3aa59addc2562eb1e5c602a132ab458aec001ec0 npm ↗︎ unpkg ↗︎
@graphql-mesh/plugin-opentelemetry 1.3.46-alpha-3aa59addc2562eb1e5c602a132ab458aec001ec0 npm ↗︎ unpkg ↗︎
@graphql-mesh/plugin-prometheus 1.3.34-alpha-3aa59addc2562eb1e5c602a132ab458aec001ec0 npm ↗︎ unpkg ↗︎
@graphql-hive/gateway-runtime 1.6.0-alpha-3aa59addc2562eb1e5c602a132ab458aec001ec0 npm ↗︎ unpkg ↗︎

@theguild-bot
Copy link
Collaborator

theguild-bot commented Mar 11, 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 Mar 11, 2025

🚀 Snapshot Release (Binary for macOS-ARM64)

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

Download

@enisdenjo enisdenjo marked this pull request as draft March 11, 2025 13:07
@theguild-bot
Copy link
Collaborator

theguild-bot commented Mar 11, 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:1.12.0-alpha-3aa59addc2562eb1e5c602a132ab458aec001ec0

@theguild-bot
Copy link
Collaborator

theguild-bot commented Mar 11, 2025

🚀 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

theguild-bot commented Mar 11, 2025

🚀 Snapshot Release (Binary for macOS-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 Mar 11, 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:1.12.0-alpha-3aa59addc2562eb1e5c602a132ab458aec001ec0-bun

Copy link
Contributor

@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: 1

🔭 Outside diff range comments (1)
packages/gateway/src/commands/handleReportingConfig.ts (1)

79-100: ⚠️ Potential issue

Remove duplicate code at the end of the file.

There appears to be some duplicate code at the end of the file (lines 79-100) that seems to be a partial repetition of the Apollo GraphOS configuration logic. This code is likely a remnant from development or a mistake in the file and should be removed.

-      target: opts.hiveUsageTarget,
-    };
-  }
-
-  if (opts.apolloKey) {
-    ctx.log.info(`Configuring Apollo GraphOS registry reporting`);
-    if (!opts.apolloGraphRef) {
-      ctx.log.error(
-        `Apollo GraphOS requires a graph ref in the format <graph-id>@<graph-variant>. Please provide a valid graph ref.`,
-      );
-      process.exit(1);
-    }
-    return {
-      ...loadedConfig.reporting,
-      type: 'graphos',
-      apiKey: opts.apolloKey,
-      graphRef: opts.apolloGraphRef,
-    };
-  }
-
-  return null;
-}
🧹 Nitpick comments (1)
packages/runtime/src/plugins/useHiveConsole.ts (1)

1-25: New plugin for Hive Console integration

This new plugin implementation creates a bridge between the Gateway and Hive's reporting system. The code properly initializes the agent with sensible defaults, including the Gateway name and logger.

There's a noted TypeScript issue that should be addressed in a future update to ensure proper context type inheritance.

Consider adding a brief comment explaining the purpose of this plugin at the top of the file for better documentation.

+/**
+ * Plugin that enables Hive Console integration for the Gateway,
+ * providing usage reporting and other Hive features.
+ */
export default function useHiveConsole<
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b145a27 and 7e86e4e.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (21)
  • packages/runtime/package.json (1 hunks)
  • packages/runtime/src/createGatewayRuntime.ts (2 hunks)
  • packages/runtime/src/getReportingPlugin.ts (2 hunks)
  • packages/runtime/src/plugins/useHiveConsole.ts (1 hunks)
  • packages/runtime/src/types.ts (2 hunks)
  • packages/runtime/src/getReportingPlugin.ts (2 hunks)
  • packages/runtime/src/types.ts (1 hunks)
  • packages/gateway/src/cli.ts (2 hunks)
  • packages/gateway/src/commands/handleReportingConfig.ts (1 hunks)
  • packages/gateway/src/commands/proxy.ts (4 hunks)
  • packages/gateway/src/commands/subgraph.ts (4 hunks)
  • packages/gateway/src/commands/supergraph.ts (3 hunks)
  • packages/gateway/src/commands/subgraph.ts (1 hunks)
  • packages/gateway/src/commands/handleReportingConfig.ts (1 hunks)
  • packages/gateway/src/commands/handleReportingConfig.ts (2 hunks)
  • packages/runtime/src/createGatewayRuntime.ts (1 hunks)
  • packages/runtime/src/getReportingPlugin.ts (1 hunks)
  • packages/runtime/src/getReportingPlugin.ts (1 hunks)
  • .changeset/@graphql-hive_gateway-runtime-809-dependencies.md (1 hunks)
  • .changeset/plenty-llamas-push.md (1 hunks)
  • .changeset/wet-kiwis-peel.md (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
`packages/**`: In this directory we keep all packages releva...

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.

  • packages/gateway/src/commands/subgraph.ts
  • packages/runtime/src/getReportingPlugin.ts
  • packages/gateway/src/commands/handleReportingConfig.ts
  • packages/gateway/src/commands/supergraph.ts
  • packages/runtime/src/createGatewayRuntime.ts
  • packages/runtime/package.json
  • packages/runtime/src/types.ts
  • packages/gateway/src/commands/proxy.ts
  • packages/gateway/src/cli.ts
  • packages/runtime/src/plugins/useHiveConsole.ts
`packages/gateway/**`: The main runtime for the Hive gateway...

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.

  • packages/gateway/src/commands/subgraph.ts
  • packages/gateway/src/commands/handleReportingConfig.ts
  • packages/gateway/src/commands/supergraph.ts
  • packages/gateway/src/commands/proxy.ts
  • packages/gateway/src/cli.ts
`**`: For all PRs, we would like to verify that a Linear iss...

**: 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
  • packages/runtime/src/getReportingPlugin.ts
  • packages/gateway/src/commands/handleReportingConfig.ts
  • packages/gateway/src/commands/supergraph.ts
  • packages/runtime/src/createGatewayRuntime.ts
  • packages/runtime/package.json
  • packages/runtime/src/types.ts
  • packages/gateway/src/commands/proxy.ts
  • packages/gateway/src/cli.ts
  • packages/runtime/src/plugins/useHiveConsole.ts
⏰ Context from checks skipped due to timeout of 90000ms (43)
  • GitHub Check: Examples / Convert operation-field-permissions
  • GitHub Check: Examples / Convert type-merging-batching
  • GitHub Check: Examples / Convert subscriptions-with-transforms
  • GitHub Check: Examples / Convert programmatic-batching
  • GitHub Check: Examples / Convert openapi-subscriptions
  • GitHub Check: Examples / Convert openapi-javascript-wiki
  • GitHub Check: Examples / Convert openapi-arg-rename
  • GitHub Check: Examples / Convert openapi-additional-resolvers
  • GitHub Check: Examples / Convert json-schema-subscriptions
  • GitHub Check: Examples / Convert interface-additional-resolvers
  • GitHub Check: Examples / Convert hmac-auth-https
  • GitHub Check: Examples / Convert federation-subscriptions-passthrough
  • GitHub Check: Examples / Convert apq-subgraphs
  • GitHub Check: Examples / Convert file-upload
  • GitHub Check: Examples / Convert federation-mixed
  • GitHub Check: Examples / Convert federation-example
  • GitHub Check: Examples / Convert extra-fields
  • GitHub Check: Binary built on ubuntu-24.04-arm
  • GitHub Check: Binary built on windows-latest
  • GitHub Check: Binary built on macos-14
  • GitHub Check: Binary built on macos-13
  • GitHub Check: Bun Docker image
  • GitHub Check: Binary built on ubuntu-latest
  • GitHub Check: Node Docker image
  • GitHub Check: E2E / Bun Docker on Ubuntu
  • GitHub Check: E2E / Bun on Ubuntu
  • GitHub Check: E2E / Node Binary on Windows
  • GitHub Check: E2E / Node Binary on Ubuntu
  • GitHub Check: E2E / Node Docker on Ubuntu
  • GitHub Check: E2E / Node 23 on Ubuntu
  • GitHub Check: E2E / Node 22 on Ubuntu
  • GitHub Check: Benchmark / bun / 1000 items
  • GitHub Check: Benchmark / bun / 100 items
  • GitHub Check: Leaks / Node v23
  • GitHub Check: Benchmark / bun / 10 items
  • GitHub Check: Benchmark / node / 1000 items
  • GitHub Check: E2E / Node 20 on Ubuntu
  • GitHub Check: Benchmark / node / 100 items
  • GitHub Check: Benchmark / node / 10 items
  • GitHub Check: Leaks / Node v22
  • GitHub Check: E2E / Node 18 on Ubuntu
  • GitHub Check: Leaks / Node v20
  • GitHub Check: Leaks / Node v18
🔇 Additional comments (23)
.changeset/wet-kiwis-peel.md (1)

1-6: LGTM: The changeset correctly declares a patch version bump for the new feature

The changeset properly documents the introduction of the new target reporting option for the @graphql-hive/gateway-runtime package with a patch version bump, which is appropriate for a non-breaking addition.

.changeset/plenty-llamas-push.md (1)

1-7: LGTM: Properly documented changeset with clear deprecation notice

The changeset correctly documents both the new target reporting option and the CLI options deprecation for the @graphql-hive/gateway package with appropriate patch versioning.

.changeset/@graphql-hive_gateway-runtime-809-dependencies.md (1)

1-9: LGTM: Dependencies changeset properly documented

The changeset correctly documents the dependency changes (adding @graphql-hive/yoga and removing @graphql-mesh/plugin-hive) with a patch version bump, which is appropriate for dependency updates.

packages/runtime/package.json (1)

52-52: LGTM: Dependency update matches changeset declaration

The addition of @graphql-hive/yoga@^0.41.0 aligns with the changeset file that documents this dependency change.

packages/runtime/src/types.ts (1)

274-275: LGTM: New optional property with clear documentation

The target property is properly added to the GatewayHiveReportingOptions interface with good documentation and marked as optional, which preserves backward compatibility.

packages/runtime/src/createGatewayRuntime.ts (1)

194-197: Improved configuration handling for reporting plugin

The change properly passes the configuration context to the reporting plugin, ensuring it has access to logger, cache, and other contextual information. The removal of the empty object fallback (|| {}) suggests that getReportingPlugin now consistently returns a structured object.

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

31-31: New import for centralized reporting configuration handling

This import brings in the handleReportingConfig utility function that centralizes the reporting configuration logic.


54-56: Added new CLI options for Hive usage reporting

Two new options hiveUsageTarget and hiveUsageAccessToken have been added to support the new Hive usage reporting mechanism.


157-167:

✅ Verification successful

Refactored reporting configuration to use centralized utility function

The code now uses the handleReportingConfig utility function to process various reporting-related options, including both the legacy hiveRegistryToken and the new hiveUsageTarget/hiveUsageAccessToken options. This centralization makes the code more maintainable and consistent across different commands.


🏁 Script executed:

#!/bin/bash
# Check for a changeset file that documents this change
fd ".*\.md" .changeset -x cat {}

Length of output: 22595


Refactored Reporting Configuration Verified and Approved

The refactoring in packages/gateway/src/commands/supergraph.ts (lines 157–167) correctly uses the centralized handleReportingConfig function to process both the legacy hiveRegistryToken option and the new hiveUsageTarget/hiveUsageAccessToken options. This update is also clearly documented in the changeset (e.g., "Introduce target as a new Hive reporting option" and the deprecation of --hive-registry-token in favor of the new options), ensuring that the intended changes are both implemented and tracked.

  • Location: packages/gateway/src/commands/supergraph.ts, lines 157–167
  • Impact: Centralizes and streamlines reporting configuration for improved maintainability and consistency.
packages/runtime/src/getReportingPlugin.ts (1)

21-28: Improved handling of Hive usage configuration

The updated logic properly handles the case where usage reporting is explicitly disabled (usage === false). For other cases, it now correctly extends the usage configuration with the target property, ensuring type safety by only spreading properties if usage is an object.

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

25-25: Good addition of handleReportingConfig import.

This import supports the centralized approach to reporting configuration handling that's being implemented across the codebase.


41-42: New CLI options for Hive usage properly integrated.

The addition of hiveUsageTarget and hiveUsageAccessToken options aligns with the updated CLI interface defined in cli.ts, providing more flexible configuration for Hive reporting.


61-72: Well-structured reporting configuration handling.

The implementation centralizes the reporting configuration by using the handleReportingConfig function, which improves code organization and maintainability. The approach correctly preserves any additional reporting configuration from the loaded config.


107-107: Good use of spread operator for registryConfig.

Using the spread operator to incorporate the registryConfig into the final config object is clean and maintains consistency with the other configuration sections.

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

21-21: Good addition of handleReportingConfig import.

This import supports the centralized approach to reporting configuration handling that's being implemented across the codebase.


39-40: New CLI options for Hive usage properly integrated.

The addition of hiveUsageTarget and hiveUsageAccessToken options aligns with the updated CLI interface defined in cli.ts, providing more flexible configuration for Hive reporting.


101-112: Well-structured reporting configuration handling.

The implementation centralizes the reporting configuration by using the handleReportingConfig function, which improves code organization and maintainability. The approach correctly preserves any additional reporting configuration from the loaded config.


147-147: Good use of spread operator for registryConfig.

Using the spread operator to incorporate the registryConfig into the final config object is clean and maintains consistency with the other configuration sections.

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

75-82: Updated interface to support new Hive reporting options.

The interface correctly omits target and token properties from the base interface and redefines them with updated documentation. The documentation clearly specifies the default values from environment variables.


318-319: Good deprecation notice for hive-registry-token.

The deprecation message clearly instructs users on the new options to use instead of the deprecated one.


321-332: Well-defined new CLI options for Hive usage reporting.

The new options are properly defined with clear descriptions and environment variable fallbacks. The descriptions correctly indicate that both options are required when using either one.

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

1-78: Good implementation of centralized reporting configuration handling.

The handleReportingConfig function is well-structured and handles different reporting configuration scenarios appropriately:

  1. It prevents mixing old and new configuration methods with clear error messages
  2. Provides a deprecation warning when using the old hiveRegistryToken option
  3. Ensures both hiveUsageTarget and hiveUsageAccessToken are provided when using the new approach
  4. Properly configures Apollo GraphOS reporting when those options are provided

This centralization makes the code more maintainable and keeps the logic consistent across different commands.


1-78:

❓ Verification inconclusive

Verify that a changeset file has been created.

According to the project's coding guidelines, when new features are added to packages, a changeset file should be created using yarn changeset with a full description and a minor semver change. Since this PR introduces new CLI options and deprecates an existing one, please ensure a changeset file has been included.


🏁 Script executed:

#!/bin/bash
# Description: Check if a changeset file exists for this PR

# Look for changeset files
echo "Looking for changeset files..."
find .changeset -name "*.md" | grep -v README.md

Length of output: 4187


Changeset Verification:
The repository already contains changeset files; however, please double-check that the changeset file addressing this PR’s new CLI options and deprecation (i.e. not one of the dependency updates) includes a full description and marks a minor semver change as per our guidelines.

@theguild-bot
Copy link
Collaborator

theguild-bot commented Mar 11, 2025

🚀 Snapshot Release (Binary for Windows-X64)

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

Download

@enisdenjo enisdenjo self-assigned this Mar 12, 2025
@enisdenjo enisdenjo marked this pull request as ready for review March 12, 2025 14:51
@enisdenjo enisdenjo removed their assignment Mar 12, 2025
Copy link
Contributor

@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

🔭 Outside diff range comments (1)
packages/runtime/src/getReportingPlugin.ts (1)

1-91: 💡 Verification agent

🧩 Analysis chain

Verify changeset file creation

A changeset file should be created for these changes using yarn changeset with a full description of the new functionality and examples. Since this PR introduces new features (new target option), the changeset should specify a "minor" semver change.


🏁 Script executed:

#!/bin/bash
# Check if a changeset file was created for this PR

echo "Checking for changeset files..."
fd -e md -p '.changeset/'

Length of output: 98


Action Required: Create a Changeset File

It appears that no changeset file was found in the .changeset/ directory. Since this PR introduces a new target option feature, please run yarn changeset to generate a changeset file. Make sure the file includes:

  • A full description of the new functionality (e.g., the new target option).
  • Usage examples as needed.
  • A minor semver bump designation.

Please add this changeset file before merging.

🧹 Nitpick comments (7)
packages/runtime/src/getReportingPlugin.ts (1)

1-91: Documentation for new CLI options

Since this PR introduces new CLI options (--hive-usage-target and --hive-usage-access-token), documentation should be added to the corresponding console project.

Would you like me to create a follow-up issue to ensure documentation is added for these new CLI options?

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

157-166: Add tests for the new reporting flow.

The centralized call to handleReportingConfig is clear and maintainable. However, consider adding or extending tests to validate usage reporting or registry reporting logic (especially with the new CLI options).

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

61-72: Subgraph restricted to Hive reporting.

Explicitly disabling GraphOS by setting apolloGraphRef and apolloKey to undefined makes sense if that’s the expected behavior. The new registryConfig approach is consistent with the supergraph. Please ensure there are tests or validation for subgraph usage reporting using Hive.

Also applies to: 107-107

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

38-64: Conflict checks are well-defined.

Exiting early for conflicting or incomplete options is good. However, consider adding tests specifically verifying these error paths.


66-81: Hive usage logic is correct and consistent.

Reusing hiveRegistryToken as a fallback for hiveUsageAccessToken streamlines backward compatibility. Confirm that references to the deprecated --hive-registry-token are documented or guided for migration to the new usage tokens.

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

39-40: New CLI options added for Hive usage reporting.

These new options align with the PR objective to introduce --hive-usage-target and --hive-usage-access-token. However, there's no explicit deprecation notice for hiveRegistryToken which is mentioned as deprecated in the PR objectives.

Consider adding a comment above hiveRegistryToken in the destructuring assignment to indicate its deprecated status, such as:

        hiveCdnEndpoint,
        hiveCdnKey,
+       // @deprecated - Use hiveUsageTarget and hiveUsageAccessToken instead
        hiveRegistryToken,
        hiveUsageTarget,
        hiveUsageAccessToken,

101-112: Refactored reporting configuration with improved type safety.

The refactoring centralizes the reporting configuration logic and improves type safety with Pick<ProxyConfig, 'reporting'>. The implementation correctly handles the new options while maintaining backward compatibility with hiveRegistryToken.

Consider adding a brief comment explaining the purpose of this configuration block:

+      // Configure Hive reporting options for usage tracking
      const registryConfig: Pick<ProxyConfig, 'reporting'> = {};
      const reporting = handleReportingConfig(ctx, loadedConfig, {
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 04952b7 and 6451d25.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (13)
  • .changeset/@graphql-hive_gateway-runtime-809-dependencies.md (1 hunks)
  • .changeset/plenty-llamas-push.md (1 hunks)
  • .changeset/wet-kiwis-peel.md (1 hunks)
  • packages/gateway/src/cli.ts (2 hunks)
  • packages/gateway/src/commands/handleReportingConfig.ts (1 hunks)
  • packages/gateway/src/commands/proxy.ts (4 hunks)
  • packages/gateway/src/commands/subgraph.ts (4 hunks)
  • packages/gateway/src/commands/supergraph.ts (3 hunks)
  • packages/runtime/package.json (1 hunks)
  • packages/runtime/src/createGatewayRuntime.ts (2 hunks)
  • packages/runtime/src/getReportingPlugin.ts (2 hunks)
  • packages/runtime/src/plugins/useHiveConsole.ts (1 hunks)
  • packages/runtime/src/types.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (7)
  • .changeset/wet-kiwis-peel.md
  • .changeset/plenty-llamas-push.md
  • .changeset/@graphql-hive_gateway-runtime-809-dependencies.md
  • packages/runtime/package.json
  • packages/runtime/src/types.ts
  • packages/runtime/src/plugins/useHiveConsole.ts
  • packages/gateway/src/cli.ts
🧰 Additional context used
📓 Path-based instructions (3)
`packages/**`: In this directory we keep all packages releva...

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.

  • packages/gateway/src/commands/proxy.ts
  • packages/gateway/src/commands/supergraph.ts
  • packages/gateway/src/commands/handleReportingConfig.ts
  • packages/runtime/src/createGatewayRuntime.ts
  • packages/runtime/src/getReportingPlugin.ts
  • packages/gateway/src/commands/subgraph.ts
`packages/gateway/**`: The main runtime for the Hive gateway...

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.

  • packages/gateway/src/commands/proxy.ts
  • packages/gateway/src/commands/supergraph.ts
  • packages/gateway/src/commands/handleReportingConfig.ts
  • packages/gateway/src/commands/subgraph.ts
`**`: For all PRs, we would like to verify that a Linear iss...

**: 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/proxy.ts
  • packages/gateway/src/commands/supergraph.ts
  • packages/gateway/src/commands/handleReportingConfig.ts
  • packages/runtime/src/createGatewayRuntime.ts
  • packages/runtime/src/getReportingPlugin.ts
  • packages/gateway/src/commands/subgraph.ts
⏰ Context from checks skipped due to timeout of 90000ms (26)
  • GitHub Check: Unit / Node v23
  • GitHub Check: Unit / Bun
  • GitHub Check: Unit / Node v22
  • GitHub Check: Unit / Node v20
  • GitHub Check: Leaks / Node v23
  • GitHub Check: Leaks / Node v22
  • GitHub Check: Leaks / Node v20
  • GitHub Check: Leaks / Node v18
  • GitHub Check: E2E / Bun Docker on Ubuntu
  • GitHub Check: E2E / Bun on Ubuntu
  • GitHub Check: E2E / Node Binary on Windows
  • GitHub Check: E2E / Node Binary on Ubuntu
  • GitHub Check: E2E / Node Docker on Ubuntu
  • GitHub Check: Benchmark / bun / 1000 items
  • GitHub Check: E2E / Node 23 on Ubuntu
  • GitHub Check: Snapshot / snapshot
  • GitHub Check: Benchmark / bun / 100 items
  • GitHub Check: E2E / Node 22 on Ubuntu
  • GitHub Check: Benchmark / bun / 10 items
  • GitHub Check: Benchmark / node / 1000 items
  • GitHub Check: E2E / Node 20 on Ubuntu
  • GitHub Check: Bundle
  • GitHub Check: Build
  • GitHub Check: E2E / Node 18 on Ubuntu
  • GitHub Check: Benchmark / node / 100 items
  • GitHub Check: Benchmark / node / 10 items
🔇 Additional comments (18)
packages/runtime/src/createGatewayRuntime.ts (2)

98-98: New import for Hive Console plugin

This import correctly replaces the previous Mesh Hive plugin import, aligning with the PR objective of relocating the Hive plugin from Mesh to Gateway.


205-208: Good implementation of the new Hive Console plugin

The persistedDocumentsPlugin now properly uses the new useHiveConsole function instead of the previous Mesh-based plugin. Setting enabled: false ensures that only usage reporting is disabled while persisted documents functionality remains intact.

packages/runtime/src/getReportingPlugin.ts (4)

2-4: Updated imports for Hive Console plugin

The import statement correctly brings in the new Hive Console plugin and its types, which is necessary for the plugin migration described in the PR objectives.


15-15: Updated return type to support GraphOS

The return type now correctly allows the name to be either 'Hive' or 'GraphOS', providing better type safety.


19-29: Improved handling of target and usage configuration

This code change adds support for the new target option mentioned in the PR objectives. The implementation correctly handles cases where usage is explicitly disabled, and properly constructs the usage object when target is specified.

The type check before spreading usage properties is a good defensive programming practice to avoid errors when trying to spread non-object values.


32-37: Updated plugin initialization

The code now properly uses the new useHiveConsole plugin with enabled: true to ensure usage reporting is activated when configured. The conditional spreading of the usage object ensures that configuration is only applied when relevant.

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

31-31: Well-structured import for reporting configuration.

No issues found; extracting reporting logic into a dedicated helper module improves maintainability and readability.


54-55: Ensure changeset includes new CLI options.

You've introduced --hive-usage-target and --hive-usage-access-token. According to our guidelines, please confirm there's a corresponding changeset describing these new CLI options with a minor semver bump.

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

25-25: Import statement looks good.

Centralizing logic for reporting configuration enhances modularity.


41-42: Include these new subgraph usage flags in the changeset.

Remember to confirm that the subgraph’s newly accepted CLI options are documented, consistent with supergraph usage, and covered in the existing or new changeset file.

packages/gateway/src/commands/handleReportingConfig.ts (5)

1-6: Imports are concise.

Everything is well-organized and matches the needed types from the parent directories.


8-14: Interface definition is clear.

The new fields for Hive usage target and access token are straightforward. Ensure these remain in sync with any further additions to the CLI flags.


16-37: Centralizing reporting configuration.

Overall approach merges config-based reporting with CLI overrides. This simplifies the logic in the command files. Great job!


83-97: GraphOS reporting configuration looks good.

Apollo usage explicitly requires a graph ref in <graph-id>@<graph-variant> format. Good job enforcing that requirement and cleaning up the command-level logic.


99-100: Handling no configuration scenario gracefully.

Returning null when no valid reporting options apply is clear. Make sure the calling code checks for a null return properly (which you have done).

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

21-21: Approve module import for centralized reporting config handling.

Good modularization by centralizing reporting configuration logic into a separate file.


147-147: Simplified configuration composition using spread operator.

Clean implementation using the spread operator to merge the reporting configuration.


34-196:

❓ Verification inconclusive

Verify documentation for new CLI options.

The PR adds two new CLI options (--hive-usage-target and --hive-usage-access-token) but they aren't documented in the CLI help text. While the implementation is sound, users won't know about these options without proper documentation.

Could you verify if documentation for these new options has been added to the corresponding console project as mentioned in the coding guidelines? If not, consider creating a follow-up issue to add documentation for these new options and the deprecation of --hive-registry-token.


🏁 Script executed:

#!/bin/bash
# Check if the new CLI options are documented in the command
grep -r --include="*.ts" "hiveUsageTarget\|hiveUsageAccessToken" packages/

Length of output: 2346


Documentation Update for New CLI Options Required

The new CLI options (--hive-usage-target and --hive-usage-access-token) are properly integrated into the code, as visible in the reporting configuration. However, there's no evidence from the repository that these options have been added to the corresponding console project's CLI help text. Please verify whether the documentation update has been completed per our coding guidelines. If not, create a follow-up issue to add the missing documentation for these new options and to note the deprecation of --hive-registry-token.

@enisdenjo enisdenjo merged commit 17cfa19 into main Mar 12, 2025
32 of 33 checks passed
@enisdenjo enisdenjo deleted the use-hive-console branch March 12, 2025 16:28
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.

5 participants