v1.4.0
Minor Changes
-
a8ff751Thanks @Torsten85! - ### Connection lifecycle & error handlingSocketQLProvider— New React provider that wraps URQL'sProvider, callsconnect()on mount, and throws connection errors to the nearest error boundary.ConnectionRejectedErrornow accepts an optionaldataparameter for structured error context sent to the client.ConnectionError— New client-side type withdata?: Record<string, any>, exported from@requence/socketql/client.
createClientAPI changes- Returns an extended URQL
Clientdirectly instead of{ client, manager, invalidate }. autoConnectnow defaults tofalse. UseSocketQLProvideror callclient.connect()manually.authoption (new) — replaces the previousonConnectoption for providing auth data.onConnectoption — now a connection success handler (() => void), no longer used for auth.onConnectErroroption — registers an initial connection error handler.client.connect()— Initiate the WebSocket connection.client.onConnect(cb)— Subscribe to successful connections. Returns unsubscribe function.client.onConnectError(cb)— Subscribe to connection errors. Returns unsubscribe function.client.invalidate(target)— Unchanged, now a method on the client directly.
Migration
-const { client, manager, invalidate } = createClient({ - onConnect: () => ({ token: getAccessToken() }), -}) +const client = createClient({ + auth: () => ({ token: getAccessToken() }), +}) -<Provider value={client}> +<SocketQLProvider client={client}> <App /> -</Provider> +</SocketQLProvider> -invalidate('Users') +client.invalidate('Users')