Skip to content

GraphQL Yoga

GraphQL Yoga is a batteries-included cross-platform, spec-compliant GraphQL server, that runs anywhere. Yoga is focused on easy setup, performance and great developer experience.

→ Website

→ Repository

→ Docs

Installation

sh
$ npm i graphql-yoga
$ npm i graphql-yoga
sh
$ pnpm add graphql-yoga
$ pnpm add graphql-yoga
sh
$ yarn add graphql-yoga
$ yarn add graphql-yoga
sh
$ bun i graphql-yoga
$ bun i graphql-yoga

Serving Garph schema

ts
import { g, InferResolvers, buildSchema } from 'garph'
import { createYoga, YogaInitialContext } from 'graphql-yoga'

const queryType = g.type('Query', {
  greet: g.string()
})

const resolvers: InferResolvers<{ Query: typeof queryType }, { context: YogaInitialContext }> = {
  Query: {
    greet: () => `Hello, World!`
  }
}

const schema = buildSchema({ g, resolvers })
const yoga = createYoga({ schema })
import { g, InferResolvers, buildSchema } from 'garph'
import { createYoga, YogaInitialContext } from 'graphql-yoga'

const queryType = g.type('Query', {
  greet: g.string()
})

const resolvers: InferResolvers<{ Query: typeof queryType }, { context: YogaInitialContext }> = {
  Query: {
    greet: () => `Hello, World!`
  }
}

const schema = buildSchema({ g, resolvers })
const yoga = createYoga({ schema })

Types

  • Context: YogaInitialContext