On this page

@graphql-yoga/nestjs

Changelog for @graphql-yoga/nestjs: every release with its changes and the pull requests behind them.

5.0.0

Major Changes

  • #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

    • The @graphql-yoga/logger package has been removed. graphql-yoga re-exports Logger, MemoryLogWriter and LogLevel from @graphql-hive/logger instead.
    • createLogger and the YogaLogger type are no longer exported. Use new Logger(options) instead.
    • The logging option now takes boolean | Logger | LogLevel, where Logger is the one from @graphql-hive/logger.
    • yoga.logger has been renamed to yoga.log.
    • The logger option of useGraphiQL and useHealthCheck has been removed. They now log through the request’s logger.
    • @graphql-yoga/nestjs now logs through Nest’s Logger by default instead of not logging at all. Pass logging: false to keep the previous behaviour. logging: true on Fastify no longer logs through Fastify’s logger, pass it explicitly instead (see below).
    • @envelop/apollo-federation, @envelop/auth0, @envelop/graphql-jit, @envelop/newrelic, @envelop/resource-limitations, @envelop/response-cache, @envelop/response-cache-cloudflare-kv and @envelop/statsd now have a peer dependency on @graphql-hive/logger that you must install.
    • @envelop/apollo-federation’s logger option now expects a Logger from @graphql-hive/logger and defaults to new Logger() instead of console.

    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)] })
  • #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

    • If you’re on Node 18/20, upgrade to Node 22 or later before upgrading this package.
    • If you’re on graphql 14/15, upgrade to graphql 16 or 17 first.
    • 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.
  • #4623 be89d05 Thanks @ardatan! - ### Dependencies

    • Bump @graphql-tools/utils to ^13.1.1, @graphql-tools/schema to ^11.0.0, and @graphql-tools/executor to ^4.1.2.

    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

    • createGraphQLError is removed. Use new GraphQLError(message, options) from graphql. To attach Yoga’s experimental schema coordinate, use withSchemaCoordinate(error, coordinate) and read with getSchemaCoordinate from @graphql-tools/utils.
    • mapMaybePromise is removed (was exported from Yoga / @envelop/core). Use handleMaybePromise from @whatwg-node/promise-helpers.
    • Yoga no longer re-exports helpers that already live upstream:
      • getSchemaCoordinate -> @graphql-tools/utils
      • mergeSchemas -> @graphql-tools/schema
      • DisposableSymbols -> @whatwg-node/server
      • mapAsyncIterator / isPromise / fakePromise / handleMaybePromise / MaybePromise -> @whatwg-node/promise-helpers
    • @envelop/core utils no longer re-exports mapAsyncIterator or isPromise. Import from @whatwg-node/promise-helpers.
    • Use asGetArgumentValuesVariables / coerceGetVariableValuesResult from @graphql-tools/utils for GraphQL 16/17 VariableValues compatibility.

    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')

Patch Changes

4.0.4

Patch Changes

  • Updated dependencies [9294289]:
    • graphql-yoga@5.24.6

4.0.3

Patch Changes

  • Updated dependencies []:
    • graphql-yoga@5.24.5

4.0.2

Patch Changes

  • Updated dependencies [d8b8860]:
    • graphql-yoga@5.24.4

4.0.1

Patch Changes

  • Updated dependencies [c6febdc]:
    • graphql-yoga@5.24.3

4.0.0

Major Changes

  • #4589 c08efde Thanks @egoodwinx! - Remove the built-in subscriptions driver option and its graphql-ws / subscriptions-transport-ws wiring (previously implemented via @nestjs/graphql’s GqlSubscriptionService).

    Fix open handle leak in multipart tests.

    @nestjs/graphql v14 (required for NestJS 12 support) dropped server-side support for subscriptions-transport-ws, and the driver-level graphql-ws integration held a socket open after shutdown. Rather than keep a partial, driver-managed subscriptions setup, YogaDriver and YogaFederationDriver no longer accept a subscriptions option. Wire up subscriptions yourself using GraphQL Yoga’s own subscription support (e.g. the graphql-ws package, or @graphql-yoga/plugin-graphql-sse) the same way you would for a standalone graphql-yoga server.

Patch Changes

3.25.1

Patch Changes

  • Updated dependencies [c6a9aa4]:
    • graphql-yoga@5.24.1

3.25.0

Patch Changes

3.24.0

Patch Changes

3.23.0

Minor Changes

  • #4545 94ebe5b Thanks @egoodwinx! - Update to support graphql-js 17

    Bump package versions, fix expected typing, and update compatability with subscribe.

Patch Changes

  • Updated dependencies [94ebe5b]:
    • graphql-yoga@5.22.0

3.22.3

Patch Changes

  • Updated dependencies [04014d2]:
    • graphql-yoga@5.21.3

3.22.2

Patch Changes

  • Updated dependencies [39b55ba]:
    • graphql-yoga@5.21.2

3.22.1

Patch Changes

  • Updated dependencies [4b43efd]:
    • graphql-yoga@5.21.1

3.22.0

Patch Changes

  • Updated dependencies [e263f7e]:
    • graphql-yoga@5.21.0

3.21.0

Patch Changes

  • Updated dependencies [93f1dc0]:
    • graphql-yoga@5.20.0

3.20.0

Patch Changes

  • Updated dependencies [7e0aaf6]:
    • graphql-yoga@5.19.0

3.19.1

Patch Changes

3.19.0

Patch Changes

  • Updated dependencies [3eabd17]:
    • graphql-yoga@5.18.0

3.18.1

Patch Changes

  • Updated dependencies [c27f550]:
    • graphql-yoga@5.17.1

3.18.0

Patch Changes

3.17.1

Patch Changes

  • Updated dependencies [ba38629]:
    • graphql-yoga@5.16.2

