CF Workers Wrangler GraphQL Yoga template πŸ“¦ πŸš€

Overview

GraphQL Yoga for Cloudflare Workers (Wrangler template)

Fully-featured GraphQL Server with focus on easy setup, performance & great developer experience:

  • Easiest way to run a GraphQL server: Sensible defaults & includes everything you need with minimal setup (we also export a platform/env-agnostic handler so you can build your own wrappers easily).
  • Includes Subscriptions: Built-in support for GraphQL subscriptions using Server-Sent Events.
  • Compatible: Works with all GraphQL clients (Apollo, Relay...) and fits seamless in your GraphQL workflow.
  • WHATWG Fetch API: the core package depends on WHATWG Fetch API so it can run and deploy on any environment (Serverless, Workers, Deno, Node).
  • Easily Extendable: New GraphQL-Yoga support all envelop plugins.

See it in action!


Read the 2.0 announcement blog post

Read the docs

Deploy to Cloudflare Workers

 


 

Getting started

  1. Install and configure wrangler
npm i @cloudflare/wrangler -g

wrangler login
  1. Create a new project with the GraphQL Yoga template
 wrangler generate graphql-yoga-worker https://github.com/the-guild-org/yoga-cloudflare-workers-template
  1. Build and deploy your CF Worker GraphQL API
cd graphql-yoga-worker
wrangler build
wrangler publish

 


 

Project overview

Yoga configuration

GraphQL Yoga comes with defaults for CORS and error handling:

  • CORS are enabled by default
  • Automatically masking unexpected errors and preventing sensitive information leaking to clients.

Yoga also brings support (with no additional dependency) for subscriptions, file uploads and your favourite schema building library (GraphQL Tools, Pothos, Nexus, TypeGraphQL, SDL first schema-design approaches, graphql-js, Apollo Tools).

More information on all available features on the official documentation.

 

Envelop Plugins

GraphQL Yoga is built on top of Envelop. Envelop is a library that helps build GraphQL API faster and flexibly with plugin-based architecture.

Similar to Express middlewares allowing you to customize requests' behavior, Envelop applies the same idea to GraphQL requests.

By exposing hooks in all the phases of a GraphQL Request execution, Envelop enables the creation of plugins that simplify the setup of standard API features such as:

  • Security: Depth limits, Rate limiting
  • Authentication
  • Advanced caching
  • Error handling: Sentry, error masking
  • Monitoring: Hive
  • Logging
  • Tracing: NewRelic, Datadog, StatsD, Apollo Tracing

More information on Envelop documentation.

Note: Some Node.js specific plugins such as useSentry() are supported in Serverless environments

 

Caching

GraphQL Yoga is relying on fetch() WHATWG Fetch API, allowing you to leverage Cloudflare Cache when fetching data from external services.

For more advanced use-cases, please refer to the useResponseCache() Envelop plugins, with a Redis cache (memory cache is not supported on Serverless).

 

Bundle size

GraphQL Yoga bundle is 36% lighter than Apollo Cloudflare Server (Wrangler bundled script comparison), leading is a faster startup and deployment time. ⚑️

 


 

Going futher

 


 

License

This project is licensed with the MIT License.

You might also like...

A URL shortener that runs on Cloudflare Workers

ITP Works A URL shortener that runs on Cloudflare Workers. It stores the rules in Cloudflare KV storage and sends a 301 redirect when a matched pathna

Mar 4, 2022

Google-Drive-Directory-Index | Combining the power of Cloudflare Workers and Google Drive API will allow you to index your Google Drive files on the browser.

🍿 Google-Drive-Directory-Index Combining the power of Cloudflare Workers and Google Drive will allow you to index your Google Drive files on the brow

Jan 2, 2023

Remix + Cloudflare Workers + DO + Turborepo

Remix + Cloudflare Workers + DO + Turborepo A starter to get you up and going with Remix on Cloudflare with all the latest and greatest. What's inside

Dec 12, 2022

Remix + Cloudflare Workers + Wrangler2 + Tailwind + ESLint + Prettier + Vitest + Playwright

