gql_websocket_link 1.0.1-alpha+1699813671752 gql_websocket_link: ^1.0.1-alpha+1699813671752 copied to clipboard
GQL Websocket Link
GQL WebSocket link to execute subscriptions as well as mutations & queries against a GraphQL backend.
This link support autoReconnect
and will resubscribe after reconnecting.
This package supports both the deprecated graphql-ws
and the graphql-transport-ws
protocol
via the WebSocketLink
and TransportWebSocketLink
classes respectively.
Usage #
WebSocketLink
/ graphql-ws
protocol #
import "package:gql_link/gql_link.dart";
import "package:gql_websocket_link/gql_websocket_link.dart";
void main () {
final link = Link.from([
// SomeLink(),
WebSocketLink("ws://<GRAPHQL_SERVER_ENDPOINT>/graphql"),
]);
}
TransportWebSocketLink
/ graphql-transport-ws
protocol #
import "package:gql_link/gql_link.dart";
import "package:gql_websocket_link/gql_websocket_link.dart";
void main () {
final link = Link.from([
// SomeLink(),
TransportWebSocketLink(
TransportWsClientOptions(
socketMaker: WebSocketMaker.url(() => "ws://<GRAPHQL_SERVER_ENDPOINT>/graphql")
),
),
]);
}
Features and bugs #
Please file feature requests and bugs at the GitHub.
Attribution #
This code was adapted with minor changed from the graphql-flutter
repo