All Projects → enisdenjo → cloudflare-worker-graphql-ws-template

enisdenjo / cloudflare-worker-graphql-ws-template

Licence: MIT License
A template for WebSockets powered Cloudflare Worker project using graphql-ws

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to cloudflare-worker-graphql-ws-template

workers-jwt
Generate JWTs on Cloudflare Workers using the WebCrypto API
Stars: ✭ 67 (+219.05%)
Mutual labels:  workers, cloudflare, cloudflare-workers
cloudflare-worker-router
A super lightweight router (1.3K) with middleware support and ZERO dependencies for CloudFlare Workers.
Stars: ✭ 144 (+585.71%)
Mutual labels:  workers, cloudflare, cloudflare-workers
natural
Fastest Framework for NodeJS. Written in pure ES6+
Stars: ✭ 30 (+42.86%)
Mutual labels:  workers, cloudflare, cloudflare-workers
worker-auth-providers
worker-auth-providers is an open-source providers to make authentication easy with workers. Very lightweight script which doesn't need a lot of dependencies. Plug it with any framework or template of workers.
Stars: ✭ 85 (+304.76%)
Mutual labels:  cloudflare, cloudflare-workers
viteflare
Cloudflare workers meet Vite plugins
Stars: ✭ 35 (+66.67%)
Mutual labels:  workers, cloudflare
inkrss
Notify when rss feeds are updated | RSS 更新通知
Stars: ✭ 234 (+1014.29%)
Mutual labels:  cloudflare, cloudflare-workers
DNS-over-Discord
A 1.1.1.1 DNS resolver built for Discord
Stars: ✭ 228 (+985.71%)
Mutual labels:  cloudflare, cloudflare-workers
miniflare
🔥 Fully-local simulator for Cloudflare Workers
Stars: ✭ 2,811 (+13285.71%)
Mutual labels:  cloudflare, cloudflare-workers
terraform-cloudflare-maintenance
Terraform module to create a responsive Maintenance Page using Cloudflare Workers.
Stars: ✭ 111 (+428.57%)
Mutual labels:  cloudflare, cloudflare-workers
vite-plugin-cloudflare
🔥Building Cloudflare workers is faster and easier using vite-plugin-cloudflare with node builtins like process and stream
Stars: ✭ 108 (+414.29%)
Mutual labels:  workers, cloudflare
cfworker-middware-telegraf
Make telegraf (a telegram bot framework) useable in Cloudflare Workers
Stars: ✭ 23 (+9.52%)
Mutual labels:  cloudflare, cloudflare-workers
slshx
⚔️ Strongly-typed Discord commands on Cloudflare Workers
Stars: ✭ 163 (+676.19%)
Mutual labels:  cloudflare, cloudflare-workers
IPFS PHOTO SHARE
💰用甚嚒服务器,ServerLess搭建一个图片分享站点!| 基于CloudFlareWorker无服务器函数和IPFS去中心化存储的图片分享网站
Stars: ✭ 76 (+261.9%)
Mutual labels:  cloudflare, cloudflare-workers
cfw-easy-utils
An in-depth library to assist with common tasks with CF Workers. Includes utils for responses, cookies, and more!
Stars: ✭ 52 (+147.62%)
Mutual labels:  cloudflare, cloudflare-workers
workers-unsplash-api
Serverless API for requesting images from Unsplash's API, designed for use with a React frontend
Stars: ✭ 20 (-4.76%)
Mutual labels:  cloudflare, cloudflare-workers
telegram-bot-api-worker
Take an alternate route to Telegram Bot API :)
Stars: ✭ 75 (+257.14%)
Mutual labels:  cloudflare, cloudflare-workers
relay-starter-kit
💥 Monorepo template (seed project) pre-configured with GraphQL API, PostgreSQL, React, Relay, Material UI.
Stars: ✭ 3,513 (+16628.57%)
Mutual labels:  cloudflare, cloudflare-workers
html
HTML templating and streaming response library for Service Worker-like environments such as Cloudflare Workers.
Stars: ✭ 41 (+95.24%)
Mutual labels:  workers, cloudflare-workers
cloudflare-worker-rest-api
A cloudflare worker module which helps building REST Api quickly and easily, similar to express framework.
Stars: ✭ 31 (+47.62%)
Mutual labels:  workers, cloudflare
supaflare
URL shortener / redirection service powered by Supabase, Cloudflare Workers, Workers KV and Cloudflare Pages.
Stars: ✭ 51 (+142.86%)
Mutual labels:  cloudflare, cloudflare-workers

🚡 graphql-ws on Cloudflare Workers

A template for WebSockets powered Cloudflare Worker project using graphql-ws.

The worker serves the following routes:

  • "/" renders GraphiQL using only graphql-ws (as showcased here)
  • "/graphql" serves the GraphQL over WebSocket

Getting started

This template is meant to be used with 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. Documentation can be found here.

To generate using Wrangler, run this command:

wrangler generate my-graphql-ws https://github.com/enisdenjo/cloudflare-worker-graphql-ws-template

Gotchas

  • Server WebSocket instance does not contain the protocol property (as ws does) which is why you should pass the Sec-WebSocket-Protocol header to the graphql-ws server

  • Message listener event data property is already a string

  • 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.

  • webpack.config.js is configured to omit the browser entry field in package.jsons since we are bundling for Node workers and not for browsers

    This is especially necessary for graphql-ws since the browser bundle does NOT contain any server code.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].