wingbot 3.65.10 → 3.65.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wingbot",
3
- "version": "3.65.10",
3
+ "version": "3.65.11",
4
4
  "description": "Enterprise Messaging Bot Conversation Engine",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/plugins/index.js CHANGED
@@ -8,14 +8,14 @@ const pluginsJson = require('./plugins.json');
8
8
  const plugins = new Map();
9
9
 
10
10
  for (const plugin of pluginsJson.plugins) {
11
- // @ts-ignore
12
- const fn = module.require(`./${plugin.id}/plugin`);
11
+ plugins.set(plugin.id, {
12
+ pluginFactory: (...args) => {
13
+ // @ts-ignore
14
+ const fn = module.require(`./${plugin.id}/plugin`);
13
15
 
14
- if (plugin.isFactory) {
15
- plugins.set(plugin.id, { pluginFactory: fn });
16
- } else {
17
- plugins.set(plugin.id, fn);
18
- }
16
+ return plugin.isFactory ? fn(...args) : fn;
17
+ }
18
+ });
19
19
  }
20
20
 
21
21
  module.exports = plugins;
@@ -4,7 +4,6 @@
4
4
  'use strict';
5
5
 
6
6
  const assert = require('assert');
7
- const { graphql, buildSchema } = require('graphql');
8
7
  const WingbotApiConnector = require('./WingbotApiConnector');
9
8
  // @ts-ignore
10
9
  const packageJson = require('../../package.json');
@@ -21,6 +20,7 @@ const DEFAULT_CACHE = 86400000; // 24 hours
21
20
  */
22
21
 
23
22
  /** @typedef {import('../CallbackAuditLog')} AuditLog */
23
+ /** @typedef {import('graphql')} GqlLib */
24
24
 
25
25
  /**
26
26
  * Experimental chatbot API
@@ -81,6 +81,19 @@ class GraphApi {
81
81
  cacheKeys: opts.cacheKeys,
82
82
  useBundledGql: opts.useBundledGql
83
83
  });
84
+
85
+ this._lib = null;
86
+ }
87
+
88
+ /**
89
+ * @returns {GqlLib}
90
+ */
91
+ get _gql () {
92
+ if (this._lib === null) {
93
+ // eslint-disable-next-line global-require
94
+ this._lib = require('graphql');
95
+ }
96
+ return this._lib;
84
97
  }
85
98
 
86
99
  /**
@@ -139,7 +152,7 @@ class GraphApi {
139
152
  audit
140
153
  };
141
154
 
142
- const response = await graphql({
155
+ const response = await this._gql.graphql({
143
156
  schema,
144
157
  source: body.query,
145
158
  rootValue: this._root,
@@ -159,7 +172,7 @@ class GraphApi {
159
172
 
160
173
  if (!schemaIsSame) {
161
174
  this._originalSchema = loadedSchema;
162
- this._cachedSchema = buildSchema(loadedSchema);
175
+ this._cachedSchema = this._gql.buildSchema(loadedSchema);
163
176
  }
164
177
  return this._cachedSchema;
165
178
  }