mercurius-cache
Advanced tools
Comparing version 6.0.0 to 6.0.1
@@ -17,3 +17,3 @@ 'use strict' | ||
const fields = opts.all | ||
? Object.keys(schema.getQueryType().getFields()).map(field => `Query.${field}`) | ||
? Object.keys(schema.getQueryType().getFields()).map(field => `${schema.getQueryType()}.${field}`) | ||
: this.getPolicies(opts.policy) | ||
@@ -95,3 +95,3 @@ | ||
function createReport ({ app, all, policy, logInterval, logReport }) { | ||
if (!logInterval || !((policy && policy.Query) || all)) { | ||
if (!logInterval || !((policy && policy[app.graphql.schema.getQueryType()]) || all)) { | ||
const disabled = { | ||
@@ -98,0 +98,0 @@ clear: noop, |
{ | ||
"name": "mercurius-cache", | ||
"version": "6.0.0", | ||
"version": "6.0.1", | ||
"description": "Cache the results of your GraphQL resolvers, for Mercurius", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -14,2 +14,78 @@ 'use strict' | ||
test('Report with non-default query type name', async ({ strictSame, plan, fail, teardown }) => { | ||
plan(2) | ||
let app = null | ||
const stream = split(JSON.parse) | ||
try { | ||
app = fastify({ | ||
logger: { | ||
stream | ||
} | ||
}) | ||
} catch (e) { | ||
fail() | ||
} | ||
teardown(app.close.bind(app)) | ||
const clock = FakeTimers.install({ | ||
shouldAdvanceTime: true, | ||
advanceTimeDelta: 100 | ||
}) | ||
teardown(() => clock.uninstall()) | ||
const schema = ` | ||
schema { | ||
query: XQuery | ||
} | ||
type XQuery { | ||
add(x: Int, y: Int): Int | ||
} | ||
` | ||
const resolvers = { | ||
XQuery: { | ||
async add (_, { x, y }) { | ||
return x + y | ||
} | ||
} | ||
} | ||
app.register(mercurius, { | ||
schema, | ||
resolvers | ||
}) | ||
app.register(cache, { | ||
ttl: 1, | ||
policy: { | ||
XQuery: { | ||
add: true | ||
} | ||
}, | ||
logInterval: 3 | ||
}) | ||
const query = '{ add(x: 2, y: 2) }' | ||
let data | ||
await request({ app, query }) | ||
await request({ app, query }) | ||
clock.tick(1000) | ||
await once(stream, 'data') | ||
data = await once(stream, 'data') | ||
strictSame(data.data, { 'XQuery.add': { dedupes: 0, hits: 1, misses: 1, skips: 0 } }) | ||
await clock.tick(3000) | ||
data = await once(stream, 'data') | ||
strictSame(data.data, { 'XQuery.add': { dedupes: 0, hits: 0, misses: 0, skips: 0 } }) | ||
}) | ||
test('Report with policy specified', async ({ strictSame, plan, fail, teardown }) => { | ||
@@ -16,0 +92,0 @@ plan(2) |
Sorry, the diff of this file is not supported yet
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
196952
6231