🌐
HTTP300K+/wkMIT

graphql-yoga

GraphQL Yoga is a batteries-included, fully-featured GraphQL server built on top of the Fetch API standard, making it compatible with any JavaScript runtime inc

Installation

npm
npm install graphql-yoga graphql
yarn
yarn add graphql-yoga graphql
pnpm
pnpm add graphql-yoga graphql

Import

ESM
import { createYoga, createSchema } from 'graphql-yoga';

Quick Example

usage
import { createYoga, createSchema } from 'graphql-yoga';
import { createServer } from 'http';

const yoga = createYoga({
  schema: createSchema({
    typeDefs: `type Query { hello: String }`,
    resolvers: { Query: { hello: () => 'Hello' } },
  }),
});

createServer(yoga).listen(4000);

About graphql-yoga

GraphQL Yoga is a batteries-included, fully-featured GraphQL server built on top of the Fetch API standard, making it compatible with any JavaScript runtime including Node.js, Deno, Bun, Cloudflare Workers, and AWS Lambda. Developed by The Guild, GraphQL Yoga provides a simple yet powerful API for building GraphQL servers with sensible defaults that can be customized through an extensible plugin system based on the Envelop plugin framework. The server includes built-in support for file uploads, subscriptions (WebSocket and Server-Sent Events), response caching, CORS configuration, error masking for production, and GraphiQL for interactive query development. GraphQL Yoga integrates seamlessly with popular schema-building tools including Pothos, Nexus, TypeGraphQL, and SDL-first approaches. The plugin system allows adding functionality like authentication, rate limiting, query depth limiting, and APM integration through a composable middleware architecture. GraphQL Yoga handles multipart request parsing for file uploads natively and supports @defer and @stream for incremental delivery. It is positioned as a simpler, more standards-compliant alternative to Apollo Server.

Quick Facts

Packagegraphql-yoga
CategoryHTTP
Weekly Downloads300K+
LicenseMIT
Installnpm install graphql-yoga graphql

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.