For AI agents: a documentation index is available at /llms.txt
Skip to main content

Transport

Accessors

closed

Get Signature

get closed(): boolean;
Returns

boolean

Constructors

Constructor

new Transport(
url,
defaultTimeout?,
transportFactory?): Transport;

Parameters

ParameterTypeDefault value
urlstring | undefinedundefined
defaultTimeoutnumber30000
transportFactoryTransportFactorydefaultTransportFactory

Returns

Transport

Methods

close()

close(): void;

Returns

void


connect()

connect(): Promise<void>;

Build the transport (via the factory) and send the graphql-transport-ws connection_init. Idempotent: repeated calls return the same in-flight promise. Resolves once the transport is wired and connection_init is sent; the server's connection_ack is consumed asynchronously. Frames ride a single ordered channel, so operations sent right after connect() resolves still arrive after connection_init server-side.

Returns

Promise<void>


onMessage()

onMessage(listener): () => void;

Subscribe to every raw frame the transport receives — in addition to the per-operation routing, and including frames with no matching operation (e.g. server-pushed data over a custom ConnectionTransport). The connection_ack handshake frame is consumed internally and not delivered. Returns an unsubscribe function.

Parameters

ParameterType
listener(message) => void

Returns

() => void


operationTimeout()

operationTimeout(timeout?, cushion?): number;

Resolve a per-operation timeout against the transport default.

Parameters

ParameterTypeDefault value
timeout?numberundefined
cushion?number0

Returns

number


send()

send<T>(
query,
variables?,
timeout?): Promise<T>;

Run a query or mutation and resolve with its data object. The operation emits a single next (whose data is captured) followed by complete (which resolves); a pre-execution error frame or GraphQL errors reject with BrowserQLError.

Type Parameters

Type Parameter
T

Parameters

ParameterType
querystring
variables?Record<string, unknown>
timeout?number

Returns

Promise<T>


subscribe()

subscribe(
query,
variables,
handlers): Promise<() => void>;

Open a subscription. Returns an unsubscribe function that completes just this stream. Streamed values and errors are delivered to handlers.

Parameters

ParameterType
querystring
variablesRecord<string, unknown>
handlersSubscriber

Returns

Promise<() => void>