GraphQLWsClient.withoutJson constructor
GraphQLWsClient.withoutJson(
- StreamChannel<
Map> channel
Wraps a channel that already decodes JSON into maps.
Implementation
GraphQLWsClient.withoutJson(this.channel) {
_ctrl.local.stream
.map((m) => m.toJson())
.cast<Map>()
.forEach(channel.sink.add);
channel.stream.listen((m) {
// A frame the protocol cannot read travels as a stream error rather than
// as an exception nobody catches, so that the server closes with the
// code the protocol names instead of losing the connection.
try {
_ctrl.local.sink.add(GraphQLWsMessage.fromJson(m));
} catch (e) {
_ctrl.local.sink.addError(e);
}
});
}