3.17.0

Minor Changes

Patch Changes

3.16.0

Patch Changes

3.15.2

Patch Changes

  • Updated dependencies [e7b8906]:
    • graphql-yoga@5.15.2

3.15.1

Patch Changes

  • Updated dependencies [ecd605b]:
    • graphql-yoga@5.15.1

3.15.0

Patch Changes

3.14.0

Patch Changes

3.13.5

Patch Changes

  • Updated dependencies [8b41a52]:
    • graphql-yoga@5.13.5

3.13.4

Patch Changes

3.13.3

Patch Changes

3.13.2

Patch Changes

3.13.1

Patch Changes

  • Updated dependencies [dee7995]:
    • graphql-yoga@5.13.1

3.13.0

Patch Changes

3.12.2

Patch Changes

  • Updated dependencies [a6b3de9]:
    • graphql-yoga@5.12.2

3.12.1

Patch Changes

  • Updated dependencies [fbf328c]:
    • graphql-yoga@5.12.1

3.12.0

Patch Changes

3.11.0

Patch Changes

3.10.12

Patch Changes

  • Updated dependencies [1c055f5]:
    • graphql-yoga@5.10.11

3.10.11

Patch Changes

3.10.10

Patch Changes

3.10.9

Patch Changes

3.10.8

Patch Changes

  • Updated dependencies [ed344ea]:
    • graphql-yoga@5.10.8

3.10.7

Patch Changes

3.10.6

Patch Changes

  • Updated dependencies [121ccba]:
    • graphql-yoga@5.10.6

3.10.5

Patch Changes

3.10.4

Patch Changes

  • Updated dependencies [944ecd5]:
    • graphql-yoga@5.10.4

3.10.3

Patch Changes

3.10.2

Patch Changes

3.10.1

Patch Changes

  • Updated dependencies [20cd9b6]:
    • graphql-yoga@5.10.1

3.10.0

Patch Changes

  • Updated dependencies [f81501c]:
    • graphql-yoga@5.10.0

3.9.0

Patch Changes

3.8.0

Patch Changes

3.7.0

Minor Changes

Patch Changes

3.6.3

Patch Changes

  • Updated dependencies [0866c1b]:
    • graphql-yoga@5.6.3

3.6.2

Patch Changes

3.6.1

Patch Changes

  • Updated dependencies [4252e3d]:
    • graphql-yoga@5.6.1

3.6.0

Patch Changes

  • Updated dependencies [9f3f945]:
    • graphql-yoga@5.6.0

3.5.0

Patch Changes

  • Updated dependencies [0208024]:
    • graphql-yoga@5.5.0

3.4.0

Patch Changes

3.3.1

Patch Changes

3.3.0

Patch Changes

3.2.0

Patch Changes

3.1.1

Patch Changes

  • Updated dependencies [3ef877a7]:
    • graphql-yoga@5.1.1

3.1.0

Minor Changes

  • #2992 b1f0e3a2 Thanks @magrinj! - Adding support of conditionalSchema option. (Currently without support for WebSocket subscriptions)

Patch Changes

  • Updated dependencies [b1f0e3a2]:
    • graphql-yoga@5.1.0

3.0.2

Patch Changes

  • Updated dependencies [77d107fe]:
    • graphql-yoga@5.0.2

3.0.1

Patch Changes

  • Updated dependencies [3fea19f2]:
    • graphql-yoga@5.0.1

3.0.0

Major Changes

Patch Changes

2.1.1

Patch Changes

  • Updated dependencies [bf602edf]:
    • graphql-yoga@4.0.5

2.1.0

Minor Changes

  • #2977 bb583a11 Thanks @gthau! - Support for NestJS @Subscription.filter method in YogaDriver.

2.0.4

Patch Changes

  • Updated dependencies [5f182006]:
    • graphql-yoga@4.0.4

2.0.3

Patch Changes

  • Updated dependencies [5efb8250]:
    • graphql-yoga@4.0.3

2.0.2

Patch Changes

2.0.1

Patch Changes

2.0.0

Major Changes

Patch Changes

1.1.1

Patch Changes

1.1.0

Patch Changes

  • Updated dependencies [aff69200]:
    • graphql-yoga@3.9.0

1.0.1

Patch Changes

1.0.0

Major Changes

  • #2525 41f4a545 Thanks @enisdenjo! - GraphQL Yoga driver for NestJS GraphQL.

    BREAKING CHANGES

    • No more subscriptionWithFilter in YogaBaseDriver.
    • YogaBaseDriver.yogaInstance has been renamed to YogaBaseDriver.yoga
    • YogaBaseDriver has been renamed to AbstractYogaDriver
    • Drop @envelop/apollo-server-errors, if you want to use it - supply it to the plugins yourself
    • graphql is now a peer dependency
    • graphql-yoga is now a peer dependency
    • installSubscriptionHandlers driver option has been dropped, please use the subscriptions option
    • Apollo Federation v2 support
    • Apollo Federation driver has been moved to a separate package @graphql-yoga/nestjs-federation
    • Dropped support for @nestjs/graphql@v10, now at least v11 is required (https://github.com/nestjs/graphql/pull/2435)
    • Minimum Node.js engine is v14

Patch Changes

0.3.1

Patch Changes

  • 05d838c: Make Fastify platform work (#79)

0.3.0

Minor Changes

  • 2c1f603: @nestjs/graphql should be a peer dependency

0.2.0

Minor Changes

  • 8161b3e: Support NestJS v9

0.1.0

Minor Changes

  • c58c7d5: Yoga v3

0.0.4

Patch Changes

  • b57dd7a: Fix Federated service code-first schema generation

0.0.3

Patch Changes

  • 486baac: fix build

0.0.2

Patch Changes

  • 3237986: update documentation