feat: add real WebSocket E2E integration test for realtime subscriptions#1163
Merged
Conversation
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
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. |
- 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
522464b to
50eb5d6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 whereargs.get('ids')was using the deprecated grafastFieldArgsAPI.Bug fix (
plugin.ts): Changedargs.get('ids')→args.getRaw('ids'). The grafastFieldArgs.get()method is deprecated (typed asnever) 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:grafastSubscribeidsargumentThe 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 agraphql-wsclient over an actual WebSocket transport.Review & Testing Checklist for Human
args.getRaw('ids')correctness: Confirm that.getRaw()returns the expected grafast step type and that the downstreamlambdain thesubscribePlancorrectly receivesstring[] | null | undefinedat runtime. This is a production code change.event: 'UNKNOWN'androwId: null(lines 377-387) because grafast subscriptions don't support event-level inhibition. Verify this is the intended client-side filtering contract.delay(200)–delay(500)for event propagation. Verify these are sufficient for CI environments under load. Consider whether any of these could be flaky.graphql-ws6.0.7→6.0.8 andws8.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-websocketlocally against a seeded PostgreSQL instance to verify all 7 tests pass.Notes
realtime.integration.test.tshas a pre-existing module resolution error onmain(not introduced by this PR).pgSubscriberis manually threaded into the grafast context via thegraphql-wssubscribehandler — 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