Catch the highlights of GraphQLConf 2023!Click for recordings.Or check out our recap blog post.
Quick Start
This is the documentation for the old GraphQL Yoga version 2. We recommend upgrading to the latest GraphQL Yoga version 5.

Migrate to GraphQL Yoga v5

Quick Start

GraphQL Yoga is a batteries-included cross-platform GraphQL over HTTP (opens in a new tab) spec-compliant GraphQL Server using Envelop (opens in a new tab), and GraphQL Tools (opens in a new tab) that runs anywhere.


yarn add @graphql-yoga/node graphql


You will need to provide a schema to Yoga, either by an existing executable schema or by providing your type definitions and resolver map.

import { createServer } from '@graphql-yoga/node'
const server = createServer({
  schema: {
    typeDefs: /* GraphQL */ `
      type Query {
        hello: String
    resolvers: {
      Query: {
        hello: () => 'Hello from Yoga!'

Yoga uses GraphQL Tools under the hood so you'll want to follow the makeExecutableSchema (opens in a new tab) pattern.

That is it!

Now visit http://localhost:4000/graphql (opens in a new tab) to execute the following query operation:

query HelloWorld {

Using Existing Schema

You can also pass an existing GraphQLSchema instance to createServer.

If you're using a library such as Pothos (opens in a new tab), GraphQL Nexus (opens in a new tab), gqtx (opens in a new tab), or vanilla graphql-js (opens in a new tab), you simply can pass the GraphQLSchema to schema:

import { createServer } from '@graphql-yoga/node'
import { schema } from './schema'
const server = createServer({ schema })