Skip to content

Latest commit

 

History

History
29 lines (21 loc) · 805 Bytes

README.md

File metadata and controls

29 lines (21 loc) · 805 Bytes

absinthe_socket_link

Dart library to interact with Absinthe Subscriptions over Phoenix Channels.

This library uses phoenix_socket for Phoenix Channel, making the API consistent across web and native environments.

Usage

This is a simple implementation.

Link createGraphqlLink() async {
  final HttpLink httpLink = HttpLink("http://localhost/graphql");

  final phoenixSocket = PhoenixSocket(
    "ws://localhost/graphql/websocket",
    socketOptions: PhoenixSocketOptions(
      params: {"authorization": 'My Strong Token'},
    ),
  );

  final wsLink = AbsintheSocketLink(phoenixSocket);

  return Link.split(
    (request) => request.isSubscription,
    wsLink, httpLink,
  );
}