View Source GraphQLWSClient.Driver behaviour (GraphQL-over-Websocket Client v0.1.1)

A behaviour that defines function to implement custom backends.

Link to this section Summary

Callbacks

Connects to the socket and returns the updated GraphQLWSClient.Conn.

Disconnects from the socket.

Optional callback that prepares the :opts stored in the GraphQLWSClient.Conn. Can be used to set default values.

Parses a message received from the socket.

Pushes a message to the socket.

Link to this section Callbacks

@callback connect(GraphQLWSClient.Conn.t()) ::
  {:ok, GraphQLWSClient.Conn.t()} | {:error, GraphQLWSClient.SocketError.t()}

Connects to the socket and returns the updated GraphQLWSClient.Conn.

@callback disconnect(GraphQLWSClient.Conn.t()) :: :ok

Disconnects from the socket.

@callback init(opts :: map()) :: any()

Optional callback that prepares the :opts stored in the GraphQLWSClient.Conn. Can be used to set default values.

@callback parse_message(GraphQLWSClient.Conn.t(), msg :: any()) ::
  {:ok, GraphQLWSClient.Message.t()}
  | {:error, GraphQLWSClient.SocketError.t()}
  | :ignore
  | :disconnect

Parses a message received from the socket.

@callback push_message(GraphQLWSClient.Conn.t(), msg :: GraphQLWSClient.Message.t()) ::
  :ok

Pushes a message to the socket.