{"id":13553248,"url":"https://github.com/enisdenjo/cloudflare-worker-graphql-ws-template","last_synced_at":"2025-09-24T05:32:00.956Z","repository":{"id":66056045,"uuid":"378902248","full_name":"enisdenjo/cloudflare-worker-graphql-ws-template","owner":"enisdenjo","description":"A template for WebSockets powered Cloudflare Worker project using graphql-ws","archived":false,"fork":false,"pushed_at":"2022-02-21T22:26:08.000Z","size":623,"stargazers_count":39,"open_issues_count":0,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-13T04:10:50.107Z","etag":null,"topics":["cloudflare","cloudflare-workers","graphql","graphql-ws","websockets","workers"],"latest_commit_sha":null,"homepage":"https://graphql-ws.enisdenjo.workers.dev","language":"JavaScript","has_issues":false,"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/enisdenjo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"enisdenjo"}},"created_at":"2021-06-21T11:07:59.000Z","updated_at":"2024-11-21T02:41:12.000Z","dependencies_parsed_at":"2023-03-13T20:30:59.893Z","dependency_job_id":null,"html_url":"https://github.com/enisdenjo/cloudflare-worker-graphql-ws-template","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enisdenjo%2Fcloudflare-worker-graphql-ws-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enisdenjo%2Fcloudflare-worker-graphql-ws-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enisdenjo%2Fcloudflare-worker-graphql-ws-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enisdenjo%2Fcloudflare-worker-graphql-ws-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/enisdenjo","download_url":"https://codeload.github.com/enisdenjo/cloudflare-worker-graphql-ws-template/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234044976,"owners_count":18770889,"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":["cloudflare","cloudflare-workers","graphql","graphql-ws","websockets","workers"],"created_at":"2024-08-01T12:02:20.702Z","updated_at":"2025-09-24T05:31:55.548Z","avatar_url":"https://github.com/enisdenjo.png","language":"JavaScript","funding_links":["https://github.com/sponsors/enisdenjo"],"categories":["JavaScript"],"sub_categories":[],"readme":"# [🚡 `graphql-ws`](https://github.com/enisdenjo/graphql-ws) on [Cloudflare Workers](https://workers.cloudflare.com/)\n\nA template for [WebSockets](https://developers.cloudflare.com/workers/runtime-apis/websockets) powered Cloudflare Worker project using graphql-ws.\n\nThe worker serves the following routes:\n\n- `\"/\"` renders GraphiQL using only `graphql-ws` ([as showcased here](https://gist.github.com/enisdenjo/a68312878fdc4df299cb0433c60c1dea))\n- `\"/graphql\"` serves the GraphQL over WebSocket\n\n## Getting started\n\nThis template is meant to be used with [Wrangler](https://github.com/cloudflare/wrangler). If you are not already familiar with the tool, we recommend that you install the tool and configure it to work with your [Cloudflare account](https://dash.cloudflare.com). Documentation can be found [here](https://developers.cloudflare.com/workers/tooling/wrangler/).\n\nTo generate using Wrangler, run this command:\n\n```bash\nwrangler generate my-graphql-ws https://github.com/enisdenjo/cloudflare-worker-graphql-ws-template\n```\n\n## Gotchas\n\n- Server WebSocket instance does not contain the `protocol` property ([as `ws` does](https://github.com/websockets/ws/blob/145480a5b520ee951d848009d51069bfd7ed928c/lib/websocket.js#L115-L120)) which is why you should pass the `Sec-WebSocket-Protocol` header to the `graphql-ws` server\n- Message listener event `data` property is already a string\n- If the client does not support the `\"graphql-transport-ws\"` subprotocol, the `Sec-WebSocket-Protocol` header will be omitted. This causes Chrome to abruptly terminate the connection with a `1006` close event code.\n- `webpack.config.js` is configured to omit the `browser` entry field in `package.json`s since we are bundling for Node workers and not for browsers\n\n  _This is especially necessary for `graphql-ws` since the `browser` bundle does NOT contain any server code._\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenisdenjo%2Fcloudflare-worker-graphql-ws-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fenisdenjo%2Fcloudflare-worker-graphql-ws-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenisdenjo%2Fcloudflare-worker-graphql-ws-template/lists"}