Packages

graphql-yoga

6.1.0 · 12 Nov 2026MIT3.3M / weekRepositoryHomepagenpmAtom feed

Your version

6.0.0

major22 Oct 2026Where it was published

6.1.0 is the newest release of 6.x.

In short

20 breaking1 fixed4 changed8 internal

Release note

Major Changes

  • Breaking

    #4575
    862447a
    Thanks @egoodwinx! - Use
    @graphql-hive/logger and add correlated, per-request
    logging (closes #4048)

    Every request now gets its own logger, available as context.log (and serverContext.log in
    plugin hooks), tagged with a requestId. Everything logged while handling a request can be
    correlated by that id.

    The request id is taken from the host integration if it already assigned one (e.g. Fastify's
    request.id), otherwise from the incoming x-request-id header, otherwise generated. It is also
    sent back in the x-request-id response header. Configure it with the new requestId option:

    createYoga({
      requestId: {
        // don't trust the incoming header, recommended when clients can reach the server directly
        trustHeader: false,
        headerName: 'x-correlation-id',
        generateRequestId: () => myId()
      }
    })

    Pass requestId: false to disable it.

    At the info level, a single "Request processed" line is logged per request with the method,
    path, operation name and type, response status, error count and duration. At the debug level,
    more details about request processing are logged.

    Masked errors are now logged with the request's logger, so they can be traced back to the request
    that caused them. Custom maskError functions receive the request's context as an optional fourth
    argument.

    The @envelop/newrelic, @envelop/auth0, @envelop/resource-limitations, @envelop/statsd,
    @envelop/graphql-jit, @envelop/response-cache and @envelop/response-cache-cloudflare-kv
    plugins accept a new log option for their own messages, instead of always writing to the
    console.

    @envelop/response-cache's shouldCacheResult now also receives the GraphQL context.

Breaking Changes

Migration

Create loggers with Logger:

- import { createLogger } from 'graphql-yoga';
+ import { Logger } from 'graphql-yoga';

  createYoga({
-   logging: createLogger('debug'),
+   logging: new Logger({ level: 'debug' }),
  });

Use log instead of logger on the Yoga instance:

  const plugin = {
    onYogaInit({ yoga }) {
-     yoga.logger.info('ready');
+     yoga.log.info('ready');
    },
  };

Prefer the request-scoped logger inside resolvers and plugin hooks so the logs carry the request
id:

const resolvers = {
  Query: {
    hello: (_, __, context) => {
      context.log.debug('resolving hello')
      return 'world'
    }
  }
}

If you use any of the @envelop/* plugins listed above, install the logger:

npm i @graphql-hive/logger

If you depended on @graphql-yoga/logger directly, switch to @graphql-hive/logger:

- import { Logger } from '@graphql-yoga/logger';
+ import { Logger } from '@graphql-hive/logger';

To keep logging through Fastify's logger in @graphql-yoga/nestjs:

import { Logger } from 'graphql-yoga'
import { PinoLogWriter } from '@graphql-hive/logger/writers/pino'

// in your yoga driver options
logging: new Logger({ writers: [new PinoLogWriter(app.log)] })
  • Breaking

    #4574
    79b0e8b
    Thanks @egoodwinx! - ### Breaking Changes

    • Node: minimum supported version is now Node 22. Node 18 and 20 are no longer supported.
      Future releases will only support Node >=22.

    • GraphQL: minimum supported version is now GraphQL 16. GraphQL 14 and 15 are no longer
      supported.

    • Request body parsing: Yoga now limits request bodies to 25,000,000 bytes by default.
      Enforcing this limit streams the body through a byte counter, making POST body parsing
      asynchronous even for an in-memory body. As a result, yoga.fetch() can return a Promise where
      it previously returned a synchronous Response, even when all resolvers and plugins are
      synchronous.

Migration

  • Breaking

    If you're on Node 18/20, upgrade to Node 22 or later before upgrading this package.

  • Breaking

    If you're on graphql 14/15, upgrade to graphql 16 or 17 first.

  • Breaking

    Await yoga.fetch() and response body parsing instead of relying on synchronous results. Set
    maxRequestBodySize: false in createYoga to disable the body-size limit and preserve
    synchronous parsing for in-memory bodies, but only if you enforce an appropriate request-body
    limit elsewhere.

  • Breaking

    #4623
    be89d05
    Thanks @ardatan! - ### Dependencies

Incremental delivery

Yoga maps the GraphQL HTTP Accept header through INCREMENTAL_DELIVERY_SPECS from
@graphql-tools/utils onto executor incrementalSpec. multipart/mixed;incrementalSpec=v0.2
runs the v0.2 payload format and echoes that spec on Content-Type.
multipart/mixed;deferSpec=20220824 or bare multipart/mixed stays on v0.1. An unsupported
incremental spec yields 406.

A later incremental spec is a graphql-tools table row plus an executor publisher. Yoga, Hive
Gateway, and HTTP executors pick it up by bumping @graphql-tools/utils /
@graphql-tools/executor.

Breaking Changes

Migration

import { GraphQLError } from 'graphql'
import { withSchemaCoordinate } from 'graphql-yoga'
import { mergeSchemas } from '@graphql-tools/schema'
import { getSchemaCoordinate } from '@graphql-tools/utils'
import { handleMaybePromise, isPromise, type MaybePromise } from '@whatwg-node/promise-helpers'
import { DisposableSymbols } from '@whatwg-node/server'

throw withSchemaCoordinate(new GraphQLError('not found'), 'Query.user')
  • Breaking

    #4574
    79b0e8b
    Thanks @egoodwinx! - ### Dependencies

    • Bump @whatwg-node/server to ^0.13.0, @whatwg-node/fetch to ^0.12.0, and
      @whatwg-node/promise-helpers to ^2.0.0.

    • Delegate to @whatwg-node/server's useLimitRequestBodySize instead of a hand-rolled byte counter,
      and swap in the native TransformStream when the incoming request already has a native
      ReadableStream body — piping it through the ponyfill TransformStream throws since they're
      different realms. Thread an optional fetchAPI param through handle/parseRequest/
      getResultForParams so callers can override which fetchAPI (native vs ponyfill) the rest of the
      pipeline uses.

    • Unread request bodies are discarded after the response is decided (keep-alive friendly).

    • Incoming global Request instances automatically use the native Fetch API
      (pickRightFetchAPI), so Next.js no longer needs fetchAPI: { Response }.

Breaking Changes

  • Breaking

    engines.node is now >=22.15.0 (aligned with whatwg-node 0.12+/0.13).

  • Breaking

    @envelop/core no longer exports mapMaybePromise (removed upstream in
    @whatwg-node/promise-helpers v2). Use handleMaybePromise(() => value, ...) instead.

  • Breaking

    @whatwg-node/fetch no longer exports crypto; use the platform crypto global. TextEncoder
    still comes from fetchAPI where hashing goes through Yoga’s FetchAPI.

Patch Changes

  • #4622
    5334079
    Thanks @ardatan! - Stop swapping in globalThis.TransformStream
    inside the request body-size limiter. @whatwg-node/server already passes the request-appropriate
    Fetch API (native vs ponyfill) into Yoga as the handler's third argument, so onRequestParse
    receives a realm-compatible TransformStream without an ad-hoc guard.

A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.