Skip to content

refactor(subscription): consolidate WebSocket handling in subscription plugin #7690

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

Draft
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

BrynCooke
Copy link
Contributor

@BrynCooke BrynCooke commented Jun 14, 2025

Consolidate WebSocket handling in subscription plugin

Task

Consolidate WebSocket subscription handling logic within the subscription plugin to improve architectural clarity and code maintainability as part of the broader subgraph service refactoring effort.

Why

The WebSocket subscription logic was scattered between the subgraph service and subscription plugin, creating unnecessary coupling and making the codebase harder to maintain. WebSocket handling is subscription-specific functionality that logically belongs entirely within the subscription plugin rather than being split across multiple services.

Benefits:

  • Clear ownership of WebSocket subscription logic within subscription plugin
  • Reduced coupling between subgraph service and subscription functionality
  • Better separation of concerns following single responsibility principle
  • Foundation for future subscription protocol enhancements

How

Code Consolidation:

  • Moved call_websocket() and get_websocket_request() functions from subgraph service to subscription plugin
  • Relocated SubscriptionExtension struct definition to subscription plugin module
  • Updated subgraph service to delegate WebSocket subscription requests to subscription plugin
  • Removed unused WebSocket imports and dependencies from subgraph service

Architectural Improvements:

  • Subscription plugin now owns all subscription-related WebSocket logic
  • Subgraph service focuses solely on HTTP request handling
  • Reduced coupling between services while preserving all existing functionality

Technical Details

  • Zero behavioral changes: All WebSocket subscription functionality remains identical
  • API compatibility: Fully preserved with no breaking changes
  • Code organization: Complete separation of HTTP and WebSocket concerns
  • Import cleanup: Removed unused WebSocket dependencies from subgraph service
  • Delegation pattern: Subgraph service cleanly delegates to subscription plugin for WebSocket requests

Review Strategy

Focus on these specific areas not covered by CI:

  1. Functional verification: Confirm that all WebSocket subscription functionality works identically to before, including error handling and connection management

  2. Architecture review: Verify that the subscription plugin properly handles all WebSocket scenarios that were previously handled by subgraph service

  3. Code organization: Check that no subscription-related logic remains in subgraph service and that all imports are properly updated

  4. Delegation correctness: Ensure that the subgraph service properly identifies and delegates WebSocket requests to the subscription plugin without data loss

  5. Test coverage: Verify that all existing WebSocket subscription tests pass and that no functionality was lost during the code movement


Checklist

Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review.

  • Changes are compatible1
  • Documentation2 completed
  • Performance impact assessed and acceptable
  • Metrics and logs are added3 and documented
  • Tests added and passing4
    • Unit Tests
    • Integration Tests
    • Manual Tests

Exceptions

Note any exceptions here

Notes

Footnotes

  1. It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this.

  2. Configuration is an important part of many changes. Where applicable please try to document configuration examples.

  3. A lot of (if not most) features benefit from built-in observability and debug-level logs. Please read this guidance on metrics best-practices.

  4. Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions.

@BrynCooke BrynCooke requested a review from a team as a code owner June 14, 2025 19:23

This comment has been minimized.

@BrynCooke BrynCooke marked this pull request as draft June 14, 2025 20:36
bryn added 2 commits June 14, 2025 22:33
…ugin

Moves WebSocket subscription logic from subgraph_service.rs to the subscription
plugin to improve architectural clarity and maintainability. WebSocket handling
is subscription-specific functionality that belongs with the subscription plugin
rather than in the generic subgraph service layer.

Technical implementation:
- Relocate call_websocket() and get_websocket_request() functions from subgraph service to subscription plugin
- Move SubscriptionExtension struct definition to subscription plugin module
- Update subgraph service to delegate WebSocket subscription requests to subscription plugin
- Remove unused WebSocket imports and dependencies from subgraph service
- Preserve all existing functionality and API compatibility

This refactoring consolidates related functionality, reduces coupling between
services, and creates clearer separation of concerns. The subscription plugin
now owns all subscription-related WebSocket logic while the subgraph service
focuses on HTTP request handling.

Review strategy: Verify that all WebSocket subscription functionality remains
intact and that the subscription plugin properly handles all passthrough mode
scenarios. Check that no functionality was lost in the code movement.
@BrynCooke BrynCooke force-pushed the refactor/move-websocket-to-subscription-plugin branch from 6a92a55 to 3512cf2 Compare June 14, 2025 22:10
@apollo-librarian
Copy link

apollo-librarian bot commented Jun 14, 2025

✅ Docs preview has no changes

The preview was not built because there were no changes.

Build ID: 6bf77d65a00effee68fd52ce

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.

1 participant