GraphQL Yoga
Fully-featured GraphQL Server with focus on easy setup, performance & great developer experience
Go to documenationQuick start
Install
pnpm add graphql-yoga graphql
Start
Make a schema, create Yoga and start a Node server:import { createServer } from 'node:http'
import { createSchema, createYoga } from 'graphql-yoga'
const yoga = createYoga({
schema: createSchema({
typeDefs: /* GraphQL */ `
type Query {
hello: String
}
`,
resolvers: {
Query: {
hello: () => 'Hello from Yoga!'
}
}
})
})
const server = createServer(yoga)
server.listen(4000, () => {
console.info('Server is running on http://localhost:4000/graphql')
})
Overview
- Easiest way to run a GraphQL server: Sensible defaults & includes everything you need with
- Includes Subscriptions: Built-in support for GraphQL subscriptions using
- Compatible: Works with all GraphQL clients
- WHATWG Fetch API: the core package depends on
- Easily Extendable: New GraphQL-Yoga support all
envelop
plugins.
Features
- Fully typed with TypeScript
- GraphQL over HTTP spec compliant
- GraphiQL included
- File uploads with GraphQL Multipart Request spec
- Subscriptions and realtime capabilities
- Automatic persisted queries
- Built-in parsing and validation caching
- Testing utilities
- Supports ESM
- Runs everywhere, including environments like:
Documentation
Our documentation website will help you get started.Examples
We've made sure developers can quickly start with GraphQL Yoga by providing a comprehensive set of examples. See all of them in theexamples/
folder.Comparison
Read more about how GraphQL Yoga compares to other servers in the ecosystem here.Contributing
If this is your first time contributing to this project, please do read our Contributor Workflow Guide before you get started off.For this project in particular, to get started on
stage/2-failing-test
:- Install Node.js
- Run in your terminal:
npm i -g pnpm@8 && pnpm install && pnpm build
- Add tests to
packages/graphql-yoga/__tests__
using Jest APIs - Run the tests with
pnpm test
Feel free to open issues and pull requests. We're always welcome support from the community.