1.0.0-beta.6
The WebSocket graphql-transport-ws sub-protocol implementation
Attributes
Includes Deno configuration
Repository
Current version released
2 years ago
Dependencies
esm.sh
graphql-transport-ws
The WebSocket graphql-transport-ws sub-protocol implementation.
Usage
createGraphQLTransportWs
- Create API that handles sending and receiving messages for thegraphql-transport-ws
sub-protocol.createClient
- Create client-sidegraphql-transport-ws
sub-protocol compliant API.createServer
- Create server-sidegraphql-transport-ws
sub-protocol compliant API.
Ping and Pong
import { createGraphQLTransportWs } from "https://deno.land/x/graphql_transport_ws@$VERSION/mod.ts";
const graphqlTransportWs = createGraphQLTransportWs("<ENDPOINT>");
graphqlTransportWs.addEventListener("pong", (ev) => {
console.log(ev.data);
});
graphqlTransportWs.ping();
graphqlTransportWs.addEventListener("ping", () => {
graphqlTransportWs.pong();
});
Subscribe subscription
import { createGraphQLTransportWs } from "https://deno.land/x/graphql_transport_ws@$VERSION/mod.ts";
const graphqlTransportWs = createGraphQLTransportWs("<ENDPOINT>");
graphqlTransportWs.addEventListener("connectionack", (ev) => {
console.log(ev.data);
});
graphqlTransportWs.addEventListener("next", (ev) => {
console.log(ev.data.id, ev.data.payload);
});
graphqlTransportWs.connectionInit();
graphqlTransportWs.subscribe({
query: `subscription { hello }`,
});
License
Copyright © 2022-present TomokiMiyauci.
Released under the MIT license
graphql-transport-ws
: enisdenjo