Skip to content

feat: add graphile-realtime-test package for subscription integration testing#1144

Merged
pyramation merged 2 commits into
mainfrom
feat/graphile-realtime-test
May 12, 2026
Merged

feat: add graphile-realtime-test package for subscription integration testing#1144
pyramation merged 2 commits into
mainfrom
feat/graphile-realtime-test

Conversation

@pyramation
Copy link
Copy Markdown
Contributor

@pyramation pyramation commented May 12, 2026

Summary

New graphile-realtime-test package providing reusable test utilities for integration-testing GraphQL subscriptions powered by graphile-realtime-subscriptions. The package wraps graphile-test connections with subscription-aware context and offers:

  • makeRealtimeSmartTagsPlugin(tagsByTable) — injects @realtime smart tags on table codecs during schema build (mirrors graphile-search test pattern)
  • subscribe(opts) — typed wrapper around grafast.subscribe() returning an AsyncIterableIterator
  • waitForEvent() / collectEvents() — async iterator helpers with configurable timeouts
  • notify() / notifyChange() / notifyInvalidate()pg_notify helpers matching the realtime:<schema>.<table> channel format and OP:uuid,... payload format used by emit_change
  • createRealtimeTestContext() — orchestrates schema build, pgSubscriber wiring, and exposes convenience methods (ctx.subscribe(), ctx.notifyChange(), ctx.teardown())
  • Minimal SQL seed (realtime-seed.sql) and integration tests that dogfood all helpers
  • README with logo, CI badge, and API reference matching other workspace packages

The 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

  • pgSubscriber extraction in context.ts uses (pgService as any).pgSubscriber — verify this is the correct way to obtain the subscriber from makePgService(). If postgraphile exposes a typed API for this, it should be used instead. This is the most fragile part of the package.
  • Integration tests are not exercised in CI — tests use --passWithNoTests since CI has no database with the seed applied. Run cd graphile/graphile-realtime-test && pnpm test locally against a real PostgreSQL instance with the seed SQL to verify all 7+ test cases pass end-to-end.
  • Peer dependency versions are pinned exactly ("grafast": "1.0.0", "postgraphile": "5.0.0", etc.) — confirm these match the workspace versions and that exact pinning (vs workspace:^ or semver ranges) is intentional for peer deps.
  • Integration tests assume specific field names (onItemChanged, ItemSubscriptionPayload) generated by the realtime subscriptions plugin — verify these match the plugin's actual naming convention.

Notes

  • The smart-tags.ts hook uses before: ['RealtimeSubscriptionsPlugin'] to ensure tags are injected before the realtime plugin discovers them — this ordering is load-bearing.
  • context.ts also falls back to pgSubscriberKey ?? 'pgSubscriber' for the grafast context key, which should be verified against how RealtimeSubscriptionsPlugin looks up the subscriber.
  • collectEvents() is exported but has no dedicated test coverage — decide if this needs a test or if waitForEvent() coverage is sufficient.

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

… 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.
@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 12, 2026

@pyramation pyramation merged commit 5970bf6 into main May 12, 2026
37 checks passed
@pyramation pyramation deleted the feat/graphile-realtime-test branch May 12, 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