On this page

@envelop/response-cache-cloudflare-kv

Changelog for @envelop/response-cache-cloudflare-kv: every release with its changes and the pull requests behind them.

7.0.0

Major Changes

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

Minor 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)] })

Patch Changes

6.3.4

Patch Changes

  • Updated dependencies [9fde867]:
    • @envelop/response-cache@9.3.4

6.3.3

Patch Changes

  • Updated dependencies [d8b8860]:
    • @envelop/response-cache@9.3.3

6.3.2

Patch Changes

  • Updated dependencies [c6febdc]:
    • @envelop/response-cache@9.3.2

6.3.1

Patch Changes

  • #4577 7bff35c Thanks @egoodwinx! - Add homepage and bugs.url to package.json files

  • Updated dependencies [7bff35c]:

    • @envelop/response-cache@9.3.1

6.3.0

Patch Changes

  • Updated dependencies [ab4aeaa]:
    • @envelop/response-cache@9.3.0

6.2.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]:
    • @envelop/response-cache@9.2.0

6.1.1

Patch Changes

  • Updated dependencies []:
    • @envelop/response-cache@9.1.1

6.1.0

Patch Changes

  • Updated dependencies [dc2327d]:
    • @envelop/response-cache@9.1.0

6.0.0

Patch Changes

  • Updated dependencies []:
    • @envelop/response-cache@9.0.0

5.0.0

Patch Changes

  • Updated dependencies [35539a7]:
    • @envelop/response-cache@8.1.0

4.0.0

Patch Changes

  • Updated dependencies []:
    • @envelop/response-cache@8.0.0

3.1.3

Patch Changes

  • Updated dependencies []:
    • @envelop/response-cache@7.1.3

3.1.2

Patch Changes

  • Updated dependencies [26137e7, 26137e7]:
    • @envelop/response-cache@7.1.2

3.1.1

Patch Changes

  • Updated dependencies []:
    • @envelop/response-cache@7.1.1

3.1.0

Patch Changes

  • Updated dependencies []:
    • @envelop/response-cache@7.1.0

3.0.0

Patch Changes

  • Updated dependencies [9bd1b20]:
    • @envelop/response-cache@7.0.0

2.0.0

Patch Changes

  • Updated dependencies [7882ffb]:
    • @envelop/response-cache@6.3.0

1.0.0

Minor Changes

  • #2238 430ee7d Thanks @ardatan! - BREAKING: Now the cache implementation does not require the ExecutionContext or KVNamespace instance but only the name of the namespace

    import { createSchema, createYoga, YogaInitialContext } from 'graphql-yoga'
    import { useResponseCache } from '@envelop/response-cache'
    import { createKvCache } from '@envelop/response-cache-cloudflare-kv'
    import { resolvers } from './graphql-schema/resolvers.generated'
    import { typeDefs } from './graphql-schema/typeDefs.generated'
    
    export type Env = {
      GRAPHQL_RESPONSE_CACHE: KVNamespace
    }
    
    const graphqlServer = createYoga<Env & ExecutionContext>({
      schema: createSchema({ typeDefs, resolvers }),
      plugins: [
        useResponseCache({
          cache: createKvCache({
            KVName: 'GRAPHQL_RESPONSE_CACHE',
            keyPrefix: 'graphql' // optional
          }),
          session: () => null,
          includeExtensionMetadata: true,
          ttl: 1000 * 10 // 10 seconds
        })
      ]
    })
    
    export default {
      fetch: graphqlServer
    }

Patch Changes

  • Updated dependencies [430ee7d]:
    • @envelop/response-cache@6.2.0

0.3.0

Minor Changes

  • #2105 a2c7657 Thanks @AdiRishi! - Change @cloudflare/workers-types to an optional peer dependency of the package

Patch Changes

  • Updated dependencies [ee1b3c0, 4a1e50b]:
    • @envelop/response-cache@6.1.2

0.2.0

Minor Changes

Patch Changes

  • Updated dependencies [cafc43f, 09a4bc1]:
    • @envelop/response-cache@6.1.1