$ show graphql-hive/graphql-yoga
GraphQL Yoga is a production-ready GraphQL server framework built on the Web Fetch API, designed to run on Node.js, Deno, Bun, Cloudflare Workers, and other serverless platforms. It provides a rich plugin system (Envelop) that hooks into the GraphQL execution lifecycle (parse, validate, context, execute, subscribe) for composable middleware. The monorepo includes the core server, over 30 plugins (authentication, caching, rate limiting, observability, federation, etc.), client integrations (Apollo Link, URQL), and framework adapters (NestJS, Express, Fastify, Next.js, SvelteKit, etc.). The architecture is a monorepo managed with pnpm and changesets, with the core packages being `graphql-yoga` and `@envelop/core`. Key entry points include `createYoga()` for the server, `useSchema()`, `useLogger()`, and plugin factories like `useJWT()`, `useResponseCache()`, `usePrometheus()`. Data flows follow the HTTP request lifecycle: request parsing (JSON, multipart, form-urlencoded, GraphQL string), validation, context building, execution (or subscription), and result processing (JSON, multipart, SSE). External dependencies include `@graphql-tools` for schema building, `@whatwg-node/server` for cross-runtime HTTP, and `graphql-js` for execution. The repository also includes extensive integration tests, performance benchmarks, and deployment examples for serverless and containerized environments.
The LLM identified 5 files worth highlighting for reuse:
Core plugin orchestration that composes Envelop hooks (onParse, onValidate, onExecute, onSubscribe, etc.) into a pipeline. Demonstrates a clean, composable middleware pattern for GraphQL lifecycle. Reusable as a generic middleware system for any GraphQL server.
Typed pub/sub utility with configurable buffer (Repeater) supporting Fixed, Sliding, and Dropping strategies. Self-contained and reusable for any event-driven system, not just GraphQL. Demonstrates clean async iterator design.
Response cache plugin with entity-based invalidation, TTL per schema coordinate, session scoping, and pluggable cache backends (in-memory, Redis, Cloudflare KV). Demonstrates advanced caching patterns for GraphQL responses, including support for streaming and deferred queries.
JWT authentication plugin with multiple signing key providers (inline, remote JWKS), token extraction from headers/cookies/connection params, and role-based access via directives. Reusable auth pattern that can be extracted and adapted for any GraphQL server.
Testing utilities for Envelop plugins: `createTestkit`, `createSpiedPlugin`, `assertSingleExecutionValue`, `assertStreamExecutionValue`, `collectAsyncIteratorValues`. Provides a clean, reusable pattern for unit testing GraphQL plugins without a full server setup.