Skip to content

May 30, 2024

Latest
Compare
Choose a tag to compare
@theguild-bot theguild-bot released this 30 May 09:49
de4d13b

@envelop/response-cache@6.2.0

Minor Changes

  • #2238
    430ee7d
    Thanks @ardatan! - Accept a factory function to cache that takes
    the context and returns the cache implementation

@envelop/response-cache-cloudflare-kv@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