@envelop/response-cache 4.0.1 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@envelop/response-cache",
3
- "version": "4.0.1",
3
+ "version": "4.0.2",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
- "@envelop/core": "^3.0.1",
6
+ "@envelop/core": "^3.0.2",
7
7
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
8
8
  },
9
9
  "dependencies": {
@@ -1,4 +1,4 @@
1
1
  import { ExecutionArgs } from 'graphql';
2
2
  import { Plugin } from '@envelop/core';
3
- export declare function useCacheDocumentString(): Plugin;
3
+ export declare function useCacheDocumentString<PluginContext extends Record<string, any> = {}>(): Plugin<PluginContext>;
4
4
  export declare function defaultGetDocumentString(executionArgs: ExecutionArgs): string;
@@ -1,4 +1,4 @@
1
1
  import { ExecutionArgs } from 'graphql';
2
2
  import { Plugin } from '@envelop/core';
3
- export declare function useCacheDocumentString(): Plugin;
3
+ export declare function useCacheDocumentString<PluginContext extends Record<string, any> = {}>(): Plugin<PluginContext>;
4
4
  export declare function defaultGetDocumentString(executionArgs: ExecutionArgs): string;
@@ -18,7 +18,7 @@ export declare type GetDocumentStringFunction = (executionArgs: ExecutionArgs) =
18
18
  export declare type ShouldCacheResultFunction = (params: {
19
19
  result: ExecutionResult;
20
20
  }) => Boolean;
21
- export declare type UseResponseCacheParameter<C = any> = {
21
+ export declare type UseResponseCacheParameter<PluginContext extends Record<string, any> = {}> = {
22
22
  cache?: Cache;
23
23
  /**
24
24
  * Maximum age in ms. Defaults to `Infinity`. Set it to 0 for disabling the global TTL.
@@ -60,12 +60,12 @@ export declare type UseResponseCacheParameter<C = any> = {
60
60
  * });
61
61
  * ```
62
62
  */
63
- session(context: C): string | undefined | null;
63
+ session(context: PluginContext): string | undefined | null;
64
64
  /**
65
65
  * Specify whether the cache should be used based on the context.
66
66
  * By default any request uses the cache.
67
67
  */
68
- enabled?(context: C): boolean;
68
+ enabled?(context: PluginContext): boolean;
69
69
  /**
70
70
  * Skip caching of following the types.
71
71
  */
@@ -119,4 +119,4 @@ export declare const defaultBuildResponseCacheKey: BuildResponseCacheKeyFunction
119
119
  * By default, results with errors (unexpected, EnvelopError, or GraphQLError) are not cached.
120
120
  */
121
121
  export declare const defaultShouldCacheResult: ShouldCacheResultFunction;
122
- export declare function useResponseCache({ cache, ttl: globalTtl, session, enabled, ignoredTypes, ttlPerType, ttlPerSchemaCoordinate, idFields, invalidateViaMutation, buildResponseCacheKey, getDocumentString, shouldCacheResult, includeExtensionMetadata, }: UseResponseCacheParameter): Plugin;
122
+ export declare function useResponseCache<PluginContext extends Record<string, any> = {}>({ cache, ttl: globalTtl, session, enabled, ignoredTypes, ttlPerType, ttlPerSchemaCoordinate, idFields, invalidateViaMutation, buildResponseCacheKey, getDocumentString, shouldCacheResult, includeExtensionMetadata, }: UseResponseCacheParameter<PluginContext>): Plugin<PluginContext>;
@@ -18,7 +18,7 @@ export declare type GetDocumentStringFunction = (executionArgs: ExecutionArgs) =
18
18
  export declare type ShouldCacheResultFunction = (params: {
19
19
  result: ExecutionResult;
20
20
  }) => Boolean;
21
- export declare type UseResponseCacheParameter<C = any> = {
21
+ export declare type UseResponseCacheParameter<PluginContext extends Record<string, any> = {}> = {
22
22
  cache?: Cache;
23
23
  /**
24
24
  * Maximum age in ms. Defaults to `Infinity`. Set it to 0 for disabling the global TTL.
@@ -60,12 +60,12 @@ export declare type UseResponseCacheParameter<C = any> = {
60
60
  * });
61
61
  * ```
62
62
  */
63
- session(context: C): string | undefined | null;
63
+ session(context: PluginContext): string | undefined | null;
64
64
  /**
65
65
  * Specify whether the cache should be used based on the context.
66
66
  * By default any request uses the cache.
67
67
  */
68
- enabled?(context: C): boolean;
68
+ enabled?(context: PluginContext): boolean;
69
69
  /**
70
70
  * Skip caching of following the types.
71
71
  */
@@ -119,4 +119,4 @@ export declare const defaultBuildResponseCacheKey: BuildResponseCacheKeyFunction
119
119
  * By default, results with errors (unexpected, EnvelopError, or GraphQLError) are not cached.
120
120
  */
121
121
  export declare const defaultShouldCacheResult: ShouldCacheResultFunction;
122
- export declare function useResponseCache({ cache, ttl: globalTtl, session, enabled, ignoredTypes, ttlPerType, ttlPerSchemaCoordinate, idFields, invalidateViaMutation, buildResponseCacheKey, getDocumentString, shouldCacheResult, includeExtensionMetadata, }: UseResponseCacheParameter): Plugin;
122
+ export declare function useResponseCache<PluginContext extends Record<string, any> = {}>({ cache, ttl: globalTtl, session, enabled, ignoredTypes, ttlPerType, ttlPerSchemaCoordinate, idFields, invalidateViaMutation, buildResponseCacheKey, getDocumentString, shouldCacheResult, includeExtensionMetadata, }: UseResponseCacheParameter<PluginContext>): Plugin<PluginContext>;