mercurius
Advanced tools
Comparing version 10.1.1 to 10.2.0
@@ -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. |
@@ -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
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
995284
35196
+ Added@fastify/websocket@7.2.0(transitive)
- Removed@fastify/websocket@6.0.1(transitive)
- Removedfastify-plugin@3.0.1(transitive)
Updated@fastify/websocket@^7.0.0
Updatedfastify-plugin@^4.2.0