Catch the highlights of GraphQLConf 2023!Click for recordings.Or check out our recap blog post.
v2
Features
Envelop Plugins
⚠️
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

Envelop Plugins

Envelop (opens in a new tab) is a lightweight JavaScript (TypeScript) library for customizing the GraphQL execution layer, allowing developers to build, share and compose plugins that enhance the capabilities of your GraphQL server. GraphQL Yoga uses Envelop under the hood, so you can easily extend your server's capabilities with the plugins from Envelop Ecosystem (opens in a new tab)

Example

The following example adds GraphQL JIT (opens in a new tab) to our GraphQL Server using Envelop GraphQL JIT Plugin (opens in a new tab):

import { useGraphQlJit } from '@envelop/graphql-jit'
import { createServer } from '@graphql-yoga/node'
 
// Provide your schema
const server = createServer({
  schema: {
    typeDefs: /* GraphQL */ `
      type Query {
        greetings: String!
      }
    `,
    resolvers: {
      Query: {
        greetings: () => 'Hello World!'
      }
    }
  },
  plugins: [useGraphQlJit()]
})
 
// Start the server and explore http://localhost:4000/graphql
server.start()