GraphQL Yoga v4 documentation (superseded by v5): Batteries-included GraphQL Server with focus on easy setup, performance & great developer experience
GraphQL Yoga is a batteries-included cross-platform
GraphQL over HTTP spec-compliant
GraphQL server powered by Envelop and
GraphQL Tools that runs anywhere; focused on easy setup, performance
and great developer experience.
Installation
npm i graphql-yoga graphql
yarn add graphql-yoga graphql
pnpm add graphql-yoga graphql
bun add graphql-yoga graphql
Schema
You will need to provide a schema to Yoga, there are many ways to assemble a GraphQL schema, here’s
just a few:
After you have created a GraphQL schema, simply pass it in to Yoga and liftoff! 🚀
import { createServer } from 'node:http'import { createYoga } from 'graphql-yoga'import { schema } from './schema'// Create a Yoga instance with a GraphQL schema.const yoga = createYoga({ schema })// Pass it into a server to hook into request handlers.const server = createServer(yoga)// Start the server and you're done!server.listen(4000, () => { console.info('Server is running on http://localhost:4000/graphql')})