zox-graphql-ws
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

Frontend WeSocket interface for Zox.js GraphQL endpoint

Connect using a single line of code.
WeSocket will auto-reconnect if connection breaks.

const gql = new GraphQLWebSocket();
const gql = new GraphQLWebSocket('ws://localhost:8080/graphql');

Subscribe to any number of event feeds.

var sid = gql.subscribe({id:'subscription-id'}, event => console.log(event));

Unsubscribe using the returned subscription id.

gql.unsubscribe(sid);

Execute Queries and Mutations over the same connection.

gql.query({id:'query-id'}, event => console.log(event));
const event = gql.queryAsync({id:'query-id'});

Options:

query: Send raw GraphQL Query
id: Execute a predefined Query by it's ID
op: Operation name - used when the Query contains multiple operations
vars: Variables

Readme

Keywords

Package Sidebar

Install

npm i zox-graphql-ws

Weekly Downloads

4

Version

1.0.3

License

MIT

Unpacked Size

14.1 kB

Total Files

11

Last publish

Collaborators

  • zoranravic