{"id":49461,"library":"subscriptions-transport-ws-envelop","title":"subscriptions-transport-ws","description":"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.","status":"maintenance","version":"2.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/PabloSzx/subscriptions-transport-ws","tags":["javascript","typescript"],"install":[{"cmd":"npm install subscriptions-transport-ws-envelop","lang":"bash","label":"npm"},{"cmd":"yarn add subscriptions-transport-ws-envelop","lang":"bash","label":"yarn"},{"cmd":"pnpm add subscriptions-transport-ws-envelop","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; required for building and executing GraphQL schemas and operations.","package":"graphql","optional":false},{"reason":"Peer dependency; the underlying WebSocket library used for server and client connections.","package":"ws","optional":false}],"imports":[{"note":"Package supports CommonJS requires but TypeScript types are only available via ESM import. Requires peer dependencies `graphql` and `ws`.","wrong":"const { SubscriptionServer } = require('subscriptions-transport-ws');","symbol":"SubscriptionServer","correct":"import { SubscriptionServer } from 'subscriptions-transport-ws'"},{"note":"SubscriptionClient is a named export, not default. CommonJS pattern still works: const { SubscriptionClient } = require('subscriptions-transport-ws');","wrong":"import SubscriptionClient from 'subscriptions-transport-ws';","symbol":"SubscriptionClient","correct":"import { SubscriptionClient } from 'subscriptions-transport-ws'"},{"note":"Case-sensitive; remember the capital 'G', 'Q', 'L' after 'Graph'.","wrong":"import { addGraphqlSubscriptions } from 'subscriptions-transport-ws';","symbol":"addGraphQLSubscriptions","correct":"import { addGraphQLSubscriptions } from 'subscriptions-transport-ws'"}],"quickstart":{"code":"import { createServer } from 'http';\nimport { SubscriptionServer } from 'subscriptions-transport-ws';\nimport { execute, subscribe } from 'graphql';\nimport { schema } from './my-schema';\n\nconst WS_PORT = 5000;\nconst websocketServer = createServer((_req, res) => {\n  res.writeHead(404);\n  res.end();\n});\n\nwebsocketServer.listen(WS_PORT, () => {\n  console.log(`WebSocket Server running on http://localhost:${WS_PORT}`);\n});\n\nSubscriptionServer.create(\n  { schema, execute, subscribe },\n  { server: websocketServer, path: '/graphql' }\n);","lang":"typescript","description":"Sets up a WebSocket server using SubscriptionServer with a GraphQL schema, execute, and subscribe functions from graphql-js."},"warnings":[{"fix":"Replace the package with graphql-ws and follow its migration guide (https://github.com/enisdenjo/graphql-ws/blob/master/MIGRATION.md).","message":"This package is not actively maintained. Please migrate to graphql-ws.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Ensure both client and server use the same transport library. Prefer migrating to graphql-ws for future compatibility.","message":"Incompatible 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.","severity":"breaking","affected_versions":">=0.0.1"},{"fix":"Migrate to @apollo/client and use ApolloLink.from([...]) with a WebSocketLink from graphql-ws.","message":"When using SubscriptionClient with Apollo Client, the networkInterface option has been deprecated in Apollo Client 3.x. Use `ApolloLink` with `WebSocketLink` instead.","severity":"gotcha","affected_versions":">=0.7.0"}],"env_vars":null,"search_vec":"'2.0.2':16 'activ':29 'alway':96 'apollo':68 'avoid':104 'caveat':95 'client':41 'client-sid':40 'client/server':69 'common':65 'consid':97 'critic':94 'current':14 'depend':62 'develop':21 'ecosystem':76 'graphql':9,44,51,57,75,83,90,101 'graphql-w':50,82,100 'implement':87 'incompat':106 'integr':72 'javascript':111 'lack':108 'legaci':49 'librari':85 'maintain':30 'mainten':19 'migrat':98 'mode':20 'mutat':13 'new':89 'packag':26,55 'peer':61 'project':78 'protocol':53,105 'provid':32 'queri':11 'requir':56 'server':36 'server-sid':35 'side':37,42 'specif':93 'stall':23 'subscript':2,10 'subscriptioncli':39 'subscriptions-transport-w':1 'subscriptionserv':34 'supersed':80 'transport':3,7 'typescript':112 'updat':110 'use':47,66 'version':15 'websocket':6,46,92 'ws':4,52,59,84,102","created_at":"2026-06-07T17:01:53.831653+00:00","updated_at":"2026-06-07T17:01:53.831653+00:00","problems":[{"fix":"Run npm install subscriptions-transport-ws or yarn add subscriptions-transport-ws.","cause":"Package not installed or missing from node_modules.","error":"Module not found: Error: Can't resolve 'subscriptions-transport-ws'"},{"fix":"Use named import: import { SubscriptionServer } from 'subscriptions-transport-ws'.","cause":"Importing incorrectly (e.g., default import instead of named import).","error":"TypeError: SubscriptionServer.create is not a function"},{"fix":"Install ws: npm install ws","cause":"Peer dependency 'ws' not installed.","error":"'ws' is not a peer dependency but required at runtime"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/PabloSzx/subscriptions-transport-ws#readme","github":"https://github.com/PabloSzx/subscriptions-transport-ws","docs":null,"changelog":null,"pypi":null,"npm":"subscriptions-transport-ws-envelop","openapi_spec":null,"status_page":null,"smithery":null,"categories":["messaging"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}