Skip to content

enhance(executor-http): ensure subgraph name is present in the upstream HTTP error extensions#792

Merged
ardatan merged 5 commits intomainfrom
ensure-subgraph-name
Mar 7, 2025
Merged

enhance(executor-http): ensure subgraph name is present in the upstream HTTP error extensions#792
ardatan merged 5 commits intomainfrom
ensure-subgraph-name

Conversation

@ardatan
Copy link
Copy Markdown
Member

@ardatan ardatan commented Mar 7, 2025

Ref GW-241

Subgraph name exists as serviceName in case of DOWNSTREAM_SERVICE_ERROR as in Apollo Gateway.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 7, 2025

📝 Walkthrough

Summary by CodeRabbit

  • Chores

    • Updated dependency versions to enhance system stability.
  • New Features

    • Improved error reporting: Error messages now include a service identifier for clearer context.
  • Refactor

    • Consolidated and streamlined error handling by replacing redundant definitions.
  • Tests

    • Expanded test coverage to validate the improved error reporting mechanism.

Walkthrough

The changes introduce a new changeset file documenting updates to several GraphQL-related dependencies, including minor and patch version updates. A new interface for upstream error extensions has been added, while a local definition has been removed in favor of an external re-export. The HTTP executor options now include a new optional property for a service name, and related runtime code and tests have been updated to reflect changes in error extension properties.

Changes

File(s) Change Summary
.changeset/clean-games-film.md New file documenting dependency updates (minor and patch bumps for GraphQL-related packages) and outlining functionality to include the subgraph name in upstream error extensions.
packages/executors/common/src/index.ts Added a new UpstreamErrorExtensions interface with optional properties for error handling.
packages/executors/http/src/index.ts Added a new optional serviceName property to HTTPExecutorOptions and removed the previous definition of UpstreamErrorExtensions.
packages/runtime/src/plugins/useUpstreamTimeout.ts Renamed subgraph to serviceName in the upstreamErrorExtensions object within the onFetch method.
packages/runtime/tests/upstream-retry.test.ts Added a new serviceName property in error responses for specific error cases in the test suite.
packages/transports/common/src/types.ts Removed local definition of UpstreamErrorExtensions and re-exported it from @graphql-tools/executor-common.
packages/transports/http/src/index.ts Introduced a new serviceName property in the object returned by getSubgraphExecutor.
e2e/aws-sigv4/aws-sigv4.e2e.ts Added serviceName property in error response for unsigned request test case.
packages/runtime/tests/subgraph-errors.test.ts New test file for handling errors in subgraph queries, verifying error reporting mechanism.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • GW-241: Authentication required, not authenticated - You need to authenticate to access this operation.

📜 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 d14c97d and 97aa61c.

📒 Files selected for processing (3)
  • e2e/aws-sigv4/aws-sigv4.e2e.ts (1 hunks)
  • packages/executors/common/src/index.ts (1 hunks)
  • packages/runtime/tests/subgraph-errors.test.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/executors/common/src/index.ts
🧰 Additional context used
📓 Path-based instructions (3)
`e2e/**`: This directory includes end-to-end tests for the g...

