View Source GraphQLWSClient.Driver behaviour (GraphQL Websocket Client v2.0.2)
A behaviour that defines function to implement custom backends.
Customize Options
To customize the options that are used by the driver, you can set a custom
:driver
tuple when starting the client.
GraphQLWSClient.start_link(
host: "example.com",
driver: {GraphQLWSClient.Drivers.Gun, json_library: Poison},
)
Or you can set it in the configuration for your custom client.
import Config
config :my_app, MyGraphQLWSClient,
driver: {GraphQLWSClient.Drivers.Gun, json_library: Poison}
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.
Callbacks
@callback connect(GraphQLWSClient.Conn.t()) :: {:ok, GraphQLWSClient.Conn.t()} | {:error, Exception.t()}
Connects to the socket and returns the updated GraphQLWSClient.Conn
.
@callback disconnect(GraphQLWSClient.Conn.t()) :: :ok
Disconnects from the socket.
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, Exception.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.