mercurius-cache
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -13,3 +13,3 @@ import { FastifyPluginAsync } from "fastify"; | ||
export type PolicyFieldName = string; | ||
export type PolicyField = Record<PolicyFieldName, PolicyFieldOptions | object>; | ||
export type PolicyField = Record<PolicyFieldName, PolicyFieldOptions | object | boolean>; | ||
export type PolicyName = string; | ||
@@ -21,3 +21,3 @@ export type MercuriusCachePolicy = Record<PolicyName, PolicyField>; | ||
log?: object; | ||
invalidate?: boolean; | ||
invalidation?: boolean; | ||
} | ||
@@ -28,3 +28,3 @@ | ||
log?: object; | ||
invalidate?: boolean | { invalidate: boolean; referencesTTL?: number }; | ||
invalidation?: boolean | { invalidate: boolean; referencesTTL?: number }; | ||
} | ||
@@ -31,0 +31,0 @@ |
@@ -152,8 +152,8 @@ 'use strict' | ||
if (_storage.type === 'redis' && maxTTL && _storage.options.invalidate && | ||
(typeof _storage.options.invalidate === 'boolean' || (_storage.options.invalidate && !_storage.options.invalidate.referencesTTL))) { | ||
if (_storage.type === 'redis' && maxTTL && _storage.options.invalidation && | ||
(typeof _storage.options.invalidation === 'boolean' || (_storage.options.invalidation && !_storage.options.invalidation.referencesTTL))) { | ||
_storage.options = { | ||
..._storage.options, | ||
invalidate: { | ||
..._storage.options.invalidate, | ||
invalidation: { | ||
..._storage.options.invalidation, | ||
referencesTTL: maxTTL + 1 | ||
@@ -160,0 +160,0 @@ } |
{ | ||
"name": "mercurius-cache", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Cache the results of your GraphQL resolvers, for Mercurius", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -76,6 +76,6 @@ 'use strict' | ||
test('should get default storage.options.invalidate.referencesTTL as max of policies and main ttl / invalidation as boolean true', async (t) => { | ||
test('should get default storage.options.invalidation.referencesTTL as max of policies and main ttl / invalidation as boolean true', async (t) => { | ||
const options = { | ||
ttl: 1, | ||
storage: { type: 'redis', options: { client: {}, invalidate: true } }, | ||
storage: { type: 'redis', options: { client: {}, invalidation: true } }, | ||
policy: { | ||
@@ -93,9 +93,9 @@ Query: { | ||
t.equal(storage.options.invalidate.referencesTTL, 6) | ||
t.equal(storage.options.invalidation.referencesTTL, 6) | ||
}) | ||
test('should get default storage.options.invalidate.referencesTTL as max of policies and main ttl / invalidation as empty object', async (t) => { | ||
test('should get default storage.options.invalidation.referencesTTL as max of policies and main ttl / invalidation as empty object', async (t) => { | ||
const options = { | ||
ttl: 1, | ||
storage: { type: 'redis', options: { client: {}, invalidate: {} } }, | ||
storage: { type: 'redis', options: { client: {}, invalidation: {} } }, | ||
policy: { | ||
@@ -113,3 +113,3 @@ Query: { | ||
t.equal(storage.options.invalidate.referencesTTL, 6) | ||
t.equal(storage.options.invalidation.referencesTTL, 6) | ||
}) | ||
@@ -120,3 +120,3 @@ | ||
ttl: 1, | ||
storage: { type: 'redis', options: { client: {}, invalidate: true } }, | ||
storage: { type: 'redis', options: { client: {}, invalidation: true } }, | ||
all: true | ||
@@ -123,0 +123,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
136772
34
4280