e2e/**: This directory includes end-to-end tests for the gateway.
The examples directory is generated based on the code in this directory.

  • e2e/aws-sigv4/aws-sigv4.e2e.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.

  • e2e/aws-sigv4/aws-sigv4.e2e.ts
  • packages/runtime/tests/subgraph-errors.test.ts
`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/runtime/tests/subgraph-errors.test.ts
⏰ Context from checks skipped due to timeout of 90000ms (22)
  • GitHub Check: E2E / Bun Docker on Ubuntu
  • GitHub Check: Leaks / Node v23
  • GitHub Check: E2E / Bun on Ubuntu
  • GitHub Check: E2E / Node Binary on Windows
  • GitHub Check: Leaks / Node v22
  • GitHub Check: Leaks / Node v20
  • GitHub Check: Leaks / Node v18
  • 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: E2E / Node 20 on Ubuntu
  • GitHub Check: E2E / Node 18 on Ubuntu
  • GitHub Check: Snapshot / snapshot
  • GitHub Check: Benchmark / bun / 1000 items
  • GitHub Check: Unit / Bun
  • GitHub Check: Benchmark / bun / 100 items
  • GitHub Check: Benchmark / bun / 10 items
  • GitHub Check: Benchmark / node / 1000 items
  • GitHub Check: Bundle
  • GitHub Check: Benchmark / node / 100 items
  • GitHub Check: Benchmark / node / 10 items
🔇 Additional comments (2)
e2e/aws-sigv4/aws-sigv4.e2e.ts (1)

74-74: Properly added serviceName to error extensions

This change correctly implements the enhancement to include the subgraph name as serviceName in the error extensions, aligning with Apollo Gateway's behavior as mentioned in the PR objectives.

packages/runtime/tests/subgraph-errors.test.ts (1)

1-70: Well-structured test for the new feature

The test file is well-designed to verify that subgraph errors properly include the service name in error extensions. Good practices used here:

  • Using random values for service name and error message to ensure resilience
  • Proper resource cleanup with using declarations
  • Explicit verification of all error properties including the new serviceName
  • Isolated test that doesn't depend on external services

This test directly validates the enhancement described in GW-241.

✨ 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.

Copy link
Copy Markdown
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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 661b103 and 06fe9e2.

📒 Files selected for processing (7)
  • .changeset/clean-games-film.md (1 hunks)
  • packages/executors/common/src/index.ts (1 hunks)
  • packages/executors/http/src/index.ts (5 hunks)
  • packages/runtime/src/plugins/useUpstreamTimeout.ts (1 hunks)
  • packages/runtime/tests/upstream-retry.test.ts (2 hunks)
  • packages/transports/common/src/types.ts (1 hunks)
  • packages/transports/http/src/index.ts (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/executors/common/src/index.ts
  • packages/transports/common/src/types.ts
  • packages/runtime/tests/upstream-retry.test.ts
  • packages/runtime/src/plugins/useUpstreamTimeout.ts
  • packages/transports/http/src/index.ts
  • packages/executors/http/src/index.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/executors/common/src/index.ts
  • packages/transports/common/src/types.ts
  • packages/runtime/tests/upstream-retry.test.ts
  • packages/runtime/src/plugins/useUpstreamTimeout.ts
  • packages/transports/http/src/index.ts
  • packages/executors/http/src/index.ts
`packages/transports/**`: The transports configures how to d...

packages/transports/**: The transports configures how to deal with requests that are made from the GraphQL gateway to the GraphQL subgraphs. Transports manipulates the calls, headers, protocols and others.

  • packages/transports/common/src/types.ts
  • packages/transports/http/src/index.ts
🪛 GitHub Check: Types
packages/transports/common/src/types.ts

[failure] 57-57:
Re-exporting a type when 'isolatedModules' is enabled requires using 'export type'.

⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: Leaks / Node v23
  • GitHub Check: Leaks / Node v22
  • GitHub Check: Leaks / Node v20
  • GitHub Check: Leaks / Node v18
  • GitHub Check: Benchmark / bun / 1000 items
  • GitHub Check: Benchmark / bun / 100 items
  • GitHub Check: Benchmark / bun / 10 items
  • GitHub Check: Benchmark / node / 1000 items
  • GitHub Check: Benchmark / node / 100 items
  • GitHub Check: Benchmark / node / 10 items
🔇 Additional comments (11)
.changeset/clean-games-film.md (1)

1-9: Changeset properly documents the dependency updates and feature addition.

The changeset correctly indicates:

  • Minor version update for @graphql-tools/executor-http
  • Patch updates for the other affected packages
  • A clear description of the feature addition to include subgraph name in error extensions

This aligns with the PR objectives to enhance error reporting.

packages/executors/common/src/index.ts (1)

60-73: Well-structured interface for consistent error handling.

The new UpstreamErrorExtensions interface provides a standardized structure for error reporting in upstream HTTP requests, including the optional serviceName property which is the core enhancement of this PR.

The interface is designed with appropriate optional fields to accommodate various error scenarios, properly typing the request and response information.

packages/runtime/tests/upstream-retry.test.ts (2)

93-93: Test updated to verify subgraph name in error extensions.

The test now verifies that the subgraph name is included in the error extensions, validating the core functionality added by this PR.


194-194: Consistent error format across different error scenarios.

The second test case is also properly updated to include the subgraph name in error extensions, ensuring consistent error reporting regardless of the error type (standard error vs rate limiting).

packages/runtime/src/plugins/useUpstreamTimeout.ts (1)

152-152: LGTM! Property renamed to improve consistency.

The change from subgraph to serviceName for the property in upstreamErrorExtensions aligns with the Apollo Gateway naming convention and creates better consistency across error handling in the codebase.

packages/transports/http/src/index.ts (1)

59-59: LGTM! Properly passing subgraph name to HTTP executor.

This addition correctly passes the subgraph name to the HTTP executor, ensuring it's available for error reporting. This change is aligned with the PR objective to include subgraph names in upstream HTTP error extensions.

packages/executors/http/src/index.ts (5)

5-5: LGTM! Using imported type instead of local definition.

Importing UpstreamErrorExtensions from the common package promotes consistency and reduces duplication.


59-63: LGTM! Well-documented new property.

The added serviceName property is properly documented with a clear description of its purpose.


165-165: LGTM! Proper extraction of the service name.

Correctly extracts the service name from options to be used in error reporting.


238-238: LGTM! Including service name in upstream error extensions.

Adding the service name to upstream error extensions provides valuable context for debugging and error handling.


447-447: LGTM! Consistent with Apollo Gateway naming.

Using the service name as the value for the subgraph property in downstream error extensions aligns with Apollo Gateway conventions as mentioned in the PR objectives.

@theguild-bot
Copy link
Copy Markdown
Collaborator

theguild-bot commented Mar 7, 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 9.0.32-alpha-97aa61c442facee49ab18af23145184fd1cb236c npm ↗︎ unpkg ↗︎
@graphql-tools/batch-execute 9.0.13-alpha-97aa61c442facee49ab18af23145184fd1cb236c npm ↗︎ unpkg ↗︎
@graphql-tools/delegate 10.2.14-alpha-97aa61c442facee49ab18af23145184fd1cb236c npm ↗︎ unpkg ↗︎
@graphql-tools/executor-common 0.0.4-alpha-97aa61c442facee49ab18af23145184fd1cb236c npm ↗︎ unpkg ↗︎
@graphql-tools/executor-graphql-ws 2.0.4-alpha-97aa61c442facee49ab18af23145184fd1cb236c npm ↗︎ unpkg ↗︎
@graphql-tools/executor-http 1.3.0-alpha-97aa61c442facee49ab18af23145184fd1cb236c npm ↗︎ unpkg ↗︎
@graphql-tools/federation 3.1.5-alpha-97aa61c442facee49ab18af23145184fd1cb236c npm ↗︎ unpkg ↗︎
@graphql-mesh/fusion-runtime 0.11.3-alpha-97aa61c442facee49ab18af23145184fd1cb236c npm ↗︎ unpkg ↗︎
@graphql-hive/gateway 1.11.0-alpha-97aa61c442facee49ab18af23145184fd1cb236c npm ↗︎ unpkg ↗︎
@graphql-hive/logger-json 0.0.3-alpha-97aa61c442facee49ab18af23145184fd1cb236c npm ↗︎ unpkg ↗︎
@graphql-hive/logger-winston 1.0.2-alpha-97aa61c442facee49ab18af23145184fd1cb236c npm ↗︎ unpkg ↗︎
@graphql-hive/nestjs 1.0.0-alpha-97aa61c442facee49ab18af23145184fd1cb236c npm ↗︎ unpkg ↗︎
@graphql-hive/plugin-aws-sigv4 1.0.0-alpha-97aa61c442facee49ab18af23145184fd1cb236c npm ↗︎ unpkg ↗︎
@graphql-mesh/hmac-upstream-signature 1.2.22-alpha-97aa61c442facee49ab18af23145184fd1cb236c npm ↗︎ unpkg ↗︎
@graphql-mesh/plugin-opentelemetry 1.3.45-alpha-97aa61c442facee49ab18af23145184fd1cb236c npm ↗︎ unpkg ↗︎
@graphql-mesh/plugin-prometheus 1.3.33-alpha-97aa61c442facee49ab18af23145184fd1cb236c npm ↗︎ unpkg ↗︎
@graphql-hive/gateway-runtime 1.5.0-alpha-97aa61c442facee49ab18af23145184fd1cb236c npm ↗︎ unpkg ↗︎
@graphql-tools/stitch 9.4.19-alpha-97aa61c442facee49ab18af23145184fd1cb236c npm ↗︎ unpkg ↗︎
@graphql-tools/stitching-directives 3.1.29-alpha-97aa61c442facee49ab18af23145184fd1cb236c npm ↗︎ unpkg ↗︎
@graphql-mesh/transport-common 0.7.31-alpha-97aa61c442facee49ab18af23145184fd1cb236c npm ↗︎ unpkg ↗︎
@graphql-mesh/transport-http 0.6.35-alpha-97aa61c442facee49ab18af23145184fd1cb236c npm ↗︎ unpkg ↗︎
@graphql-mesh/transport-http-callback 0.5.22-alpha-97aa61c442facee49ab18af23145184fd1cb236c npm ↗︎ unpkg ↗︎
@graphql-mesh/transport-ws 1.0.5-alpha-97aa61c442facee49ab18af23145184fd1cb236c npm ↗︎ unpkg ↗︎
@graphql-tools/wrap 10.0.32-alpha-97aa61c442facee49ab18af23145184fd1cb236c npm ↗︎ unpkg ↗︎

@theguild-bot
Copy link
Copy Markdown
Collaborator

theguild-bot commented Mar 7, 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
Copy Markdown
Collaborator

theguild-bot commented Mar 7, 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
Copy Markdown
Collaborator

theguild-bot commented Mar 7, 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.11.0-alpha-97aa61c442facee49ab18af23145184fd1cb236c

@theguild-bot
Copy link
Copy Markdown
Collaborator

theguild-bot commented Mar 7, 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
Copy Markdown
Collaborator

theguild-bot commented Mar 7, 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.11.0-alpha-97aa61c442facee49ab18af23145184fd1cb236c-bun

@theguild-bot
Copy link
Copy Markdown
Collaborator

theguild-bot commented Mar 7, 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
Copy Markdown
Collaborator

theguild-bot commented Mar 7, 2025

🚀 Snapshot Release (Binary for Windows-X64)

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

Download

@ardatan ardatan merged commit 9c2f323 into main Mar 7, 2025
63 checks passed
@ardatan ardatan deleted the ensure-subgraph-name branch March 7, 2025 11:53
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.

3 participants