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.
Read the 2.0 announcement blog post
- Install and configure wrangler
npm i @cloudflare/wrangler -g
wrangler login
- Create a new project with the GraphQL Yoga template
wrangler generate graphql-yoga-worker https://github.com/the-guild-org/yoga-cloudflare-workers-template
- Build and deploy your CF Worker GraphQL API
cd graphql-yoga-worker
wrangler build
wrangler publish
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.
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
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).
GraphQL Yoga bundle is 36% lighter than Apollo Cloudflare Server (Wrangler bundled script comparison), leading is a faster startup and deployment time. ⚡️
This project is licensed with the MIT License.