{"id":17592959,"url":"https://github.com/kesne/subscriptions-transport-uws","last_synced_at":"2025-04-30T03:44:14.073Z","repository":{"id":57373994,"uuid":"75339574","full_name":"kesne/subscriptions-transport-uws","owner":"kesne","description":"🔃 A WebSocket client + server for GraphQL subscriptions (based on µWS)","archived":false,"fork":false,"pushed_at":"2017-07-31T23:32:46.000Z","size":14,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-30T03:44:08.058Z","etag":null,"topics":["graphql-subscriptions","subscriptions-transport-uws"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kesne.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-01T22:47:01.000Z","updated_at":"2017-08-28T15:30:45.000Z","dependencies_parsed_at":"2022-09-17T16:00:55.514Z","dependency_job_id":null,"html_url":"https://github.com/kesne/subscriptions-transport-uws","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kesne%2Fsubscriptions-transport-uws","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kesne%2Fsubscriptions-transport-uws/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kesne%2Fsubscriptions-transport-uws/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kesne%2Fsubscriptions-transport-uws/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kesne","download_url":"https://codeload.github.com/kesne/subscriptions-transport-uws/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251638750,"owners_count":21619661,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graphql-subscriptions","subscriptions-transport-uws"],"created_at":"2024-10-22T05:44:21.755Z","updated_at":"2025-04-30T03:44:14.054Z","avatar_url":"https://github.com/kesne.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# subscriptions-transport-uws\n\nA GraphQL websocket server and client to facilitate GraphQL subscriptions. Based on [subscriptions-transport-ws](https://github.com/apollostack/subscriptions-transport-ws), built on [µWS](https://github.com/uWebSockets/uWebSockets).\n\n## Importing\n\nImporting the client and the server modules are done separately from the `lib/` directory.\n\n```js\nimport Client from 'subscriptions-transport-uws/lib/Client';\nimport Server from 'subscriptions-transport-uws/lib/Server';\n```\n\nImporting the main module is not supported and will throw an error.\n\n## Client\n### `Constructor(url, options)`\n- `url: string` : url that the client will connect to\n- `options?: Object` : optional object to modify default client behavior\n  * `timeout: number` : how long the client should wait in ms for a subscription to be started (default 5000 ms)\n\n### Methods\n#### `subscribe(options, handler) =\u003e id`\n- `options: {SubscriptionOptions}`\n  * `query: string` : GraphQL subscription\n  * `variables: Object` : GraphQL subscription variables\n  * `operationName: string` : operation name of the subscription\n- `handler: (errors: Error[], result?: any) =\u003e void` : function to handle any errors and results from the subscription response\n\n#### `unsubscribe(id) =\u003e void`\n- `id: string` : the subscription ID of the subscription to unsubscribe from\n\n## Server\n### `Constructor(options, httpServer)`\n- `options: {ServerOptions}`\n  * `subscriptionManager: SubscriptionManager` : GraphQL subscription manager\n  * `onSubscribe?: (message: SubscribeMessage, params: SubscriptionOptions, webSocketRequest: WebSocketRequest)` : optional method to create custom params that will be used when resolving this subscription\n  * `keepAlive?: number` : optional interval in ms to send `SUBSCRIPTION_KEEPALIVE` messages to all clients\n\n## Client-server messages\nEach message has a type, as well as associated fields depending on the message type.\n### Client -\u003e Server\n#### SUBSCRIPTION_START\nClient sends this message to start a subscription for a query.\n- `query: GraphQLDocument` :  GraphQL subscription\n- `variables: Object` : GraphQL subscription variables\n- `operationName: string` : operation name of the subscription\n- `id: string` : subscription ID\n\n#### SUBSCRIPTION_END\nClient sends this message to end a subscription.\n- `id: string` : subscription ID of the subscription to be terminated\n\n### Server -\u003e Client\n#### SUBSCRIPTION_SUCCESS\nThe server sends this message to confirm that it has validated the subscription query and\nis subscribed to the triggers.\n- `id: string` : ID of the subscription that was successfully set up\n\n#### SUBSCRIPTION_FAIL\nServer sends this message upon failing to register a subscription. It may also send this message\nat any point during the subscription to notify the client the the subscription has been stopped.\n- `errors: Array\u003cObject\u003e` : array of errors attributed to the subscription failing on the server\n- `id: string` : subscription ID of the subscription that failed on the server\n\n#### SUBSCRIPTION_DATA\nGraphQL result sent periodically from server to client according to subscription.\n- `payload: GraphQLResult` : GraphQL result from running the subscription\n- `id: string` : subscription ID\n\n#### SUBSCRIPTION_KEEPALIVE\nServer message sent periodically to keep the client connection alive.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkesne%2Fsubscriptions-transport-uws","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkesne%2Fsubscriptions-transport-uws","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkesne%2Fsubscriptions-transport-uws/lists"}