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

mercurius

Package Overview
Dependencies
Maintainers
2
Versions
116
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mercurius - npm Package Compare versions

Comparing version 10.1.1 to 10.2.0

21

docs/plugins.md

@@ -13,2 +13,3 @@ # Plugins

- [mercurius-postgraphile](#mercurius-postgraphile)
- [mercurius-logging](#mercurius-logging)

@@ -128,1 +129,21 @@ ## mercurius-auth

Check [https://github.com/autotelic/mercurius-postgraphile](https://github.com/autotelic/mercurius-postgraphile) for usage and readme.
## mercurius-logging
A Mercurius plugin to enhance the GQL request logging adding useful insights:
```json
{
"level": 30,
"time": 1660395516406,
"hostname": "eomm",
"reqId": "req-1",
"graphql": {
"queries": [
"firstQuery:myTeam",
"secondQuery:myTeam"
]
}
}
```
Check the [`mercurius-logging`](https://github.com/Eomm/mercurius-logging) documentation for usage and settings.

26

lib/subscription-connection.js

@@ -274,2 +274,3 @@ 'use strict'

this.sendMessage(this.protocolMessageTypes.GQL_COMPLETE, id, null)
this.handleGQLComplete(id)
}

@@ -288,2 +289,15 @@

handleGQLComplete (id) {
const sc = this.subscriptionContexts.get(id)
if (sc) {
sc.close && sc.close()
this.subscriptionContexts.delete(id)
}
const subIter = this.subscriptionIters.get(id)
if (subIter) {
subIter.return && subIter.return()
this.subscriptionIters.delete(id)
}
}
async handleGQLStop (data) {

@@ -298,12 +312,4 @@ if (this.context.onSubscriptionEnd) {

}
const sc = this.subscriptionContexts.get(data.id)
if (sc) {
sc.close && sc.close()
this.subscriptionContexts.delete(data.id)
}
const subIter = this.subscriptionIters.get(data.id)
if (subIter) {
subIter.return && subIter.return()
this.subscriptionIters.delete(data.id)
}
this.handleGQLComplete(data.id)
}

@@ -310,0 +316,0 @@

{
"name": "mercurius",
"version": "10.1.1",
"version": "10.2.0",
"description": "Fastify GraphQL adapter with gateway and subscription support",

@@ -59,5 +59,5 @@ "main": "index.js",

"@fastify/static": "^6.0.0",
"@fastify/websocket": "^6.0.0",
"@fastify/websocket": "^7.0.0",
"events.on": "^1.0.1",
"fastify-plugin": "^3.0.1",
"fastify-plugin": "^4.2.0",
"graphql": "^16.0.0",

@@ -64,0 +64,0 @@ "graphql-jit": "^0.7.3",

@@ -8,2 +8,3 @@ 'use strict'

const mq = require('mqemitter')
const { makeExecutableSchema } = require('@graphql-tools/schema')
const SubscriptionConnection = require('../lib/subscription-connection')

@@ -647,1 +648,58 @@ const { PubSub } = require('../lib/subscriber')

})
test('subscription data is released right after it ends', async (t) => {
const sc = new SubscriptionConnection({
on () {},
close () {},
send () {},
protocol: GRAPHQL_TRANSPORT_WS
}, {
context: { preSubscriptionParsing: null, preSubscriptionExecution: null },
fastify: {
graphql: {
schema: makeExecutableSchema({
typeDefs: ['type Query { blah: String! }', 'type Subscription { onMessage: String! }'],
resolvers: {
Query: {},
Subscription: {
onMessage: {
async * subscribe () {
return 'blah'
}
}
}
}
})
}
}
})
sc.isReady = true
t.equal(sc.subscriptionIters.size, 0)
t.equal(sc.subscriptionContexts.size, 0)
await sc.handleMessage(JSON.stringify({
id: 1,
type: 'subscribe',
payload: {
query: 'subscription { onMessage } '
}
}))
await new Promise(resolve => {
sc.sendMessage = (type, id, payload) => {
t.equal(id, 1)
t.equal(type, 'complete')
t.equal(payload, null)
t.equal(sc.subscriptionIters.size, 1)
t.equal(sc.subscriptionContexts.size, 1)
resolve()
}
})
t.equal(sc.subscriptionIters.size, 0)
t.equal(sc.subscriptionContexts.size, 0)
})

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