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

Migrate to GraphQL Yoga v5


An HTTP cookie is a small piece of data that holds an information to let the server recognize the client. You can learn more about the cookies here (opens in a new tab).

There is a whatwg-node plugin to handle cookies using the web standard CookieStore (opens in a new tab). So it allows you to get cookies from the client's request and set cookies back to the client in the response

You can learn more about the CookieStore API here in the MDN documentation (opens in a new tab).


yarn add @whatwg-node/server-plugin-cookies


import { createYoga, createSchema } from 'graphql-yoga'
import { useCookies } from '@whatwg-node/server-plugin-cookies'
const yoga = createYoga({
  schema: createSchema({
    typeDefs: /* GraphQL */ `
      type Query {
        cookie(name: String): String
      type Mutation {
        setCookie(name: String, value: String): String
    resolvers: {
      Query: {
        async cookie(root, args, ctx: YogaInitialContext) {
          const cookie = await ctx.request.cookieStore?.get(
          return cookie?.value
      Mutation: {
        async setCookie(root, args, ctx: YogaInitialContext) {
          await ctx.request.cookieStore?.set(, args.value)
          return args.value
  plugins: [useCookies()]
const server = createServer(yoga)
server.listen(4000, () => {
  console.log('Server is running on http://localhost:4000')