v3 (latest)
Features
Plugins

Envelop Plugins

Envelop 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 (opens in a new tab). GraphQL Yoga uses Envelop (opens in a new tab) 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 { createYoga, createSchema } from 'graphql-yoga'
 
// Provide your schema
const yoga = createYoga({
  schema: createSchema({
    typeDefs: /* GraphQL */ `
      type Query {
        greetings: String!
      }
    `,
    resolvers: {
      Query: {
        greetings: () => 'Hello World!'
      }
    }
  }),
  plugins: [useGraphQlJit()]
})
 
// Start the server and explore http://localhost:4000/graphql
const server = createServer(yoga)
server.listen(4000, () => {
  console.info('Server is running on http://localhost:4000/graphql')
})