@teambit/graphql 0.0.881 → 0.0.883
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/dist/create-link.js +2 -8
- package/dist/create-link.js.map +1 -1
- package/dist/create-remote-schemas/create-remote-schemas.js +7 -44
- package/dist/create-remote-schemas/create-remote-schemas.js.map +1 -1
- package/dist/create-remote-schemas/index.js +0 -3
- package/dist/create-remote-schemas/index.js.map +1 -1
- package/dist/graphql-error.js +0 -3
- package/dist/graphql-error.js.map +1 -1
- package/dist/graphql-provider/graphql-provider.js +0 -8
- package/dist/graphql-provider/graphql-provider.js.map +1 -1
- package/dist/graphql-provider/index.js +0 -3
- package/dist/graphql-provider/index.js.map +1 -1
- package/dist/graphql.aspect.js +0 -5
- package/dist/graphql.aspect.js.map +1 -1
- package/dist/graphql.composition.js +0 -6
- package/dist/graphql.composition.js.map +1 -1
- package/dist/graphql.main.runtime.js +18 -92
- package/dist/graphql.main.runtime.js.map +1 -1
- package/dist/graphql.ui.runtime.js +1 -48
- package/dist/graphql.ui.runtime.js.map +1 -1
- package/dist/index.js +0 -9
- package/dist/index.js.map +1 -1
- package/dist/logging.js +8 -4
- package/dist/logging.js.map +1 -1
- package/dist/render-lifecycle.js +1 -34
- package/dist/render-lifecycle.js.map +1 -1
- package/package-tar/teambit-graphql-0.0.883.tgz +0 -0
- package/package.json +3 -3
- package/{preview-1666409808293.js → preview-1666582798766.js} +2 -2
- package/package-tar/teambit-graphql-0.0.881.tgz +0 -0
|
@@ -1,198 +1,139 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
require("core-js/modules/es.array.iterator.js");
|
|
6
|
-
|
|
7
5
|
require("core-js/modules/es.promise.js");
|
|
8
|
-
|
|
9
6
|
Object.defineProperty(exports, "__esModule", {
|
|
10
7
|
value: true
|
|
11
8
|
});
|
|
12
9
|
exports.Verb = exports.GraphqlMain = void 0;
|
|
13
|
-
|
|
14
10
|
function _defineProperty2() {
|
|
15
11
|
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
-
|
|
17
12
|
_defineProperty2 = function () {
|
|
18
13
|
return data;
|
|
19
14
|
};
|
|
20
|
-
|
|
21
15
|
return data;
|
|
22
16
|
}
|
|
23
|
-
|
|
24
17
|
function _graphqlTools() {
|
|
25
18
|
const data = require("graphql-tools");
|
|
26
|
-
|
|
27
19
|
_graphqlTools = function () {
|
|
28
20
|
return data;
|
|
29
21
|
};
|
|
30
|
-
|
|
31
22
|
return data;
|
|
32
23
|
}
|
|
33
|
-
|
|
34
24
|
function _core() {
|
|
35
25
|
const data = require("@graphql-modules/core");
|
|
36
|
-
|
|
37
26
|
_core = function () {
|
|
38
27
|
return data;
|
|
39
28
|
};
|
|
40
|
-
|
|
41
29
|
return data;
|
|
42
30
|
}
|
|
43
|
-
|
|
44
31
|
function _cli() {
|
|
45
32
|
const data = require("@teambit/cli");
|
|
46
|
-
|
|
47
33
|
_cli = function () {
|
|
48
34
|
return data;
|
|
49
35
|
};
|
|
50
|
-
|
|
51
36
|
return data;
|
|
52
37
|
}
|
|
53
|
-
|
|
54
38
|
function _harmony() {
|
|
55
39
|
const data = require("@teambit/harmony");
|
|
56
|
-
|
|
57
40
|
_harmony = function () {
|
|
58
41
|
return data;
|
|
59
42
|
};
|
|
60
|
-
|
|
61
43
|
return data;
|
|
62
44
|
}
|
|
63
|
-
|
|
64
45
|
function _logger() {
|
|
65
46
|
const data = require("@teambit/logger");
|
|
66
|
-
|
|
67
47
|
_logger = function () {
|
|
68
48
|
return data;
|
|
69
49
|
};
|
|
70
|
-
|
|
71
50
|
return data;
|
|
72
51
|
}
|
|
73
|
-
|
|
74
52
|
function _express() {
|
|
75
53
|
const data = _interopRequireDefault(require("express"));
|
|
76
|
-
|
|
77
54
|
_express = function () {
|
|
78
55
|
return data;
|
|
79
56
|
};
|
|
80
|
-
|
|
81
57
|
return data;
|
|
82
58
|
}
|
|
83
|
-
|
|
84
59
|
function _expressGraphql() {
|
|
85
60
|
const data = require("express-graphql");
|
|
86
|
-
|
|
87
61
|
_expressGraphql = function () {
|
|
88
62
|
return data;
|
|
89
63
|
};
|
|
90
|
-
|
|
91
64
|
return data;
|
|
92
65
|
}
|
|
93
|
-
|
|
94
66
|
function _toolboxNetwork() {
|
|
95
67
|
const data = require("@teambit/toolbox.network.get-port");
|
|
96
|
-
|
|
97
68
|
_toolboxNetwork = function () {
|
|
98
69
|
return data;
|
|
99
70
|
};
|
|
100
|
-
|
|
101
71
|
return data;
|
|
102
72
|
}
|
|
103
|
-
|
|
104
73
|
function _graphql() {
|
|
105
74
|
const data = require("graphql");
|
|
106
|
-
|
|
107
75
|
_graphql = function () {
|
|
108
76
|
return data;
|
|
109
77
|
};
|
|
110
|
-
|
|
111
78
|
return data;
|
|
112
79
|
}
|
|
113
|
-
|
|
114
80
|
function _graphqlSubscriptions() {
|
|
115
81
|
const data = require("graphql-subscriptions");
|
|
116
|
-
|
|
117
82
|
_graphqlSubscriptions = function () {
|
|
118
83
|
return data;
|
|
119
84
|
};
|
|
120
|
-
|
|
121
85
|
return data;
|
|
122
86
|
}
|
|
123
|
-
|
|
124
87
|
function _http() {
|
|
125
88
|
const data = require("http");
|
|
126
|
-
|
|
127
89
|
_http = function () {
|
|
128
90
|
return data;
|
|
129
91
|
};
|
|
130
|
-
|
|
131
92
|
return data;
|
|
132
93
|
}
|
|
133
|
-
|
|
134
94
|
function _httpProxy() {
|
|
135
95
|
const data = _interopRequireDefault(require("http-proxy"));
|
|
136
|
-
|
|
137
96
|
_httpProxy = function () {
|
|
138
97
|
return data;
|
|
139
98
|
};
|
|
140
|
-
|
|
141
99
|
return data;
|
|
142
100
|
}
|
|
143
|
-
|
|
144
101
|
function _subscriptionsTransportWs() {
|
|
145
102
|
const data = require("subscriptions-transport-ws");
|
|
146
|
-
|
|
147
103
|
_subscriptionsTransportWs = function () {
|
|
148
104
|
return data;
|
|
149
105
|
};
|
|
150
|
-
|
|
151
106
|
return data;
|
|
152
107
|
}
|
|
153
|
-
|
|
154
108
|
function _cors() {
|
|
155
109
|
const data = _interopRequireDefault(require("cors"));
|
|
156
|
-
|
|
157
110
|
_cors = function () {
|
|
158
111
|
return data;
|
|
159
112
|
};
|
|
160
|
-
|
|
161
113
|
return data;
|
|
162
114
|
}
|
|
163
|
-
|
|
164
115
|
function _createRemoteSchemas() {
|
|
165
116
|
const data = require("./create-remote-schemas");
|
|
166
|
-
|
|
167
117
|
_createRemoteSchemas = function () {
|
|
168
118
|
return data;
|
|
169
119
|
};
|
|
170
|
-
|
|
171
120
|
return data;
|
|
172
121
|
}
|
|
173
|
-
|
|
174
122
|
function _graphql2() {
|
|
175
123
|
const data = require("./graphql.aspect");
|
|
176
|
-
|
|
177
124
|
_graphql2 = function () {
|
|
178
125
|
return data;
|
|
179
126
|
};
|
|
180
|
-
|
|
181
127
|
return data;
|
|
182
128
|
}
|
|
183
|
-
|
|
184
129
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
185
|
-
|
|
186
130
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2().default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
187
|
-
|
|
188
131
|
let Verb;
|
|
189
132
|
exports.Verb = Verb;
|
|
190
|
-
|
|
191
133
|
(function (Verb) {
|
|
192
134
|
Verb["WRITE"] = "write";
|
|
193
135
|
Verb["READ"] = "read";
|
|
194
136
|
})(Verb || (exports.Verb = Verb = {}));
|
|
195
|
-
|
|
196
137
|
class GraphqlMain {
|
|
197
138
|
constructor(
|
|
198
139
|
/**
|
|
@@ -223,24 +164,21 @@ class GraphqlMain {
|
|
|
223
164
|
this.pubSubSlot = pubSubSlot;
|
|
224
165
|
(0, _defineProperty2().default)(this, "modules", new Map());
|
|
225
166
|
}
|
|
226
|
-
|
|
227
167
|
get pubsub() {
|
|
228
168
|
const pubSubSlots = this.pubSubSlot.values();
|
|
229
169
|
if (pubSubSlots.length) return pubSubSlots[0];
|
|
230
170
|
return new (_graphqlSubscriptions().PubSub)();
|
|
231
171
|
}
|
|
232
|
-
|
|
233
172
|
/**
|
|
234
173
|
* returns the schema for a specific aspect by its id.
|
|
235
174
|
*/
|
|
236
175
|
getSchema(aspectId) {
|
|
237
176
|
return this.moduleSlot.get(aspectId);
|
|
238
177
|
}
|
|
178
|
+
|
|
239
179
|
/**
|
|
240
180
|
* get multiple schema by aspect ids.
|
|
241
181
|
*/
|
|
242
|
-
|
|
243
|
-
|
|
244
182
|
getSchemas(aspectIds) {
|
|
245
183
|
return this.moduleSlot.toArray().filter(([aspectId]) => {
|
|
246
184
|
return aspectIds.includes(aspectId);
|
|
@@ -248,7 +186,6 @@ class GraphqlMain {
|
|
|
248
186
|
return schema;
|
|
249
187
|
});
|
|
250
188
|
}
|
|
251
|
-
|
|
252
189
|
async createServer(options) {
|
|
253
190
|
const {
|
|
254
191
|
graphiql = true
|
|
@@ -258,22 +195,23 @@ class GraphqlMain {
|
|
|
258
195
|
const schemas = [localSchema.schema].concat(remoteSchemas).filter(x => x);
|
|
259
196
|
const schema = (0, _graphqlTools().mergeSchemas)({
|
|
260
197
|
schemas
|
|
261
|
-
});
|
|
198
|
+
});
|
|
262
199
|
|
|
200
|
+
// TODO: @guy please consider to refactor to express extension.
|
|
263
201
|
const app = options.app || (0, _express().default)();
|
|
264
|
-
app.use(
|
|
202
|
+
app.use(
|
|
203
|
+
// @ts-ignore todo: it's not clear what's the issue.
|
|
265
204
|
(0, _cors().default)({
|
|
266
205
|
origin(origin, callback) {
|
|
267
206
|
callback(null, true);
|
|
268
207
|
},
|
|
269
|
-
|
|
270
208
|
credentials: true
|
|
271
209
|
}));
|
|
272
|
-
app.use('/graphql',
|
|
210
|
+
app.use('/graphql',
|
|
211
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
273
212
|
(0, _expressGraphql().graphqlHTTP)((request, res, params) => ({
|
|
274
213
|
customFormatErrorFn: err => {
|
|
275
214
|
var _err$originalError, _err$originalError$er, _err$originalError2, _err$originalError2$c, _err$originalError3, _err$originalError3$e, _err$originalError4;
|
|
276
|
-
|
|
277
215
|
this.logger.error('graphql got an error during running the following query:', params);
|
|
278
216
|
this.logger.error('graphql error ', err);
|
|
279
217
|
return Object.assign(err, {
|
|
@@ -296,31 +234,28 @@ class GraphqlMain {
|
|
|
296
234
|
this.proxySubscription(server, port);
|
|
297
235
|
return server;
|
|
298
236
|
}
|
|
237
|
+
|
|
299
238
|
/**
|
|
300
239
|
* register a new graphql server.
|
|
301
240
|
*/
|
|
302
|
-
|
|
303
|
-
|
|
304
241
|
registerServer(server) {
|
|
305
242
|
this.graphQLServerSlot.register(server);
|
|
306
243
|
return this;
|
|
307
244
|
}
|
|
245
|
+
|
|
308
246
|
/**
|
|
309
247
|
* register a pubsub client
|
|
310
248
|
*/
|
|
311
|
-
|
|
312
|
-
|
|
313
249
|
registerPubSub(pubsub) {
|
|
314
250
|
const pubSubSlots = this.pubSubSlot.toArray();
|
|
315
251
|
if (pubSubSlots.length) throw new Error('can not register more then one pubsub provider');
|
|
316
252
|
this.pubSubSlot.register(pubsub);
|
|
317
253
|
return this;
|
|
318
254
|
}
|
|
255
|
+
|
|
319
256
|
/**
|
|
320
257
|
* start a graphql server.
|
|
321
258
|
*/
|
|
322
|
-
|
|
323
|
-
|
|
324
259
|
async listen(port, server, app) {
|
|
325
260
|
const serverPort = port || this.config.port;
|
|
326
261
|
const subServer = server || (await this.createServer({
|
|
@@ -331,39 +266,39 @@ class GraphqlMain {
|
|
|
331
266
|
this.logger.info(`API Server over web socket with subscriptions is now running on ws://localhost:${serverPort}/${this.config.subscriptionsPath}`);
|
|
332
267
|
});
|
|
333
268
|
}
|
|
269
|
+
|
|
334
270
|
/**
|
|
335
271
|
* register a new graphql module.
|
|
336
272
|
*/
|
|
337
|
-
|
|
338
|
-
|
|
339
273
|
register(schema) {
|
|
340
274
|
// const module = new GraphQLModule(schema);
|
|
341
275
|
this.moduleSlot.register(schema);
|
|
342
276
|
return this;
|
|
343
277
|
}
|
|
344
|
-
|
|
345
278
|
async getPort(range) {
|
|
346
279
|
const [from, to] = range;
|
|
347
280
|
return _toolboxNetwork().Port.getPort(from, to);
|
|
348
281
|
}
|
|
349
|
-
/** create Subscription server with different port */
|
|
350
282
|
|
|
283
|
+
/** create Subscription server with different port */
|
|
351
284
|
|
|
352
285
|
async createSubscription(options, port) {
|
|
353
286
|
// Create WebSocket listener server
|
|
354
287
|
const websocketServer = (0, _http().createServer)((request, response) => {
|
|
355
288
|
response.writeHead(404);
|
|
356
289
|
response.end();
|
|
357
|
-
});
|
|
290
|
+
});
|
|
358
291
|
|
|
292
|
+
// Bind it to port and start listening
|
|
359
293
|
websocketServer.listen(port, () => this.logger.debug(`Websocket Server is now running on http://localhost:${port}`));
|
|
360
294
|
const localSchema = this.createRootModule(options.schemaSlot);
|
|
361
295
|
const remoteSchemas = await (0, _createRemoteSchemas().createRemoteSchemas)(options.remoteSchemas || this.graphQLServerSlot.values());
|
|
362
296
|
const schemas = [localSchema.schema].concat(remoteSchemas).filter(x => x);
|
|
363
297
|
const schema = (0, _graphqlTools().mergeSchemas)({
|
|
364
298
|
schemas
|
|
365
|
-
});
|
|
299
|
+
});
|
|
366
300
|
|
|
301
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
367
302
|
const subServer = new (_subscriptionsTransportWs().SubscriptionServer)({
|
|
368
303
|
execute: _graphql().execute,
|
|
369
304
|
subscribe: _graphql().subscribe,
|
|
@@ -380,10 +315,8 @@ class GraphqlMain {
|
|
|
380
315
|
}
|
|
381
316
|
/** proxy ws Subscription server to avoid conflict with different websocket connections */
|
|
382
317
|
|
|
383
|
-
|
|
384
318
|
proxySubscription(server, port) {
|
|
385
319
|
const proxServer = _httpProxy().default.createProxyServer();
|
|
386
|
-
|
|
387
320
|
const subscriptionsPath = this.config.subscriptionsPath;
|
|
388
321
|
server.on('upgrade', function (req, socket, head) {
|
|
389
322
|
if (req.url === subscriptionsPath) {
|
|
@@ -396,14 +329,12 @@ class GraphqlMain {
|
|
|
396
329
|
}
|
|
397
330
|
});
|
|
398
331
|
}
|
|
399
|
-
|
|
400
332
|
createRootModule(schemaSlot) {
|
|
401
333
|
const modules = this.buildModules(schemaSlot);
|
|
402
334
|
return new (_core().GraphQLModule)({
|
|
403
335
|
imports: modules
|
|
404
336
|
});
|
|
405
337
|
}
|
|
406
|
-
|
|
407
338
|
buildModules(schemaSlot) {
|
|
408
339
|
const schemaSlots = schemaSlot ? schemaSlot.toArray() : this.moduleSlot.toArray();
|
|
409
340
|
return schemaSlots.map(([extensionId, schema]) => {
|
|
@@ -415,7 +346,6 @@ class GraphqlMain {
|
|
|
415
346
|
imports: moduleDeps,
|
|
416
347
|
context: session => {
|
|
417
348
|
var _session$headers;
|
|
418
|
-
|
|
419
349
|
return _objectSpread(_objectSpread({}, session), {}, {
|
|
420
350
|
verb: (session === null || session === void 0 ? void 0 : (_session$headers = session.headers) === null || _session$headers === void 0 ? void 0 : _session$headers['x-verb']) || Verb.READ
|
|
421
351
|
});
|
|
@@ -425,28 +355,25 @@ class GraphqlMain {
|
|
|
425
355
|
return module;
|
|
426
356
|
});
|
|
427
357
|
}
|
|
428
|
-
|
|
429
358
|
getModuleDependencies(extensionId) {
|
|
430
359
|
const extension = this.context.extensions.get(extensionId);
|
|
431
360
|
if (!extension) throw new Error(`aspect ${extensionId} was not found`);
|
|
432
361
|
const deps = this.context.getDependencies(extension);
|
|
433
|
-
const ids = deps.map(dep => dep.id);
|
|
362
|
+
const ids = deps.map(dep => dep.id);
|
|
434
363
|
|
|
364
|
+
// @ts-ignore check :TODO why types are breaking here.
|
|
435
365
|
return Array.from(this.modules.entries()).map(([depId, module]) => {
|
|
436
366
|
const dep = ids.includes(depId);
|
|
437
367
|
if (!dep) return undefined;
|
|
438
368
|
return module;
|
|
439
369
|
}).filter(module => !!module);
|
|
440
370
|
}
|
|
441
|
-
|
|
442
371
|
static async provider([loggerFactory], config, [moduleSlot, graphQLServerSlot, pubSubSlot], context) {
|
|
443
372
|
const logger = loggerFactory.createLogger(_graphql2().GraphqlAspect.id);
|
|
444
373
|
const graphqlMain = new GraphqlMain(config, moduleSlot, context, logger, graphQLServerSlot, pubSubSlot);
|
|
445
374
|
return graphqlMain;
|
|
446
375
|
}
|
|
447
|
-
|
|
448
376
|
}
|
|
449
|
-
|
|
450
377
|
exports.GraphqlMain = GraphqlMain;
|
|
451
378
|
(0, _defineProperty2().default)(GraphqlMain, "slots", [_harmony().Slot.withType(), _harmony().Slot.withType(), _harmony().Slot.withType()]);
|
|
452
379
|
(0, _defineProperty2().default)(GraphqlMain, "defaultConfig", {
|
|
@@ -456,7 +383,6 @@ exports.GraphqlMain = GraphqlMain;
|
|
|
456
383
|
});
|
|
457
384
|
(0, _defineProperty2().default)(GraphqlMain, "runtime", _cli().MainRuntime);
|
|
458
385
|
(0, _defineProperty2().default)(GraphqlMain, "dependencies", [_logger().LoggerAspect]);
|
|
459
|
-
|
|
460
386
|
_graphql2().GraphqlAspect.addRuntime(GraphqlMain);
|
|
461
387
|
|
|
462
388
|
//# sourceMappingURL=graphql.main.runtime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Verb","GraphqlMain","constructor","config","moduleSlot","context","logger","graphQLServerSlot","pubSubSlot","Map","pubsub","pubSubSlots","values","length","PubSub","getSchema","aspectId","get","getSchemas","aspectIds","toArray","filter","includes","map","schema","createServer","options","graphiql","localSchema","createRootModule","schemaSlot","remoteSchemas","createRemoteSchemas","schemas","concat","x","mergeSchemas","app","express","use","cors","origin","callback","credentials","graphqlHTTP","request","res","params","customFormatErrorFn","err","error","Object","assign","ERR_CODE","originalError","errors","name","HTTP_CODE","code","rootValue","server","subscriptionsPort","subscriptionsPortRange","subscriptionServerPort","getPort","port","createSubscription","proxySubscription","registerServer","register","registerPubSub","Error","listen","serverPort","subServer","info","subscriptionsPath","range","from","to","Port","websocketServer","response","writeHead","end","debug","SubscriptionServer","execute","subscribe","onConnect","onWsConnect","path","proxServer","httpProxy","createProxyServer","on","req","socket","head","url","ws","target","host","modules","buildModules","GraphQLModule","imports","schemaSlots","extensionId","moduleDeps","getModuleDependencies","module","typeDefs","resolvers","schemaDirectives","session","verb","headers","READ","set","extension","extensions","deps","getDependencies","ids","dep","id","Array","entries","depId","undefined","provider","loggerFactory","createLogger","GraphqlAspect","graphqlMain","Slot","withType","MainRuntime","LoggerAspect","addRuntime"],"sources":["graphql.main.runtime.ts"],"sourcesContent":["import { mergeSchemas } from 'graphql-tools';\nimport { GraphQLModule } from '@graphql-modules/core';\nimport { MainRuntime } from '@teambit/cli';\nimport { Harmony, Slot, SlotRegistry } from '@teambit/harmony';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport express, { Express } from 'express';\nimport { graphqlHTTP } from 'express-graphql';\nimport { Port } from '@teambit/toolbox.network.get-port';\nimport { execute, subscribe } from 'graphql';\nimport { PubSubEngine, PubSub } from 'graphql-subscriptions';\nimport { createServer, Server } from 'http';\nimport httpProxy from 'http-proxy';\nimport { SubscriptionServer } from 'subscriptions-transport-ws';\nimport cors from 'cors';\nimport { GraphQLServer } from './graphql-server';\nimport { createRemoteSchemas } from './create-remote-schemas';\nimport { GraphqlAspect } from './graphql.aspect';\nimport { Schema } from './schema';\n\nexport enum Verb {\n WRITE = 'write',\n READ = 'read',\n}\n\nexport type GraphQLConfig = {\n port: number;\n subscriptionsPortRange: number[];\n subscriptionsPath: string;\n};\n\nexport type GraphQLServerSlot = SlotRegistry<GraphQLServer>;\n\nexport type SchemaSlot = SlotRegistry<Schema>;\n\nexport type PubSubSlot = SlotRegistry<PubSubEngine>;\n\nexport type GraphQLServerOptions = {\n schemaSlot?: SchemaSlot;\n app?: Express;\n graphiql?: boolean;\n remoteSchemas?: GraphQLServer[];\n subscriptionsPortRange?: number[];\n onWsConnect?: Function;\n};\n\nexport class GraphqlMain {\n constructor(\n /**\n * extension config\n */\n readonly config: GraphQLConfig,\n\n /**\n * slot for registering graphql modules\n */\n private moduleSlot: SchemaSlot,\n\n /**\n * harmony context.\n */\n private context: Harmony,\n\n /**\n * logger extension.\n */\n readonly logger: Logger,\n\n private graphQLServerSlot: GraphQLServerSlot,\n\n /**\n * graphql pubsub. allows to emit events to clients.\n */\n private pubSubSlot: PubSubSlot\n ) {}\n\n get pubsub(): PubSubEngine {\n const pubSubSlots = this.pubSubSlot.values();\n if (pubSubSlots.length) return pubSubSlots[0];\n return new PubSub();\n }\n\n private modules = new Map<string, GraphQLModule>();\n\n /**\n * returns the schema for a specific aspect by its id.\n */\n getSchema(aspectId: string) {\n return this.moduleSlot.get(aspectId);\n }\n\n /**\n * get multiple schema by aspect ids.\n */\n getSchemas(aspectIds: string[]) {\n return this.moduleSlot\n .toArray()\n .filter(([aspectId]) => {\n return aspectIds.includes(aspectId);\n })\n .map(([, schema]) => {\n return schema;\n });\n }\n\n async createServer(options: GraphQLServerOptions) {\n const { graphiql = true } = options;\n const localSchema = this.createRootModule(options.schemaSlot);\n const remoteSchemas = await createRemoteSchemas(options.remoteSchemas || this.graphQLServerSlot.values());\n const schemas = [localSchema.schema].concat(remoteSchemas).filter((x) => x);\n const schema = mergeSchemas({\n schemas,\n });\n\n // TODO: @guy please consider to refactor to express extension.\n const app = options.app || express();\n app.use(\n // @ts-ignore todo: it's not clear what's the issue.\n cors({\n origin(origin, callback) {\n callback(null, true);\n },\n credentials: true,\n })\n );\n\n app.use(\n '/graphql',\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n graphqlHTTP((request, res, params) => ({\n customFormatErrorFn: (err) => {\n this.logger.error('graphql got an error during running the following query:', params);\n this.logger.error('graphql error ', err);\n return Object.assign(err, {\n // @ts-ignore\n ERR_CODE: err?.originalError?.errors?.[0].ERR_CODE || err.originalError?.constructor?.name,\n // @ts-ignore\n HTTP_CODE: err?.originalError?.errors?.[0].HTTP_CODE || err.originalError?.code,\n });\n },\n schema,\n rootValue: request,\n graphiql,\n }))\n );\n\n const server = createServer(app);\n const subscriptionsPort = options.subscriptionsPortRange || this.config.subscriptionsPortRange;\n const subscriptionServerPort = await this.getPort(subscriptionsPort);\n const { port } = await this.createSubscription(options, subscriptionServerPort);\n this.proxySubscription(server, port);\n\n return server;\n }\n\n /**\n * register a new graphql server.\n */\n registerServer(server: GraphQLServer) {\n this.graphQLServerSlot.register(server);\n return this;\n }\n\n /**\n * register a pubsub client\n */\n registerPubSub(pubsub: PubSubEngine) {\n const pubSubSlots = this.pubSubSlot.toArray();\n if (pubSubSlots.length) throw new Error('can not register more then one pubsub provider');\n this.pubSubSlot.register(pubsub);\n return this;\n }\n\n /**\n * start a graphql server.\n */\n async listen(port?: number, server?: Server, app?: Express) {\n const serverPort = port || this.config.port;\n const subServer = server || (await this.createServer({ app }));\n\n subServer.listen(serverPort, () => {\n this.logger.info(`API Server over HTTP is now running on http://localhost:${serverPort}`);\n this.logger.info(\n `API Server over web socket with subscriptions is now running on ws://localhost:${serverPort}/${this.config.subscriptionsPath}`\n );\n });\n }\n\n /**\n * register a new graphql module.\n */\n register(schema: Schema) {\n // const module = new GraphQLModule(schema);\n this.moduleSlot.register(schema);\n return this;\n }\n\n private async getPort(range: number[]) {\n const [from, to] = range;\n return Port.getPort(from, to);\n }\n\n /** create Subscription server with different port */\n\n private async createSubscription(options: GraphQLServerOptions, port: number) {\n // Create WebSocket listener server\n const websocketServer = createServer((request, response) => {\n response.writeHead(404);\n response.end();\n });\n\n // Bind it to port and start listening\n websocketServer.listen(port, () =>\n this.logger.debug(`Websocket Server is now running on http://localhost:${port}`)\n );\n\n const localSchema = this.createRootModule(options.schemaSlot);\n const remoteSchemas = await createRemoteSchemas(options.remoteSchemas || this.graphQLServerSlot.values());\n const schemas = [localSchema.schema].concat(remoteSchemas).filter((x) => x);\n const schema = mergeSchemas({\n schemas,\n });\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const subServer = new SubscriptionServer(\n {\n execute,\n subscribe,\n schema,\n onConnect: options.onWsConnect,\n },\n {\n server: websocketServer,\n path: this.config.subscriptionsPath,\n }\n );\n return { subServer, port };\n }\n /** proxy ws Subscription server to avoid conflict with different websocket connections */\n\n private proxySubscription(server: Server, port: number) {\n const proxServer = httpProxy.createProxyServer();\n const subscriptionsPath = this.config.subscriptionsPath;\n server.on('upgrade', function (req, socket, head) {\n if (req.url === subscriptionsPath) {\n proxServer.ws(req, socket, head, { target: { host: 'localhost', port } });\n }\n });\n }\n\n private createRootModule(schemaSlot?: SchemaSlot) {\n const modules = this.buildModules(schemaSlot);\n\n return new GraphQLModule({\n imports: modules,\n });\n }\n\n private buildModules(schemaSlot?: SchemaSlot) {\n const schemaSlots = schemaSlot ? schemaSlot.toArray() : this.moduleSlot.toArray();\n return schemaSlots.map(([extensionId, schema]) => {\n const moduleDeps = this.getModuleDependencies(extensionId);\n\n const module = new GraphQLModule({\n typeDefs: schema.typeDefs,\n resolvers: schema.resolvers,\n schemaDirectives: schema.schemaDirectives,\n imports: moduleDeps,\n context: (session) => {\n return {\n ...session,\n verb: session?.headers?.['x-verb'] || Verb.READ,\n };\n },\n });\n\n this.modules.set(extensionId, module);\n\n return module;\n });\n }\n\n private getModuleDependencies(extensionId: string): GraphQLModule[] {\n const extension = this.context.extensions.get(extensionId);\n if (!extension) throw new Error(`aspect ${extensionId} was not found`);\n const deps = this.context.getDependencies(extension);\n const ids = deps.map((dep) => dep.id);\n\n // @ts-ignore check :TODO why types are breaking here.\n return Array.from(this.modules.entries())\n .map(([depId, module]) => {\n const dep = ids.includes(depId);\n if (!dep) return undefined;\n return module;\n })\n .filter((module) => !!module);\n }\n\n static slots = [Slot.withType<Schema>(), Slot.withType<GraphQLServer>(), Slot.withType<PubSubSlot>()];\n\n static defaultConfig = {\n port: 4000,\n subscriptionsPortRange: [2000, 2100],\n subscriptionsPath: '/subscriptions',\n };\n\n static runtime = MainRuntime;\n static dependencies = [LoggerAspect];\n\n static async provider(\n [loggerFactory]: [LoggerMain],\n config: GraphQLConfig,\n [moduleSlot, graphQLServerSlot, pubSubSlot]: [SchemaSlot, GraphQLServerSlot, PubSubSlot],\n context: Harmony\n ) {\n const logger = loggerFactory.createLogger(GraphqlAspect.id);\n const graphqlMain = new GraphqlMain(config, moduleSlot, context, logger, graphQLServerSlot, pubSubSlot);\n return graphqlMain;\n }\n}\n\nGraphqlAspect.addRuntime(GraphqlMain);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AA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QLServerSlot","pubSubSlot","Map","pubsub","pubSubSlots","values","length","PubSub","getSchema","aspectId","get","getSchemas","aspectIds","toArray","filter","includes","map","schema","createServer","options","graphiql","localSchema","createRootModule","schemaSlot","remoteSchemas","createRemoteSchemas","schemas","concat","x","mergeSchemas","app","express","use","cors","origin","callback","credentials","graphqlHTTP","request","res","params","customFormatErrorFn","err","error","Object","assign","ERR_CODE","originalError","errors","name","HTTP_CODE","code","rootValue","server","subscriptionsPort","subscriptionsPortRange","subscriptionServerPort","getPort","port","createSubscription","proxySubscription","registerServer","register","registerPubSub","Error","listen","serverPort","subServer","info","subscriptionsPath","range","from","to","Port","websocketServer","response","writeHead","end","debug","SubscriptionServer","execute","subscribe","onConnect","onWsConnect","path","proxServer","httpProxy","createProxyServer","on","req","socket","head","url","ws","target","host","modules","buildModules","GraphQLModule","imports","schemaSlots","extensionId","moduleDeps","getModuleDependencies","module","typeDefs","resolvers","schemaDirectives","session","verb","headers","READ","set","extension","extensions","deps","getDependencies","ids","dep","id","Array","entries","depId","undefined","provider","loggerFactory","createLogger","GraphqlAspect","graphqlMain","Slot","withType","MainRuntime","LoggerAspect","addRuntime"],"sources":["graphql.main.runtime.ts"],"sourcesContent":["import { mergeSchemas } from 'graphql-tools';\nimport { GraphQLModule } from '@graphql-modules/core';\nimport { MainRuntime } from '@teambit/cli';\nimport { Harmony, Slot, SlotRegistry } from '@teambit/harmony';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport express, { Express } from 'express';\nimport { graphqlHTTP } from 'express-graphql';\nimport { Port } from '@teambit/toolbox.network.get-port';\nimport { execute, subscribe } from 'graphql';\nimport { PubSubEngine, PubSub } from 'graphql-subscriptions';\nimport { createServer, Server } from 'http';\nimport httpProxy from 'http-proxy';\nimport { SubscriptionServer } from 'subscriptions-transport-ws';\nimport cors from 'cors';\nimport { GraphQLServer } from './graphql-server';\nimport { createRemoteSchemas } from './create-remote-schemas';\nimport { GraphqlAspect } from './graphql.aspect';\nimport { Schema } from './schema';\n\nexport enum Verb {\n WRITE = 'write',\n READ = 'read',\n}\n\nexport type GraphQLConfig = {\n port: number;\n subscriptionsPortRange: number[];\n subscriptionsPath: string;\n};\n\nexport type GraphQLServerSlot = SlotRegistry<GraphQLServer>;\n\nexport type SchemaSlot = SlotRegistry<Schema>;\n\nexport type PubSubSlot = SlotRegistry<PubSubEngine>;\n\nexport type GraphQLServerOptions = {\n schemaSlot?: SchemaSlot;\n app?: Express;\n graphiql?: boolean;\n remoteSchemas?: GraphQLServer[];\n subscriptionsPortRange?: number[];\n onWsConnect?: Function;\n};\n\nexport class GraphqlMain {\n constructor(\n /**\n * extension config\n */\n readonly config: GraphQLConfig,\n\n /**\n * slot for registering graphql modules\n */\n private moduleSlot: SchemaSlot,\n\n /**\n * harmony context.\n */\n private context: Harmony,\n\n /**\n * logger extension.\n */\n readonly logger: Logger,\n\n private graphQLServerSlot: GraphQLServerSlot,\n\n /**\n * graphql pubsub. allows to emit events to clients.\n */\n private pubSubSlot: PubSubSlot\n ) {}\n\n get pubsub(): PubSubEngine {\n const pubSubSlots = this.pubSubSlot.values();\n if (pubSubSlots.length) return pubSubSlots[0];\n return new PubSub();\n }\n\n private modules = new Map<string, GraphQLModule>();\n\n /**\n * returns the schema for a specific aspect by its id.\n */\n getSchema(aspectId: string) {\n return this.moduleSlot.get(aspectId);\n }\n\n /**\n * get multiple schema by aspect ids.\n */\n getSchemas(aspectIds: string[]) {\n return this.moduleSlot\n .toArray()\n .filter(([aspectId]) => {\n return aspectIds.includes(aspectId);\n })\n .map(([, schema]) => {\n return schema;\n });\n }\n\n async createServer(options: GraphQLServerOptions) {\n const { graphiql = true } = options;\n const localSchema = this.createRootModule(options.schemaSlot);\n const remoteSchemas = await createRemoteSchemas(options.remoteSchemas || this.graphQLServerSlot.values());\n const schemas = [localSchema.schema].concat(remoteSchemas).filter((x) => x);\n const schema = mergeSchemas({\n schemas,\n });\n\n // TODO: @guy please consider to refactor to express extension.\n const app = options.app || express();\n app.use(\n // @ts-ignore todo: it's not clear what's the issue.\n cors({\n origin(origin, callback) {\n callback(null, true);\n },\n credentials: true,\n })\n );\n\n app.use(\n '/graphql',\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n graphqlHTTP((request, res, params) => ({\n customFormatErrorFn: (err) => {\n this.logger.error('graphql got an error during running the following query:', params);\n this.logger.error('graphql error ', err);\n return Object.assign(err, {\n // @ts-ignore\n ERR_CODE: err?.originalError?.errors?.[0].ERR_CODE || err.originalError?.constructor?.name,\n // @ts-ignore\n HTTP_CODE: err?.originalError?.errors?.[0].HTTP_CODE || err.originalError?.code,\n });\n },\n schema,\n rootValue: request,\n graphiql,\n }))\n );\n\n const server = createServer(app);\n const subscriptionsPort = options.subscriptionsPortRange || this.config.subscriptionsPortRange;\n const subscriptionServerPort = await this.getPort(subscriptionsPort);\n const { port } = await this.createSubscription(options, subscriptionServerPort);\n this.proxySubscription(server, port);\n\n return server;\n }\n\n /**\n * register a new graphql server.\n */\n registerServer(server: GraphQLServer) {\n this.graphQLServerSlot.register(server);\n return this;\n }\n\n /**\n * register a pubsub client\n */\n registerPubSub(pubsub: PubSubEngine) {\n const pubSubSlots = this.pubSubSlot.toArray();\n if (pubSubSlots.length) throw new Error('can not register more then one pubsub provider');\n this.pubSubSlot.register(pubsub);\n return this;\n }\n\n /**\n * start a graphql server.\n */\n async listen(port?: number, server?: Server, app?: Express) {\n const serverPort = port || this.config.port;\n const subServer = server || (await this.createServer({ app }));\n\n subServer.listen(serverPort, () => {\n this.logger.info(`API Server over HTTP is now running on http://localhost:${serverPort}`);\n this.logger.info(\n `API Server over web socket with subscriptions is now running on ws://localhost:${serverPort}/${this.config.subscriptionsPath}`\n );\n });\n }\n\n /**\n * register a new graphql module.\n */\n register(schema: Schema) {\n // const module = new GraphQLModule(schema);\n this.moduleSlot.register(schema);\n return this;\n }\n\n private async getPort(range: number[]) {\n const [from, to] = range;\n return Port.getPort(from, to);\n }\n\n /** create Subscription server with different port */\n\n private async createSubscription(options: GraphQLServerOptions, port: number) {\n // Create WebSocket listener server\n const websocketServer = createServer((request, response) => {\n response.writeHead(404);\n response.end();\n });\n\n // Bind it to port and start listening\n websocketServer.listen(port, () =>\n this.logger.debug(`Websocket Server is now running on http://localhost:${port}`)\n );\n\n const localSchema = this.createRootModule(options.schemaSlot);\n const remoteSchemas = await createRemoteSchemas(options.remoteSchemas || this.graphQLServerSlot.values());\n const schemas = [localSchema.schema].concat(remoteSchemas).filter((x) => x);\n const schema = mergeSchemas({\n schemas,\n });\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const subServer = new SubscriptionServer(\n {\n execute,\n subscribe,\n schema,\n onConnect: options.onWsConnect,\n },\n {\n server: websocketServer,\n path: this.config.subscriptionsPath,\n }\n );\n return { subServer, port };\n }\n /** proxy ws Subscription server to avoid conflict with different websocket connections */\n\n private proxySubscription(server: Server, port: number) {\n const proxServer = httpProxy.createProxyServer();\n const subscriptionsPath = this.config.subscriptionsPath;\n server.on('upgrade', function (req, socket, head) {\n if (req.url === subscriptionsPath) {\n proxServer.ws(req, socket, head, { target: { host: 'localhost', port } });\n }\n });\n }\n\n private createRootModule(schemaSlot?: SchemaSlot) {\n const modules = this.buildModules(schemaSlot);\n\n return new GraphQLModule({\n imports: modules,\n });\n }\n\n private buildModules(schemaSlot?: SchemaSlot) {\n const schemaSlots = schemaSlot ? schemaSlot.toArray() : this.moduleSlot.toArray();\n return schemaSlots.map(([extensionId, schema]) => {\n const moduleDeps = this.getModuleDependencies(extensionId);\n\n const module = new GraphQLModule({\n typeDefs: schema.typeDefs,\n resolvers: schema.resolvers,\n schemaDirectives: schema.schemaDirectives,\n imports: moduleDeps,\n context: (session) => {\n return {\n ...session,\n verb: session?.headers?.['x-verb'] || Verb.READ,\n };\n },\n });\n\n this.modules.set(extensionId, module);\n\n return module;\n });\n }\n\n private getModuleDependencies(extensionId: string): GraphQLModule[] {\n const extension = this.context.extensions.get(extensionId);\n if (!extension) throw new Error(`aspect ${extensionId} was not found`);\n const deps = this.context.getDependencies(extension);\n const ids = deps.map((dep) => dep.id);\n\n // @ts-ignore check :TODO why types are breaking here.\n return Array.from(this.modules.entries())\n .map(([depId, module]) => {\n const dep = ids.includes(depId);\n if (!dep) return undefined;\n return module;\n })\n .filter((module) => !!module);\n }\n\n static slots = [Slot.withType<Schema>(), Slot.withType<GraphQLServer>(), Slot.withType<PubSubSlot>()];\n\n static defaultConfig = {\n port: 4000,\n subscriptionsPortRange: [2000, 2100],\n subscriptionsPath: '/subscriptions',\n };\n\n static runtime = MainRuntime;\n static dependencies = [LoggerAspect];\n\n static async provider(\n [loggerFactory]: [LoggerMain],\n config: GraphQLConfig,\n [moduleSlot, graphQLServerSlot, pubSubSlot]: [SchemaSlot, GraphQLServerSlot, PubSubSlot],\n context: Harmony\n ) {\n const logger = loggerFactory.createLogger(GraphqlAspect.id);\n const graphqlMain = new GraphqlMain(config, moduleSlot, context, logger, graphQLServerSlot, pubSubSlot);\n return graphqlMain;\n }\n}\n\nGraphqlAspect.addRuntime(GraphqlMain);\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA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