refactor(codegen): accept WsClient via config instead of require('graphql-ws')#1102
Merged
pyramation merged 3 commits intomainfrom May 10, 2026
Merged
Conversation
…-realtime template
The orm-realtime.ts template used `type WsClient = import('graphql-ws').Client`
which requires graphql-ws to be resolvable at compile time in every SDK
consumer, even though the actual require() is lazy inside the
RealtimeManager constructor.
Replace with minimal inline type definitions (WsClient, WsClientOptions,
WsSink, WsExecutionResult) so generated code compiles without graphql-ws
as a dependency. Consumers that never use subscriptions never need the
package at all.
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:
|
…phql-ws')
Instead of the generated RealtimeManager doing require('graphql-ws')
internally (which fails in ESM and forces a hidden dependency), the
consumer now passes a WsClient instance via RealtimeConfig.client:
import { createClient } from 'graphql-ws';
const orm = createOrmClient({
endpoint: '...',
realtime: { client: createClient({ url: 'wss://...' }) },
});
This gives the developer full control over WS connection options,
auth, and transport. If subscriptions aren't used, graphql-ws is
never imported at all.
This comment has been minimized.
This comment has been minimized.
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
The
orm-realtime.tscodegen template previously didrequire('graphql-ws')inside theRealtimeManagerconstructor, which:graphql-wsas a hidden dependency even when subscriptions aren't usedNew approach:
RealtimeConfignow accepts aclient: WsClientproperty. The consumer creates and passes in their owngraphql-wsclient instance:The SDK defines only a minimal
WsClientinterface — noimport, norequire, no dependency ongraphql-wsat all. If the developer never uses subscriptions, they never need the package.Changes:
RealtimeConfigsimplified to{ client: WsClient }— all WS connection options (url, auth, retry, etc.) are now the consumer's responsibility when creating the clientWsClientexported as a public type so consumers can reference the interfaceRealtimeManagerconstructor reduced tothis.wsClient = config.clientWsClientexportReview & Testing Checklist for Human
WsClientinterface shape (subscribe+dispose) stays compatible withgraphql-ws'sClienttypeconstructive-dbto confirm the regeneratedrealtime.tsfiles match the new templateclient: createClient(...)instead of the oldurl/getToken/etc. configNotes
Companion fix already pushed to constructive-db PR #1089 (
deps-update/20260510-105803) with the same changes applied to all 13 generatedrealtime.tsfiles.Link to Devin session: https://app.devin.ai/sessions/37cd48fd674844c8b6fa1be2b7995746
Requested by: @pyramation