Skip to content

core(e2e): Add WebSocket programmatic usage e2e test to generate examples#1854

Closed
santino wants to merge 3 commits into
mainfrom
GW-125
Closed

core(e2e): Add WebSocket programmatic usage e2e test to generate examples#1854
santino wants to merge 3 commits into
mainfrom
GW-125

Conversation

@santino
Copy link
Copy Markdown

@santino santino commented Jan 13, 2026

Ref GW-125

Description

This PR adds a new e2e test websocket-programmatic-usage that demonstrates WebSocket subscription support in the Hive Gateway. The test serves as both validation and documentation for users who want to use WebSocket subscriptions programmatically.

Changes

Added Files:

  • e2e/websocket-programmatic-usage/websocket-programmatic-usage.e2e.ts - E2E test for WebSocket subscriptions
  • e2e/websocket-programmatic-usage/package.json - Test dependencies
  • e2e/websocket-programmatic-usage/mesh.config.ts - Mesh configuration
  • e2e/websocket-programmatic-usage/services/api.ts - GraphQL service with subscriptions

What the Test Demonstrates

The test validates that the Hive Gateway automatically provides WebSocket support for GraphQL subscriptions when using the mesh composition approach. It shows:

  1. WebSocket Connection: Establishing WebSocket connections to ws://localhost:4000/graphql
  2. Subscription Execution: Running GraphQL subscriptions over WebSocket
  3. Multiple Subscriptions: Handling concurrent subscriptions
  4. Connection Parameters: Passing authentication and client information
  5. Gateway Integration: How the gateway seamlessly provides WebSocket support for federated/composed services

Generated Example

When this PR is merged, the CI will automatically generate a complete example in examples/websocket-programmatic-usage/ that users can run locally to see WebSocket subscriptions in action.

Context

This addresses user feedback about needing better documentation/examples for WebSocket usage. The auto-generated example serves as living documentation showing how to set up and use WebSocket subscriptions with the Hive Gateway.

Testing

The test passes and validates the WebSocket functionality end-to-end. The CI will also generate and validate the example works correctly.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @santino, 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 a new end-to-end test suite designed to validate and showcase the programmatic usage of WebSocket subscriptions with the Hive Gateway. It addresses a need for clearer documentation and examples, ensuring that the gateway's automatic WebSocket support for federated services is well-demonstrated and easily reproducible for users.

Highlights

  • New E2E Test for WebSocket Programmatic Usage: Introduces a new end-to-end test (websocket-programmatic-usage) to validate and demonstrate WebSocket subscription support in the Hive Gateway when used programmatically.
  • Validation and Documentation: The test serves as both a validation mechanism for WebSocket functionality and a living documentation example for users looking to implement programmatic WebSocket subscriptions.
  • Comprehensive WebSocket Coverage: The test covers key aspects of WebSocket usage, including establishing connections, executing single and multiple GraphQL subscriptions, passing connection parameters (authentication, client info), and demonstrating seamless gateway integration.
  • Automated Example Generation: Upon merging, the CI pipeline will automatically generate a complete, runnable example in examples/websocket-programmatic-usage/, providing a practical resource for users.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/examples.yml
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.

Copy link
Copy Markdown
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 PR adds a new e2e test for WebSocket subscriptions, which is a great addition for both validation and documentation. The implementation is straightforward and covers the key aspects of programmatic WebSocket usage.

I've made a few suggestions to improve the robustness and consistency of the new test files:

  • Using localhost instead of 0.0.0.0 for the client connection to improve cross-platform compatibility.
  • Adding type checks to handle API responses more safely.
  • Adding missing newlines at the end of files for consistency.

Overall, this is a well-written PR that effectively demonstrates the WebSocket functionality.

Comment thread e2e/websocket-programmatic-usage/websocket-programmatic-usage.e2e.ts Outdated
Comment thread e2e/websocket-programmatic-usage/mesh.config.ts Outdated
Comment thread e2e/websocket-programmatic-usage/package.json Outdated
Comment thread e2e/websocket-programmatic-usage/services/api.ts Outdated
Comment thread e2e/websocket-programmatic-usage/websocket-programmatic-usage.e2e.ts Outdated
@theguild-bot
Copy link
Copy Markdown
Collaborator

theguild-bot commented Jan 13, 2026

🚀 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 2.2.3-alpha-aa257c229ae98cb4def13d5695b520014dbe3b3e npm ↗︎ unpkg ↗︎
@graphql-hive/nestjs 2.0.32-alpha-aa257c229ae98cb4def13d5695b520014dbe3b3e npm ↗︎ unpkg ↗︎
@graphql-hive/plugin-opentelemetry 1.3.3-alpha-aa257c229ae98cb4def13d5695b520014dbe3b3e npm ↗︎ unpkg ↗︎

@theguild-bot
Copy link
Copy Markdown
Collaborator

theguild-bot commented Jan 13, 2026

🚀 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 Jan 13, 2026

🚀 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 Jan 13, 2026

🚀 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.2.3-alpha-aa257c229ae98cb4def13d5695b520014dbe3b3e-bun

@theguild-bot
Copy link
Copy Markdown
Collaborator

theguild-bot commented Jan 13, 2026

🚀 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.2.3-alpha-aa257c229ae98cb4def13d5695b520014dbe3b3e

@theguild-bot
Copy link
Copy Markdown
Collaborator

theguild-bot commented Jan 13, 2026

🚀 Snapshot Release (Binary for Windows-X64)

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

Download

@enisdenjo enisdenjo closed this Apr 13, 2026
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