Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mercurius-cache

Package Overview
Dependencies
Maintainers
3
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mercurius-cache - npm Package Compare versions

Comparing version 6.0.0 to 6.0.1

4

lib/report.js

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc