@graphql-tools/merge 6.2.17 → 8.0.1

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/es5/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  export * from './merge-resolvers';
2
2
  export * from './typedefs-mergers';
3
- export * from './merge-schemas';
4
3
  export * from './extensions';
package/es5/index.js CHANGED
@@ -5,7 +5,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  const tslib = require('tslib');
6
6
  const utils = require('@graphql-tools/utils/es5');
7
7
  const graphql = require('graphql');
8
- const schema = require('@graphql-tools/schema/es5');
9
8
 
10
9
  /**
11
10
  * Deep merges multiple resolver definition objects into a single definition.
@@ -108,432 +107,6 @@ function deduplicateArguments(args) {
108
107
  }, []);
109
108
  }
110
109
 
111
- var MAX_LINE_LENGTH = 80;
112
- var commentsRegistry = {};
113
- function resetComments() {
114
- commentsRegistry = {};
115
- }
116
- function collectComment(node) {
117
- var e_1, _a, e_2, _b, e_3, _c;
118
- var _d;
119
- var entityName = (_d = node.name) === null || _d === void 0 ? void 0 : _d.value;
120
- if (entityName == null) {
121
- return;
122
- }
123
- pushComment(node, entityName);
124
- switch (node.kind) {
125
- case 'EnumTypeDefinition':
126
- if (node.values) {
127
- try {
128
- for (var _e = tslib.__values(node.values), _f = _e.next(); !_f.done; _f = _e.next()) {
129
- var value = _f.value;
130
- pushComment(value, entityName, value.name.value);
131
- }
132
- }
133
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
134
- finally {
135
- try {
136
- if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
137
- }
138
- finally { if (e_1) throw e_1.error; }
139
- }
140
- }
141
- break;
142
- case 'ObjectTypeDefinition':
143
- case 'InputObjectTypeDefinition':
144
- case 'InterfaceTypeDefinition':
145
- if (node.fields) {
146
- try {
147
- for (var _g = tslib.__values(node.fields), _h = _g.next(); !_h.done; _h = _g.next()) {
148
- var field = _h.value;
149
- pushComment(field, entityName, field.name.value);
150
- if (isFieldDefinitionNode(field) && field.arguments) {
151
- try {
152
- for (var _j = (e_3 = void 0, tslib.__values(field.arguments)), _k = _j.next(); !_k.done; _k = _j.next()) {
153
- var arg = _k.value;
154
- pushComment(arg, entityName, field.name.value, arg.name.value);
155
- }
156
- }
157
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
158
- finally {
159
- try {
160
- if (_k && !_k.done && (_c = _j.return)) _c.call(_j);
161
- }
162
- finally { if (e_3) throw e_3.error; }
163
- }
164
- }
165
- }
166
- }
167
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
168
- finally {
169
- try {
170
- if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
171
- }
172
- finally { if (e_2) throw e_2.error; }
173
- }
174
- }
175
- break;
176
- }
177
- }
178
- function pushComment(node, entity, field, argument) {
179
- var comment = graphql.getDescription(node, { commentDescriptions: true });
180
- if (typeof comment !== 'string' || comment.length === 0) {
181
- return;
182
- }
183
- var keys = [entity];
184
- if (field) {
185
- keys.push(field);
186
- if (argument) {
187
- keys.push(argument);
188
- }
189
- }
190
- var path = keys.join('.');
191
- if (!commentsRegistry[path]) {
192
- commentsRegistry[path] = [];
193
- }
194
- commentsRegistry[path].push(comment);
195
- }
196
- function printComment(comment) {
197
- return '\n# ' + comment.replace(/\n/g, '\n# ');
198
- }
199
- /**
200
- * Copyright (c) 2015-present, Facebook, Inc.
201
- *
202
- * This source code is licensed under the MIT license found in the
203
- * LICENSE file in the root directory of this source tree.
204
- */
205
- /**
206
- * NOTE: ==> This file has been modified just to add comments to the printed AST
207
- * This is a temp measure, we will move to using the original non modified printer.js ASAP.
208
- */
209
- // import { visit, VisitFn } from 'graphql';
210
- /**
211
- * Given maybeArray, print an empty string if it is null or empty, otherwise
212
- * print all items together separated by separator if provided
213
- */
214
- function join(maybeArray, separator) {
215
- return maybeArray ? maybeArray.filter(function (x) { return x; }).join(separator || '') : '';
216
- }
217
- function hasMultilineItems(maybeArray) {
218
- var _a;
219
- return (_a = maybeArray === null || maybeArray === void 0 ? void 0 : maybeArray.some(function (str) { return str.includes('\n'); })) !== null && _a !== void 0 ? _a : false;
220
- }
221
- function addDescription(cb) {
222
- return function (node, _key, _parent, path, ancestors) {
223
- var _a;
224
- var keys = [];
225
- var parent = path.reduce(function (prev, key) {
226
- if (['fields', 'arguments', 'values'].includes(key) && prev.name) {
227
- keys.push(prev.name.value);
228
- }
229
- return prev[key];
230
- }, ancestors[0]);
231
- var key = tslib.__spreadArray(tslib.__spreadArray([], tslib.__read(keys)), [(_a = parent === null || parent === void 0 ? void 0 : parent.name) === null || _a === void 0 ? void 0 : _a.value]).filter(Boolean).join('.');
232
- var items = [];
233
- if (node.kind.includes('Definition') && commentsRegistry[key]) {
234
- items.push.apply(items, tslib.__spreadArray([], tslib.__read(commentsRegistry[key])));
235
- }
236
- return join(tslib.__spreadArray(tslib.__spreadArray([], tslib.__read(items.map(printComment))), [node.description, cb(node)]), '\n');
237
- };
238
- }
239
- function indent(maybeString) {
240
- return maybeString && " " + maybeString.replace(/\n/g, '\n ');
241
- }
242
- /**
243
- * Given array, print each item on its own line, wrapped in an
244
- * indented "{ }" block.
245
- */
246
- function block(array) {
247
- return array && array.length !== 0 ? "{\n" + indent(join(array, '\n')) + "\n}" : '';
248
- }
249
- /**
250
- * If maybeString is not null or empty, then wrap with start and end, otherwise
251
- * print an empty string.
252
- */
253
- function wrap(start, maybeString, end) {
254
- return maybeString ? start + maybeString + (end || '') : '';
255
- }
256
- /**
257
- * Print a block string in the indented block form by adding a leading and
258
- * trailing blank line. However, if a block string starts with whitespace and is
259
- * a single-line, adding a leading blank line would strip that whitespace.
260
- */
261
- function printBlockString(value, isDescription) {
262
- if (isDescription === void 0) { isDescription = false; }
263
- var escaped = value.replace(/"""/g, '\\"""');
264
- return (value[0] === ' ' || value[0] === '\t') && value.indexOf('\n') === -1
265
- ? "\"\"\"" + escaped.replace(/"$/, '"\n') + "\"\"\""
266
- : "\"\"\"\n" + (isDescription ? escaped : indent(escaped)) + "\n\"\"\"";
267
- }
268
- var printDocASTReducer = {
269
- Name: { leave: function (node) { return node.value; } },
270
- Variable: { leave: function (node) { return '$' + node.name; } },
271
- // Document
272
- Document: {
273
- leave: function (node) { return join(node.definitions, '\n\n'); },
274
- },
275
- OperationDefinition: {
276
- leave: function (node) {
277
- var varDefs = wrap('(', join(node.variableDefinitions, ', '), ')');
278
- var prefix = join([node.operation, join([node.name, varDefs]), join(node.directives, ' ')], ' ');
279
- // the query short form.
280
- return prefix + ' ' + node.selectionSet;
281
- },
282
- },
283
- VariableDefinition: {
284
- leave: function (_a) {
285
- var variable = _a.variable, type = _a.type, defaultValue = _a.defaultValue, directives = _a.directives;
286
- return variable + ': ' + type + wrap(' = ', defaultValue) + wrap(' ', join(directives, ' '));
287
- },
288
- },
289
- SelectionSet: { leave: function (_a) {
290
- var selections = _a.selections;
291
- return block(selections);
292
- } },
293
- Field: {
294
- leave: function (_a) {
295
- var alias = _a.alias, name = _a.name, args = _a.arguments, directives = _a.directives, selectionSet = _a.selectionSet;
296
- var prefix = wrap('', alias, ': ') + name;
297
- var argsLine = prefix + wrap('(', join(args, ', '), ')');
298
- if (argsLine.length > MAX_LINE_LENGTH) {
299
- argsLine = prefix + wrap('(\n', indent(join(args, '\n')), '\n)');
300
- }
301
- return join([argsLine, join(directives, ' '), selectionSet], ' ');
302
- },
303
- },
304
- Argument: { leave: function (_a) {
305
- var name = _a.name, value = _a.value;
306
- return name + ': ' + value;
307
- } },
308
- // Fragments
309
- FragmentSpread: {
310
- leave: function (_a) {
311
- var name = _a.name, directives = _a.directives;
312
- return '...' + name + wrap(' ', join(directives, ' '));
313
- },
314
- },
315
- InlineFragment: {
316
- leave: function (_a) {
317
- var typeCondition = _a.typeCondition, directives = _a.directives, selectionSet = _a.selectionSet;
318
- return join(['...', wrap('on ', typeCondition), join(directives, ' '), selectionSet], ' ');
319
- },
320
- },
321
- FragmentDefinition: {
322
- leave: function (_a) {
323
- var name = _a.name, typeCondition = _a.typeCondition, variableDefinitions = _a.variableDefinitions, directives = _a.directives, selectionSet = _a.selectionSet;
324
- // Note: fragment variable definitions are experimental and may be changed
325
- // or removed in the future.
326
- return "fragment " + name + wrap('(', join(variableDefinitions, ', '), ')') + " " +
327
- ("on " + typeCondition + " " + wrap('', join(directives, ' '), ' ')) +
328
- selectionSet;
329
- },
330
- },
331
- // Value
332
- IntValue: { leave: function (_a) {
333
- var value = _a.value;
334
- return value;
335
- } },
336
- FloatValue: { leave: function (_a) {
337
- var value = _a.value;
338
- return value;
339
- } },
340
- StringValue: {
341
- leave: function (_a) {
342
- var value = _a.value, isBlockString = _a.block;
343
- return (isBlockString ? printBlockString(value) : JSON.stringify(value));
344
- },
345
- },
346
- BooleanValue: { leave: function (_a) {
347
- var value = _a.value;
348
- return (value ? 'true' : 'false');
349
- } },
350
- NullValue: { leave: function () { return 'null'; } },
351
- EnumValue: { leave: function (_a) {
352
- var value = _a.value;
353
- return value;
354
- } },
355
- ListValue: { leave: function (_a) {
356
- var values = _a.values;
357
- return '[' + join(values, ', ') + ']';
358
- } },
359
- ObjectValue: { leave: function (_a) {
360
- var fields = _a.fields;
361
- return '{' + join(fields, ', ') + '}';
362
- } },
363
- ObjectField: { leave: function (_a) {
364
- var name = _a.name, value = _a.value;
365
- return name + ': ' + value;
366
- } },
367
- // Directive
368
- Directive: {
369
- leave: function (_a) {
370
- var name = _a.name, args = _a.arguments;
371
- return '@' + name + wrap('(', join(args, ', '), ')');
372
- },
373
- },
374
- // Type
375
- NamedType: { leave: function (_a) {
376
- var name = _a.name;
377
- return name;
378
- } },
379
- ListType: { leave: function (_a) {
380
- var type = _a.type;
381
- return '[' + type + ']';
382
- } },
383
- NonNullType: { leave: function (_a) {
384
- var type = _a.type;
385
- return type + '!';
386
- } },
387
- // Type System Definitions
388
- SchemaDefinition: {
389
- leave: function (_a) {
390
- var description = _a.description, directives = _a.directives, operationTypes = _a.operationTypes;
391
- return wrap('', description, '\n') + join(['schema', join(directives, ' '), block(operationTypes)], ' ');
392
- },
393
- },
394
- OperationTypeDefinition: {
395
- leave: function (_a) {
396
- var operation = _a.operation, type = _a.type;
397
- return operation + ': ' + type;
398
- },
399
- },
400
- ScalarTypeDefinition: {
401
- leave: function (_a) {
402
- var description = _a.description, name = _a.name, directives = _a.directives;
403
- return wrap('', description, '\n') + join(['scalar', name, join(directives, ' ')], ' ');
404
- },
405
- },
406
- ObjectTypeDefinition: {
407
- leave: function (_a) {
408
- var description = _a.description, name = _a.name, interfaces = _a.interfaces, directives = _a.directives, fields = _a.fields;
409
- return wrap('', description, '\n') +
410
- join(['type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
411
- },
412
- },
413
- FieldDefinition: {
414
- leave: function (_a) {
415
- var description = _a.description, name = _a.name, args = _a.arguments, type = _a.type, directives = _a.directives;
416
- return wrap('', description, '\n') +
417
- name +
418
- (hasMultilineItems(args)
419
- ? wrap('(\n', indent(join(args, '\n')), '\n)')
420
- : wrap('(', join(args, ', '), ')')) +
421
- ': ' +
422
- type +
423
- wrap(' ', join(directives, ' '));
424
- },
425
- },
426
- InputValueDefinition: {
427
- leave: function (_a) {
428
- var description = _a.description, name = _a.name, type = _a.type, defaultValue = _a.defaultValue, directives = _a.directives;
429
- return wrap('', description, '\n') + join([name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], ' ');
430
- },
431
- },
432
- InterfaceTypeDefinition: {
433
- leave: function (_a) {
434
- var description = _a.description, name = _a.name, interfaces = _a.interfaces, directives = _a.directives, fields = _a.fields;
435
- return wrap('', description, '\n') +
436
- join(['interface', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
437
- },
438
- },
439
- UnionTypeDefinition: {
440
- leave: function (_a) {
441
- var description = _a.description, name = _a.name, directives = _a.directives, types = _a.types;
442
- return wrap('', description, '\n') + join(['union', name, join(directives, ' '), wrap('= ', join(types, ' | '))], ' ');
443
- },
444
- },
445
- EnumTypeDefinition: {
446
- leave: function (_a) {
447
- var description = _a.description, name = _a.name, directives = _a.directives, values = _a.values;
448
- return wrap('', description, '\n') + join(['enum', name, join(directives, ' '), block(values)], ' ');
449
- },
450
- },
451
- EnumValueDefinition: {
452
- leave: function (_a) {
453
- var description = _a.description, name = _a.name, directives = _a.directives;
454
- return wrap('', description, '\n') + join([name, join(directives, ' ')], ' ');
455
- },
456
- },
457
- InputObjectTypeDefinition: {
458
- leave: function (_a) {
459
- var description = _a.description, name = _a.name, directives = _a.directives, fields = _a.fields;
460
- return wrap('', description, '\n') + join(['input', name, join(directives, ' '), block(fields)], ' ');
461
- },
462
- },
463
- DirectiveDefinition: {
464
- leave: function (_a) {
465
- var description = _a.description, name = _a.name, args = _a.arguments, repeatable = _a.repeatable, locations = _a.locations;
466
- return wrap('', description, '\n') +
467
- 'directive @' +
468
- name +
469
- (hasMultilineItems(args)
470
- ? wrap('(\n', indent(join(args, '\n')), '\n)')
471
- : wrap('(', join(args, ', '), ')')) +
472
- (repeatable ? ' repeatable' : '') +
473
- ' on ' +
474
- join(locations, ' | ');
475
- },
476
- },
477
- SchemaExtension: {
478
- leave: function (_a) {
479
- var directives = _a.directives, operationTypes = _a.operationTypes;
480
- return join(['extend schema', join(directives, ' '), block(operationTypes)], ' ');
481
- },
482
- },
483
- ScalarTypeExtension: {
484
- leave: function (_a) {
485
- var name = _a.name, directives = _a.directives;
486
- return join(['extend scalar', name, join(directives, ' ')], ' ');
487
- },
488
- },
489
- ObjectTypeExtension: {
490
- leave: function (_a) {
491
- var name = _a.name, interfaces = _a.interfaces, directives = _a.directives, fields = _a.fields;
492
- return join(['extend type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
493
- },
494
- },
495
- InterfaceTypeExtension: {
496
- leave: function (_a) {
497
- var name = _a.name, interfaces = _a.interfaces, directives = _a.directives, fields = _a.fields;
498
- return join(['extend interface', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
499
- },
500
- },
501
- UnionTypeExtension: {
502
- leave: function (_a) {
503
- var name = _a.name, directives = _a.directives, types = _a.types;
504
- return join(['extend union', name, join(directives, ' '), wrap('= ', join(types, ' | '))], ' ');
505
- },
506
- },
507
- EnumTypeExtension: {
508
- leave: function (_a) {
509
- var name = _a.name, directives = _a.directives, values = _a.values;
510
- return join(['extend enum', name, join(directives, ' '), block(values)], ' ');
511
- },
512
- },
513
- InputObjectTypeExtension: {
514
- leave: function (_a) {
515
- var name = _a.name, directives = _a.directives, fields = _a.fields;
516
- return join(['extend input', name, join(directives, ' '), block(fields)], ' ');
517
- },
518
- },
519
- };
520
- var printDocASTReducerWithComments = Object.keys(printDocASTReducer).reduce(function (prev, key) {
521
- var _a;
522
- return (tslib.__assign(tslib.__assign({}, prev), (_a = {}, _a[key] = {
523
- leave: addDescription(printDocASTReducer[key].leave),
524
- }, _a)));
525
- }, {});
526
- /**
527
- * Converts an AST into a string, using one set of reasonable
528
- * formatting rules.
529
- */
530
- function printWithComments(ast) {
531
- return graphql.visit(ast, printDocASTReducerWithComments);
532
- }
533
- function isFieldDefinitionNode(node) {
534
- return node.kind === 'FieldDefinition';
535
- }
536
-
537
110
  function directiveAlreadyExists(directivesArr, otherDirective) {
538
111
  return !!directivesArr.find(function (directive) { return directive.name.value === otherDirective.name.value; });
539
112
  }
@@ -629,8 +202,8 @@ function mergeDirectives(d1, d2, config) {
629
202
  return result;
630
203
  }
631
204
  function validateInputs(node, existingNode) {
632
- var printedNode = graphql.print(node);
633
- var printedExistingNode = graphql.print(existingNode);
205
+ var printedNode = graphql.print(tslib.__assign(tslib.__assign({}, node), { description: undefined }));
206
+ var printedExistingNode = graphql.print(tslib.__assign(tslib.__assign({}, existingNode), { description: undefined }));
634
207
  // eslint-disable-next-line
635
208
  var leaveInputs = new RegExp('(directive @w*d*)|( on .*$)', 'g');
636
209
  var sameArguments = printedNode.replace(leaveInputs, '') === printedExistingNode.replace(leaveInputs, '');
@@ -1043,7 +616,7 @@ function mergeGraphQLNodes(nodes, config) {
1043
616
  if (isNamedDefinitionNode(nodeDefinition)) {
1044
617
  var name_1 = (_b = nodeDefinition.name) === null || _b === void 0 ? void 0 : _b.value;
1045
618
  if (config === null || config === void 0 ? void 0 : config.commentDescriptions) {
1046
- collectComment(nodeDefinition);
619
+ utils.collectComment(nodeDefinition);
1047
620
  }
1048
621
  if (name_1 == null) {
1049
622
  continue;
@@ -1099,19 +672,19 @@ function mergeGraphQLNodes(nodes, config) {
1099
672
  }
1100
673
 
1101
674
  function mergeTypeDefs(typeSource, config) {
1102
- resetComments();
675
+ utils.resetComments();
1103
676
  var doc = {
1104
677
  kind: graphql.Kind.DOCUMENT,
1105
678
  definitions: mergeGraphQLTypes(typeSource, tslib.__assign({ useSchemaDefinition: true, forceSchemaDefinition: false, throwOnConflict: false, commentDescriptions: false }, config)),
1106
679
  };
1107
680
  var result;
1108
681
  if (config && config.commentDescriptions) {
1109
- result = printWithComments(doc);
682
+ result = utils.printWithComments(doc);
1110
683
  }
1111
684
  else {
1112
685
  result = doc;
1113
686
  }
1114
- resetComments();
687
+ utils.resetComments();
1115
688
  return result;
1116
689
  }
1117
690
  function visitTypeSources(typeSource, options, allNodes, visitedTypeSources) {
@@ -1160,7 +733,7 @@ function visitTypeSources(typeSource, options, allNodes, visitedTypeSources) {
1160
733
  }
1161
734
  function mergeGraphQLTypes(typeSource, config) {
1162
735
  var _a, _b, _c;
1163
- resetComments();
736
+ utils.resetComments();
1164
737
  var allNodes = visitTypeSources(typeSource, config);
1165
738
  var mergedNodes = mergeGraphQLNodes(allNodes, config);
1166
739
  if (config === null || config === void 0 ? void 0 : config.useSchemaDefinition) {
@@ -1483,92 +1056,7 @@ function extractExtensionsFromSchema(schema) {
1483
1056
  return result;
1484
1057
  }
1485
1058
 
1486
- var defaultResolverValidationOptions = {
1487
- requireResolversForArgs: 'ignore',
1488
- requireResolversForNonScalar: 'ignore',
1489
- requireResolversForAllFields: 'ignore',
1490
- requireResolversForResolveType: 'ignore',
1491
- requireResolversToMatchSchema: 'ignore',
1492
- };
1493
- /**
1494
- * Synchronously merges multiple schemas, typeDefinitions and/or resolvers into a single schema.
1495
- * @param config Configuration object
1496
- */
1497
- function mergeSchemas(config) {
1498
- var e_1, _a;
1499
- var typeDefs = mergeTypeDefs([config.schemas, config.typeDefs || []], config);
1500
- var extractedResolvers = [];
1501
- var extractedExtensions = [];
1502
- try {
1503
- for (var _b = tslib.__values(config.schemas), _c = _b.next(); !_c.done; _c = _b.next()) {
1504
- var schema = _c.value;
1505
- extractedResolvers.push(utils.getResolversFromSchema(schema));
1506
- extractedExtensions.push(extractExtensionsFromSchema(schema));
1507
- }
1508
- }
1509
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1510
- finally {
1511
- try {
1512
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1513
- }
1514
- finally { if (e_1) throw e_1.error; }
1515
- }
1516
- extractedResolvers.push.apply(extractedResolvers, tslib.__spreadArray([], tslib.__read(ensureResolvers(config))));
1517
- var resolvers = mergeResolvers(extractedResolvers, config);
1518
- var extensions = mergeExtensions(extractedExtensions);
1519
- return makeSchema({ resolvers: resolvers, typeDefs: typeDefs, extensions: extensions }, config);
1520
- }
1521
- /**
1522
- * Asynchronously merges multiple schemas, typeDefinitions and/or resolvers into a single schema.
1523
- * @param config Configuration object
1524
- */
1525
- function mergeSchemasAsync(config) {
1526
- return tslib.__awaiter(this, void 0, void 0, function () {
1527
- var _a, typeDefs, resolvers, extensions;
1528
- var _this = this;
1529
- return tslib.__generator(this, function (_b) {
1530
- switch (_b.label) {
1531
- case 0: return [4 /*yield*/, Promise.all([
1532
- mergeTypeDefs([config.schemas, config.typeDefs || []], config),
1533
- Promise.all(config.schemas.map(function (schema) { return tslib.__awaiter(_this, void 0, void 0, function () { return tslib.__generator(this, function (_a) {
1534
- return [2 /*return*/, utils.getResolversFromSchema(schema)];
1535
- }); }); })).then(function (extractedResolvers) {
1536
- return mergeResolvers(tslib.__spreadArray(tslib.__spreadArray([], tslib.__read(extractedResolvers)), tslib.__read(ensureResolvers(config))), config);
1537
- }),
1538
- Promise.all(config.schemas.map(function (schema) { return tslib.__awaiter(_this, void 0, void 0, function () { return tslib.__generator(this, function (_a) {
1539
- return [2 /*return*/, extractExtensionsFromSchema(schema)];
1540
- }); }); })).then(function (extractedExtensions) {
1541
- return mergeExtensions(extractedExtensions);
1542
- }),
1543
- ])];
1544
- case 1:
1545
- _a = tslib.__read.apply(void 0, [_b.sent(), 3]), typeDefs = _a[0], resolvers = _a[1], extensions = _a[2];
1546
- return [2 /*return*/, makeSchema({ resolvers: resolvers, typeDefs: typeDefs, extensions: extensions }, config)];
1547
- }
1548
- });
1549
- });
1550
- }
1551
- function ensureResolvers(config) {
1552
- return config.resolvers ? utils.asArray(config.resolvers) : [];
1553
- }
1554
- function makeSchema(_a, config) {
1555
- var resolvers = _a.resolvers, typeDefs = _a.typeDefs, extensions = _a.extensions;
1556
- var schema$1 = typeof typeDefs === 'string' ? graphql.buildSchema(typeDefs, config) : graphql.buildASTSchema(typeDefs, config);
1557
- // add resolvers
1558
- if (resolvers) {
1559
- schema$1 = schema.addResolversToSchema({
1560
- schema: schema$1,
1561
- resolvers: resolvers,
1562
- resolverValidationOptions: tslib.__assign(tslib.__assign({}, defaultResolverValidationOptions), (config.resolverValidationOptions || {})),
1563
- });
1564
- }
1565
- // extensions
1566
- applyExtensions(schema$1, extensions);
1567
- return schema$1;
1568
- }
1569
-
1570
1059
  exports.applyExtensions = applyExtensions;
1571
- exports.collectComment = collectComment;
1572
1060
  exports.defaultStringComparator = defaultStringComparator;
1573
1061
  exports.extractExtensionsFromSchema = extractExtensionsFromSchema;
1574
1062
  exports.extractType = extractType;
@@ -1592,15 +1080,9 @@ exports.mergeInterface = mergeInterface;
1592
1080
  exports.mergeNamedTypeArray = mergeNamedTypeArray;
1593
1081
  exports.mergeResolvers = mergeResolvers;
1594
1082
  exports.mergeScalar = mergeScalar;
1595
- exports.mergeSchemas = mergeSchemas;
1596
- exports.mergeSchemasAsync = mergeSchemasAsync;
1597
1083
  exports.mergeType = mergeType;
1598
1084
  exports.mergeTypeDefs = mergeTypeDefs;
1599
1085
  exports.mergeUnion = mergeUnion;
1600
- exports.printComment = printComment;
1601
1086
  exports.printTypeNode = printTypeNode;
1602
- exports.printWithComments = printWithComments;
1603
- exports.pushComment = pushComment;
1604
- exports.resetComments = resetComments;
1605
1087
  exports.schemaDefSymbol = schemaDefSymbol;
1606
1088
  exports.travelSchemaPossibleExtensions = travelSchemaPossibleExtensions;