Skip to content
Snippets Groups Projects
Commit 27caea99 authored by Jure's avatar Jure
Browse files

Merge branch 'pubsub-destroy' into 'master'

feat: add destroy method to graphql pubsub

See merge request pubsweet/pubsweet!420
parents 641a63bf 0c51f41a
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,7 @@ const ignoreTerminatedError =
config.get('pubsweet-server.ignoreTerminatedConnectionError')
let pubsub
let client
module.exports = {
/**
......@@ -20,7 +21,7 @@ module.exports = {
*/
getPubsub: async () => {
if (pubsub) return pubsub
const client = new pg.Client(connection)
client = new pg.Client(connection)
// ignore some errors which are thrown in integration tests
if (ignoreTerminatedError) {
client.on('error', async err => {
......@@ -40,6 +41,15 @@ module.exports = {
}
return pubsub
},
destroy: () => {
if (client) {
pubsub = null
return client.end()
}
return Promise.resolve()
},
/**
* Iterators to listen to
*/
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment