graphql-socketio-subscriptions-transport

1.0.7 • Public • Published

graphql-socketio-subscriptions-transport

Remake of subscriptions-transport-socketio which is a remake of subscriptions-transport-ws

Client

Constructor(ref)

Methods

subscribe(options, handler) => id

  • options
    • query : GraphQL subscription
    • variables : GraphQL subscription variables
    • operationName : operation name of the subscription
  • handler: (errors, result) => void : function to handle any errors and results from the subscription response

unsubscribe(id) => void

  • id : the subscription ID of the subscription to unsubscribe fro

Server

Constructor(options, ref)

Client-server messages

Each message has a type, as well as associated fields depending on the message type.

Client -> Server

SUBSCRIPTION_START

Client sends this message to start a subscription for a query.

  • query : GraphQL subscription
  • variables : GraphQL subscription variables
  • operationName : operation name of the subscription
  • id : subscription ID

SUBSCRIPTION_END

Client sends this message to end a subscription.

  • id : subscription ID of the subscription to be terminated

Server -> Client

SUBSCRIPTION_SUCCESS

The server sends this message to confirm that it has validated the subscription query and is subscribed to the triggers.

  • id : ID of the subscription that was successfully set up

SUBSCRIPTION_FAIL

Server sends this message upon failing to register a subscription. It may also send this message at any point during the subscription to notify the client the the subscription has been stopped.

  • errors : array of errors attributed to the subscription failing on the server
  • id : subscription ID of the subscription that failed on the server

SUBSCRIPTION_DATA

GraphQL result sent periodically from server to client according to subscription.

  • payload : GraphQL result from running the subscription
  • id : subscription ID

Package Sidebar

Install

npm i graphql-socketio-subscriptions-transport

Weekly Downloads

8

Version

1.0.7

License

MIT

Last publish

Collaborators

  • redcatjs