SubscriptionsTransportWS.OperationMessage (SubscriptionsTransportWS v1.0.0) View Source

Struct to contain the protocol messages.

See https://github.com/apollographql/subscriptions-transport-ws/blob/master/PROTOCOL.md for more details on their contents

Link to this section Summary

Functions

Prepare message for transport, removing any keys with nil values.

Build OperationMessage from incoming map

Link to this section Types

Specs

t() :: %SubscriptionsTransportWS.OperationMessage{
  id: String.t(),
  payload: any(),
  type: String.t()
}

Link to this section Functions

Prepare message for transport, removing any keys with nil values.

iex> %OperationMessage{type: "complete", id: "1"} |> OperationMessage.as_json
%{id: "1", type: "complete"}

Build OperationMessage from incoming map

iex> %{"type" => "connection_init"} |> OperationMessage.from_map
%OperationMessage{id: nil, type: "connection_init", payload: nil}