Welcome to Remix! Remix Docs Development You will be running two processes during development: The Miniflare server (miniflare is a local environment

Dec 19, 2022

Server-side rendering blog runs on Cloudflare workers

Serverside rendered blog I have tried something completely against to current web trends. What are these? I am using the React as backend framework wi

Jun 24, 2022

A collection of useful tools for building web apps on Cloudflare Workers.

Keywork is a batteries-included, magic-free, library for building web apps on Cloudflare Workers. Features πŸ’ͺ Written in TypeScript πŸ“š Modules Support

Dec 22, 2022

Abusing Cloudflare Workers to establish persistence and exfiltrate sensitive data at the edge.

Abusing Cloudflare Workers This repository contains companion code for the blog post MITM at the Edge: Abusing Cloudflare Workers. malicious-worker/ c

Sep 16, 2022

Lightweight universal Cloudflare API client library for Node.js, Browser, and CF Workers

Cloudflare API Client Lightweight universal HTTP client for Cloudflare API based on Fetch API that works in Node.js, browser, and CF Workers environme

Nov 13, 2022

A Cloudflare Workers service that fetches and renders Notion pages as HTML, Markdown, or JSON.

notion-fetch A Cloudflare Workers service that fetches and renders Notion pages as HTML, Markdown, or JSON. Powered by Durable Objects and R2. Usage P

Jan 6, 2023
Owner
The Guild
A group of open source developers, bringing a different approach for sustainable open source. Our philosophy is to place our libraries under a person's name.
The Guild
Configure Wrangler in the format of your choice.

wjson ✨ Configure Wrangler in the format of your choice. ✨ Installation npm i -D @darkflare/wjson Usage (CLI) Run the below command and wjson will aut

Azury 9 Oct 5, 2022
Configure Wrangler in the format of your choice.

wjson ✨ Configure Wrangler in the format of your choice. ✨ Installation npm i -D @darkflare/wjson Usage (CLI) Run the below command and wjson will aut

darkflare 8 Jul 31, 2022
NextJS with GraphQL using type-graphl and graphql-codegen adoptable dogs example code

This is a Next.js project bootstrapped with create-next-app. Getting Started First, run the development server: npm run dev # or yarn dev Open http://

Jack Herrington 2 Mar 31, 2022
GraphQL-first boilerplate that scales with TypeScript + Node Express + Apollo GraphQL APIs.

graphql-typescript-boilerplate A boilerplate project for quickly building Graphql APIs and with typescript ?? Installation Install the dependencies: y

Youssef Hajjari 6 May 15, 2022
next-graphql-server is a library for building production-grade GraphQL servers using Next.js with API Routes

next-graphql-server next-graphql-server is an easy to use Next.js library for creating performant GraphQL endpoints on top of Next.js API Routes. Star

Jakub Neander 82 Nov 21, 2022
GraphQL Hive provides all the tools the get visibility of your GraphQL architecture at all stages, from standalone APIs to composed schemas (Federation, Stitching)

GraphQL Hive GraphQL Hive provides all the tools the get visibility of your GraphQL architecture at all stages, from standalone APIs to composed schem

Kamil Kisiela 184 Dec 21, 2022
Starting template for building a Remix site with CloudFlare Workers (ES Modules Syntax)

Starting template for building a Remix site with CloudFlare Workers (ES Modules Syntax)

null 12 May 20, 2022
A starter template for Remix + Cloudflare Workers + DO + KV + Turborepo

Remix + Cloudflare Workers starter with Turborepo ?? Starter to get going with Remix and Cloudflare Workers. This template is based on the starter cre

Girish 27 Jan 2, 2023
基于 gh-proxy + Jsdelivr+ cnpmjs + cloudflare workers ηš„ GitHub Serverless API ε·₯具。

better-github-api Better, Eazy, Access Anywhere 介绍 基于 gh-proxy + Jsdelivr + cnpmjs + cloudflare workers ηš„ GitHub Serverless API ε·₯具。 cdn.jsοΌšδ»…ε« gh-proxy

One Studio 11 Nov 23, 2022
Automated packaging of Debian-flavored NGINX with PageSpeed modules. Written in Bash and GitHub Workers. APT Repository hosted on Dokku.

NGINX + Google PageSpeed Configuring NGINX to build correctly is a pain. Not because of anything wrong with it, but rather because of how slim the sta

Slava Knyazev 21 Oct 14, 2022