Registry / messaging / subscriptions-transport-ws-envelop

subscriptions-transport-ws-envelop

JSON →
library2.0.2jsnpmunverified

A WebSocket transport for GraphQL subscriptions, queries, and mutations. Current version 2.0.2 is in maintenance mode; development is stalled and the package is not actively maintained. It provides a SubscriptionServer (server-side) and SubscriptionClient (client-side) for GraphQL over WebSocket, using the legacy graphql-ws protocol. The package requires graphql and ws as peer dependencies. It is commonly used with Apollo Client/Server but can integrate with any GraphQL ecosystem. The project is superseded by graphql-ws (library), which implements the new GraphQL over WebSocket specification. Critical caveat: always consider migrating to graphql-ws to avoid protocol incompatibilities and lack of updates.

npm install subscriptions-transport-ws-envelop
INSTALL
IMPORT
SIG · SUBSCRIPTIONS-TRAN
S
subscriptions-transport-ws-envelop
messagingjavascriptv2.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SubscriptionServer
import { SubscriptionServer } from 'subscriptions-transport-ws'
const { SubscriptionServer } = require('subscriptions-transport-ws');
Package supports CommonJS requires but TypeScript types are only available via ESM import. Requires peer dependencies `graphql` and `ws`.
SubscriptionClient
import { SubscriptionClient } from 'subscriptions-transport-ws'
import SubscriptionClient from 'subscriptions-transport-ws';
SubscriptionClient is a named export, not default. CommonJS pattern still works: const { SubscriptionClient } = require('subscriptions-transport-ws');
addGraphQLSubscriptions
import { addGraphQLSubscriptions } from 'subscriptions-transport-ws'
import { addGraphqlSubscriptions } from 'subscriptions-transport-ws';
Case-sensitive; remember the capital 'G', 'Q', 'L' after 'Graph'.

Sets up a WebSocket server using SubscriptionServer with a GraphQL schema, execute, and subscribe functions from graphql-js.

import { createServer } from 'http'; import { SubscriptionServer } from 'subscriptions-transport-ws'; import { execute, subscribe } from 'graphql'; import { schema } from './my-schema'; const WS_PORT = 5000; const websocketServer = createServer((_req, res) => { res.writeHead(404); res.end(); }); websocketServer.listen(WS_PORT, () => { console.log(`WebSocket Server running on http://localhost:${WS_PORT}`); }); SubscriptionServer.create( { schema, execute, subscribe }, { server: websocketServer, path: '/graphql' } );
Debug
Known issues
deprecatedThis package is not actively maintained. Please migrate to graphql-ws.
fix
Replace the package with graphql-ws and follow its migration guide (https://github.com/enisdenjo/graphql-ws/blob/master/MIGRATION.md).
affects: >=1.0.0
breakingIncompatible protocol with newer graphql-ws. Clients using the legacy protocol (subscriptions-transport-ws) cannot connect to servers that implement the new GraphQL over WebSocket spec (graphql-ws) and vice versa.
fix
Ensure both client and server use the same transport library. Prefer migrating to graphql-ws for future compatibility.
affects: >=0.0.1
gotchaWhen using SubscriptionClient with Apollo Client, the networkInterface option has been deprecated in Apollo Client 3.x. Use `ApolloLink` with `WebSocketLink` instead.
fix
Migrate to @apollo/client and use ApolloLink.from([...]) with a WebSocketLink from graphql-ws.
affects: >=0.7.0
Errors
Common errors & fixes
Module not found: Error: Can't resolve 'subscriptions-transport-ws'
Package not installed or missing from node_modules.
fix
Run npm install subscriptions-transport-ws or yarn add subscriptions-transport-ws.
TypeError: SubscriptionServer.create is not a function
Importing incorrectly (e.g., default import instead of named import).
fix
Use named import: import { SubscriptionServer } from 'subscriptions-transport-ws'.
'ws' is not a peer dependency but required at runtime
Peer dependency 'ws' not installed.
fix
Install ws: npm install ws
Upgrade
Version history
2.0.2latest on npm
Audit
Dependencies
graphqlrequiredPeer dependency; required for building and executing GraphQL schemas and operations.
wsrequiredPeer dependency; the underlying WebSocket library used for server and client connections.
Agent activity
18 hits · last 30 days
node
14
OpenAI (training)
2
Amazon
1
Resources
subscriptions-transport-ws-envelop — npm install subscriptions-transport-ws-envelop · libregistry