Skip to content

createClient

Creates a Socket.IO-backed URQL client with custom exchanges.

function createClient(options: ClientOptions): {
client: UrqlClient
manager: SocketManager
invalidate: (target: string | DocumentNode | Array) => void
}
OptionTypeDefaultDescription
pathstring'/ws/'Socket.IO server path
transportsstring[]['websocket']Allowed transports
graphqlNamespacestring'graphql'Socket.IO namespace to connect to
onConnect() => objectReturn auth data for the connection
PropertyTypeDescription
clientUrqlClientConfigured URQL client with Suspense enabled
managerSocketManagerThe underlying Socket.IO manager
invalidateFunctionManually invalidate cached operation results
// Single query by operation name
invalidate('Users')
// Single query by document node
invalidate(UsersDocument)
// Multiple queries
invalidate(['Users', ProjectsDocument])

Exported from @requence/socketql/client, this utility returns a promise that resolves when specific query results arrive:

import { waitForResult } from '@requence/socketql/client'
await waitForResult('Users')
await waitForResult(['Users', 'Projects'])