Skip to content

feat: add real WebSocket E2E integration test for realtime subscriptions#1163

Merged
pyramation merged 1 commit into
mainfrom
feat/realtime-websocket-e2e
May 14, 2026
Merged

feat: add real WebSocket E2E integration test for realtime subscriptions#1163
pyramation merged 1 commit into
mainfrom
feat/realtime-websocket-e2e

Conversation

@pyramation
Copy link
Copy Markdown
Contributor

Summary

Adds a full end-to-end integration test suite for realtime subscriptions over real WebSocket connections (not mocked grafast.subscribe() calls). Also fixes a bug in the realtime subscriptions plugin where args.get('ids') was using the deprecated grafast FieldArgs API.

Bug fix (plugin.ts): Changed args.get('ids')args.getRaw('ids'). The grafast FieldArgs.get() method is deprecated (typed as never) and was causing "args.get is not a function" errors during subscription planning. .getRaw() is the correct API.

New test file (realtime-websocket.integration.test.ts): 7 test cases covering:

  • Sanity check via direct grafastSubscribe
  • INSERT, UPDATE, DELETE event delivery over WebSocket
  • INVALIDATE (overflow) events
  • Sparse set filtering via ids argument
  • Multiple concurrent WebSocket subscribers
  • Raw NOTIFY payload handling

The test infrastructure seeds a PostgreSQL database, builds a GraphQL schema with RealtimeSubscriptionsPlugin, starts a real HTTP + WebSocket server (ws + graphql-ws/use/ws), and connects a graphql-ws client over an actual WebSocket transport.

Review & Testing Checklist for Human

  • Verify args.getRaw('ids') correctness: Confirm that .getRaw() returns the expected grafast step type and that the downstream lambda in the subscribePlan correctly receives string[] | null | undefined at runtime. This is a production code change.
  • Sparse set filtering design: The test asserts that non-matching events arrive with event: 'UNKNOWN' and rowId: null (lines 377-387) because grafast subscriptions don't support event-level inhibition. Verify this is the intended client-side filtering contract.
  • Timing-based test stability: Tests use delay(200)delay(500) for event propagation. Verify these are sufficient for CI environments under load. Consider whether any of these could be flaky.
  • Lockfile audit: The lockfile includes graphql-ws 6.0.7→6.0.8 and ws 8.19.0→8.20.1 version bumps across the workspace. Spot-check that no unintended transitive changes were introduced.

Recommended test plan: Run cd graphile/graphile-realtime-test && npx jest realtime-websocket locally against a seeded PostgreSQL instance to verify all 7 tests pass.

Notes

  • The existing realtime.integration.test.ts has a pre-existing module resolution error on main (not introduced by this PR).
  • The pgSubscriber is manually threaded into the grafast context via the graphql-ws subscribe handler — this mirrors how PostGraphile would wire it but is not identical to the production preset integration path.

Link to Devin session: https://app.devin.ai/sessions/19485cf5cc58416a9f86068563d512f5
Requested by: @pyramation

@devin-ai-integration
Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@socket-security
Copy link
Copy Markdown

socket-security Bot commented May 14, 2026

All alerts resolved. Learn more about Socket for GitHub.

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report

- Fix args.get() -> args.getRaw() in subscribePlan (grafast FieldArgs API)
- Add 7 E2E tests: sanity check, INSERT/UPDATE/DELETE events, INVALIDATE,
  sparse set filtering, concurrent subscribers, raw NOTIFY payloads
- Uses real graphql-ws server + client over WebSocket (not mocked)
- Uses seeded database with realtime-enabled tables
- Add graphql-ws, ws dependencies to graphile-realtime-test
@devin-ai-integration devin-ai-integration Bot force-pushed the feat/realtime-websocket-e2e branch from 522464b to 50eb5d6 Compare May 14, 2026 21:34
@pyramation pyramation merged commit 360e7a5 into main May 14, 2026
37 checks passed
@pyramation pyramation deleted the feat/realtime-websocket-e2e branch May 14, 2026 22:12
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