Transport
Accessors
closed
Get Signature
get closed(): boolean;
Returns
boolean
Constructors
Constructor
new Transport(
url,
defaultTimeout?,
transportFactory?): Transport;
Parameters
| Parameter | Type | Default value |
|---|---|---|
url | string | undefined | undefined |
defaultTimeout | number | 30000 |
transportFactory | TransportFactory | defaultTransportFactory |
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
| Parameter | Type |
|---|---|
listener | (message) => void |
Returns
() => void
operationTimeout()
operationTimeout(timeout?, cushion?): number;
Resolve a per-operation timeout against the transport default.
Parameters
| Parameter | Type | Default value |
|---|---|---|
timeout? | number | undefined |
cushion? | number | 0 |
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
| Parameter | Type |
|---|---|
query | string |
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
| Parameter | Type |
|---|---|
query | string |
variables | Record<string, unknown> |
handlers | Subscriber |
Returns
Promise<() => void>