TransportWSServer class abstract

The server side of one connection of the graphql-transport-ws protocol, which the graphql-ws client and Apollo Client 3 speak.

It reads and writes JSON text over channel, such as a WebSocket's, and closes the connection with close, given a close code of TransportWSCloseCode and a reason, as the protocol reports errors that way. Extend it, and implement onSubscribe to run operations, usually with GraphQL.parseAndExecute.

See: https://github.com/enisdenjo/graphql-ws/blob/master/PROTOCOL.md

Constructors

TransportWSServer(StreamChannel<String> channel, {required void close(int code, String reason), Duration connectionInitWaitTimeout = const Duration(seconds: 3), Duration? keepAliveInterval})

Properties

channel → StreamChannel<String>
The JSON text messages of the connection.
final
close → void Function(int code, String reason)
Closes the connection with a close code and a reason.
final
connectionAckPayload → Map<String, dynamic>?
The payload of the connection_ack, if any.
no setter
connectionInitWaitTimeout → Duration
How long to wait for connection_init, before closing with TransportWSCloseCode.connectionInitialisationTimeout.
final
done → Future<void>
Completes when the connection has ended.
no setter
hashCode → int
The hash code for this object.
no setterinherited
isAcknowledged → bool
Whether the connection was acknowledged, so operations can run.
no setter
keepAliveInterval → Duration?
How often to send a ping once connected, if at all.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onConnect(Map<String, dynamic>? payload) → FutureOr<bool>
Decides whether to accept a connection, given the payload of its connection_init, such as credentials. Accepts all by default; return false to close it with TransportWSCloseCode.forbidden.
onSubscribe(String id, String query, {Map<String, dynamic>? variables, String? operationName, Map<String, dynamic>? extensions}) → FutureOr<Object?>
Runs the operation id of the subscribe payload: its query, variables, operationName and extensions.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited