Skip to content

Commit 491c7e6

Browse files
committed
add createPubSub method
1 parent c463180 commit 491c7e6

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/service.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const GraphQL = require("graphql");
1515
const { PubSub, withFilter } = require("graphql-subscriptions");
1616
const hash = require("object-hash");
1717

18-
module.exports = function (mixinOptions) {
18+
module.exports = function(mixinOptions) {
1919
mixinOptions = _.defaultsDeep(mixinOptions, {
2020
routeOptions: {
2121
path: "/graphql",
@@ -594,6 +594,16 @@ module.exports = function (mixinOptions) {
594594
return makeExecutableSchema(schemaDef);
595595
},
596596

597+
/**
598+
* Create PubSub instance.
599+
*/
600+
createPubSub() {
601+
return new PubSub();
602+
},
603+
604+
/**
605+
* Prepare GraphQL schemas based on Moleculer services.
606+
*/
597607
prepareGraphQLSchema() {
598608
// Schema is up-to-date
599609
if (!this.shouldUpdateGraphqlSchema && this.graphqlHandler) {
@@ -606,7 +616,7 @@ module.exports = function (mixinOptions) {
606616
);
607617

608618
try {
609-
this.pubsub = new PubSub();
619+
this.pubsub = this.createPubSub();
610620
const services = this.broker.registry.getServiceList({ withActions: true });
611621
const schema = this.generateGraphQLSchema(services);
612622

0 commit comments

Comments
 (0)