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 2.0.0 to 3.0.0

14

index.js

@@ -201,3 +201,7 @@ 'use strict'

if (!resolved) {
result = await getResultFromCache({ self, arg, ctx, info, cache, name, originalFieldResolver })
try {
result = await cache[name]({ self, arg, ctx, info })
} catch (err) {
// onError is already been called by cache events binding
}
}

@@ -253,9 +257,1 @@

}
async function getResultFromCache ({ self, arg, ctx, info, cache, name, originalFieldResolver }) {
try {
return await cache[name]({ self, arg, ctx, info })
} catch (error) {
return await originalFieldResolver(self, arg, ctx, info)
}
}
{
"name": "mercurius-cache",
"version": "2.0.0",
"version": "3.0.0",
"description": "Cache the results of your GraphQL resolvers, for Mercurius",

@@ -31,15 +31,15 @@ "main": "index.js",

"autocannon": "^7.9.0",
"concurrently": "^7.2.1",
"fastify": "^4.0.0",
"mercurius": "^10.0.0",
"graphql": "^16.5.0",
"ioredis": "^5.0.6",
"concurrently": "^7.4.0",
"fastify": "^4.5.3",
"graphql": "^16.6.0",
"ioredis": "^5.2.3",
"mercurius": "^11.0.0",
"snazzy": "^9.0.0",
"split2": "^4.1.0",
"standard": "^17.0.0",
"tap": "^16.2.0",
"tsd": "^0.20.0",
"typescript": "^4.7.3",
"tap": "^16.3.0",
"tsd": "^0.23.0",
"typescript": "^4.8.2",
"wait-on": "^6.0.1",
"ws": "^8.8.0"
"ws": "^8.8.1"
},

@@ -50,6 +50,6 @@ "tsd": {

"dependencies": {
"async-cache-dedupe": "^1.2.2",
"fastify-plugin": "^3.0.1"
"async-cache-dedupe": "^1.4.1",
"fastify-plugin": "^4.2.1"
},
"precommit": "test"
}

@@ -375,3 +375,3 @@ # mercurius-cache

```js
onSkip (type, fieldName, error) {
onError (type, fieldName, error) {
console.error(`error on ${type} ${fieldName}`, error)

@@ -378,0 +378,0 @@ }

@@ -103,3 +103,3 @@ 'use strict'

test('No TTL, do not use cache', async ({ equal, same, pass, plan, teardown }) => {
plan(10)
plan(7)

@@ -132,7 +132,9 @@ const app = fastify()

let misses = 0
let hits = 0
app.register(cache, {
onHit (type, name) {
hits++
},
onMiss (type, name) {
equal(type, 'Query', 'on miss')
equal(name, 'add')
misses++

@@ -152,3 +154,4 @@ },

equal(misses, 2)
equal(misses, 0)
equal(hits, 0)

@@ -1412,5 +1415,3 @@ async function query () {

test('references throws', async ({ fail, pass, plan, teardown, same }) => {
plan(1)
test('references throws', async ({ fail, pass, teardown, same, equal }) => {
const app = fastify()

@@ -1451,3 +1452,3 @@ teardown(app.close.bind(app))

onMiss (type, name) {
if (++miss === 2) { pass() }
miss++
},

@@ -1475,2 +1476,3 @@ policy: {

same(res.json(), { data: { get: 'get 11' } })
equal(miss, 1)
})

@@ -1672,1 +1674,38 @@

})
test('should call original resolver only once on resolver error', async (t) => {
const app = fastify()
t.teardown(async () => {
await app.close()
})
let count = 0
const resolvers = {
Query: {
hello () {
count++
throw new Error('oops')
}
}
}
app.register(mercurius, {
schema: `
type Query {
hello: String
}
`,
resolvers
})
await app.register(cache, {
ttl: 2,
all: true,
storage: { type: 'memory' }
})
await request({ app, query: '{ hello }' })
t.equal(count, 1)
})

@@ -121,6 +121,6 @@ 'use strict'

equal(hits.add, 0, 'never hits the cache')
equal(misses.add, 3)
equal(misses.add, 0, 'never use the cache')
equal(hits.sub, 0, 'never hits the cache')
equal(misses.sub, 6)
equal(misses.sub, 0, 'never use the cache')
})

@@ -127,0 +127,0 @@

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