GraphQLWsMessage.fromJson constructor
GraphQLWsMessage.fromJson(
- Map map
Reads a message off the wire.
Throws FormatException for a missing or non-string type, and for an
id that is not a string. Unlike the older protocol, an id is a string
and nothing else.
Implementation
factory GraphQLWsMessage.fromJson(Map map) {
final type = map['type'];
final id = map['id'];
if (type is! String) {
throw FormatException('"type" is required and must be a string.');
}
if (id != null && id is! String) {
throw FormatException('"id" must be a string.');
}
return GraphQLWsMessage(type, id: id as String?, payload: map['payload']);
}