feat: add graphile-realtime-test package for subscription integration testing#1144
Merged
Conversation
… testing New package providing test utilities for graphile-realtime-subscriptions: - makeRealtimeSmartTagsPlugin(): inject @realtime tags on tables during schema build - subscribe(): grafast.subscribe() wrapper returning typed async iterator - waitForEvent()/collectEvents(): async iterator helpers with timeout - notify()/notifyChange()/notifyInvalidate(): pg_notify helpers matching emit_change format - createRealtimeTestContext(): fully wired context with schema + subscription + NOTIFY helpers - Minimal SQL seed table for dogfooding Integration tests verify schema discovery, event flow, overflow, and sparse set filtering.
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:
|
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
New
graphile-realtime-testpackage providing reusable test utilities for integration-testing GraphQL subscriptions powered bygraphile-realtime-subscriptions. The package wrapsgraphile-testconnections with subscription-aware context and offers:makeRealtimeSmartTagsPlugin(tagsByTable)— injects@realtimesmart tags on table codecs during schema build (mirrorsgraphile-searchtest pattern)subscribe(opts)— typed wrapper aroundgrafast.subscribe()returning anAsyncIterableIteratorwaitForEvent()/collectEvents()— async iterator helpers with configurable timeoutsnotify()/notifyChange()/notifyInvalidate()—pg_notifyhelpers matching therealtime:<schema>.<table>channel format andOP:uuid,...payload format used byemit_changecreateRealtimeTestContext()— orchestrates schema build, pgSubscriber wiring, and exposes convenience methods (ctx.subscribe(),ctx.notifyChange(),ctx.teardown())realtime-seed.sql) and integration tests that dogfood all helpersThe lockfile diff is ~99% pnpm reformatting (multi-line
resolution:collapsed to single-line); actual dependency additions are just the new package.Review & Testing Checklist for Human
pgSubscriberextraction incontext.tsuses(pgService as any).pgSubscriber— verify this is the correct way to obtain the subscriber frommakePgService(). If postgraphile exposes a typed API for this, it should be used instead. This is the most fragile part of the package.--passWithNoTestssince CI has no database with the seed applied. Runcd graphile/graphile-realtime-test && pnpm testlocally against a real PostgreSQL instance with the seed SQL to verify all 7+ test cases pass end-to-end."grafast": "1.0.0","postgraphile": "5.0.0", etc.) — confirm these match the workspace versions and that exact pinning (vsworkspace:^or semver ranges) is intentional for peer deps.onItemChanged,ItemSubscriptionPayload) generated by the realtime subscriptions plugin — verify these match the plugin's actual naming convention.Notes
smart-tags.tshook usesbefore: ['RealtimeSubscriptionsPlugin']to ensure tags are injected before the realtime plugin discovers them — this ordering is load-bearing.context.tsalso falls back topgSubscriberKey ?? 'pgSubscriber'for the grafast context key, which should be verified against howRealtimeSubscriptionsPluginlooks up the subscriber.collectEvents()is exported but has no dedicated test coverage — decide if this needs a test or ifwaitForEvent()coverage is sufficient.Link to Devin session: https://app.devin.ai/sessions/19485cf5cc58416a9f86068563d512f5
Requested by: @pyramation