UNPKG

82.5 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', { value: true });
4
5const tslib = require('tslib');
6const graphql = require('graphql');
7const utils = require('@graphql-tools/utils/es5');
8const delegate = require('@graphql-tools/delegate/es5');
9const schema = require('@graphql-tools/schema/es5');
10
11function generateProxyingResolvers(subschemaOrSubschemaConfig, transforms) {
12 var _a;
13 var targetSchema;
14 var schemaTransforms = [];
15 var createProxyingResolver;
16 if (delegate.isSubschemaConfig(subschemaOrSubschemaConfig)) {
17 targetSchema = subschemaOrSubschemaConfig.schema;
18 createProxyingResolver = (_a = subschemaOrSubschemaConfig.createProxyingResolver) !== null && _a !== void 0 ? _a : defaultCreateProxyingResolver;
19 if (subschemaOrSubschemaConfig.transforms != null) {
20 schemaTransforms = schemaTransforms.concat(subschemaOrSubschemaConfig.transforms);
21 }
22 }
23 else {
24 targetSchema = subschemaOrSubschemaConfig;
25 createProxyingResolver = defaultCreateProxyingResolver;
26 }
27 if (transforms != null) {
28 schemaTransforms = schemaTransforms.concat(transforms);
29 }
30 var transformedSchema = utils.applySchemaTransforms(targetSchema, schemaTransforms);
31 var operationTypes = {
32 query: targetSchema.getQueryType(),
33 mutation: targetSchema.getMutationType(),
34 subscription: targetSchema.getSubscriptionType(),
35 };
36 var resolvers = {};
37 Object.keys(operationTypes).forEach(function (operation) {
38 var rootType = operationTypes[operation];
39 if (rootType != null) {
40 var typeName_1 = rootType.name;
41 var fields = rootType.getFields();
42 resolvers[typeName_1] = {};
43 Object.keys(fields).forEach(function (fieldName) {
44 var proxyingResolver = createProxyingResolver({
45 schema: subschemaOrSubschemaConfig,
46 transforms: transforms,
47 transformedSchema: transformedSchema,
48 operation: operation,
49 fieldName: fieldName,
50 });
51 var finalResolver = createPossiblyNestedProxyingResolver(subschemaOrSubschemaConfig, proxyingResolver);
52 if (operation === 'subscription') {
53 resolvers[typeName_1][fieldName] = {
54 subscribe: finalResolver,
55 resolve: function (payload, _, __, _a) {
56 var targetFieldName = _a.fieldName;
57 return payload[targetFieldName];
58 },
59 };
60 }
61 else {
62 resolvers[typeName_1][fieldName] = {
63 resolve: finalResolver,
64 };
65 }
66 });
67 }
68 });
69 return resolvers;
70}
71function createPossiblyNestedProxyingResolver(subschemaOrSubschemaConfig, proxyingResolver) {
72 return function (parent, args, context, info) {
73 if (parent != null) {
74 var responseKey = utils.getResponseKeyFromInfo(info);
75 var errors = utils.getErrors(parent, responseKey);
76 // Check to see if the parent contains a proxied result
77 if (errors != null) {
78 var subschema = delegate.getSubschema(parent, responseKey);
79 // If there is a proxied result from this subschema, return it
80 // This can happen even for a root field when the root type ia
81 // also nested as a field within a different type.
82 if (subschemaOrSubschemaConfig === subschema && parent[responseKey] !== undefined) {
83 return delegate.handleResult(parent[responseKey], errors, subschema, context, info);
84 }
85 }
86 }
87 return proxyingResolver(parent, args, context, info);
88 };
89}
90function defaultCreateProxyingResolver(_a) {
91 var schema = _a.schema, operation = _a.operation, transforms = _a.transforms, transformedSchema = _a.transformedSchema;
92 return function (_parent, _args, context, info) {
93 return delegate.delegateToSchema({
94 schema: schema,
95 operation: operation,
96 context: context,
97 info: info,
98 transforms: transforms,
99 transformedSchema: transformedSchema,
100 });
101 };
102}
103
104function wrapSchema(subschemaOrSubschemaConfig, transforms) {
105 var targetSchema;
106 var schemaTransforms = [];
107 if (delegate.isSubschemaConfig(subschemaOrSubschemaConfig)) {
108 targetSchema = subschemaOrSubschemaConfig.schema;
109 if (subschemaOrSubschemaConfig.transforms != null) {
110 schemaTransforms = schemaTransforms.concat(subschemaOrSubschemaConfig.transforms);
111 }
112 }
113 else {
114 targetSchema = subschemaOrSubschemaConfig;
115 }
116 if (transforms != null) {
117 schemaTransforms = schemaTransforms.concat(transforms);
118 }
119 var proxyingResolvers = generateProxyingResolvers(subschemaOrSubschemaConfig, transforms);
120 var schema = createWrappingSchema(targetSchema, proxyingResolvers);
121 return utils.applySchemaTransforms(schema, schemaTransforms);
122}
123function createWrappingSchema(schema, proxyingResolvers) {
124 var _a;
125 return utils.mapSchema(schema, (_a = {},
126 _a[utils.MapperKind.ROOT_OBJECT] = function (type) {
127 var config = type.toConfig();
128 var fieldConfigMap = config.fields;
129 Object.keys(fieldConfigMap).forEach(function (fieldName) {
130 fieldConfigMap[fieldName] = tslib.__assign(tslib.__assign({}, fieldConfigMap[fieldName]), proxyingResolvers[type.name][fieldName]);
131 });
132 return new graphql.GraphQLObjectType(config);
133 },
134 _a[utils.MapperKind.OBJECT_TYPE] = function (type) {
135 var config = type.toConfig();
136 config.isTypeOf = undefined;
137 Object.keys(config.fields).forEach(function (fieldName) {
138 config.fields[fieldName].resolve = delegate.defaultMergedResolver;
139 config.fields[fieldName].subscribe = null;
140 });
141 return new graphql.GraphQLObjectType(config);
142 },
143 _a[utils.MapperKind.INTERFACE_TYPE] = function (type) {
144 var config = type.toConfig();
145 delete config.resolveType;
146 return new graphql.GraphQLInterfaceType(config);
147 },
148 _a[utils.MapperKind.UNION_TYPE] = function (type) {
149 var config = type.toConfig();
150 delete config.resolveType;
151 return new graphql.GraphQLUnionType(config);
152 },
153 _a));
154}
155
156var RenameTypes = /** @class */ (function () {
157 function RenameTypes(renamer, options) {
158 this.renamer = renamer;
159 this.map = Object.create(null);
160 this.reverseMap = Object.create(null);
161 var _a = options != null ? options : {}, _b = _a.renameBuiltins, renameBuiltins = _b === void 0 ? false : _b, _c = _a.renameScalars, renameScalars = _c === void 0 ? true : _c;
162 this.renameBuiltins = renameBuiltins;
163 this.renameScalars = renameScalars;
164 }
165 RenameTypes.prototype.transformSchema = function (originalSchema) {
166 var _a;
167 var _this = this;
168 return utils.mapSchema(originalSchema, (_a = {},
169 _a[utils.MapperKind.TYPE] = function (type) {
170 if (graphql.isSpecifiedScalarType(type) && !_this.renameBuiltins) {
171 return undefined;
172 }
173 if (graphql.isScalarType(type) && !_this.renameScalars) {
174 return undefined;
175 }
176 var oldName = type.name;
177 var newName = _this.renamer(oldName);
178 if (newName !== undefined && newName !== oldName) {
179 _this.map[oldName] = newName;
180 _this.reverseMap[newName] = oldName;
181 return utils.renameType(type, newName);
182 }
183 },
184 _a[utils.MapperKind.ROOT_OBJECT] = function () {
185 return undefined;
186 },
187 _a));
188 };
189 RenameTypes.prototype.transformRequest = function (originalRequest) {
190 var _a;
191 var _this = this;
192 var document = graphql.visit(originalRequest.document, (_a = {},
193 _a[graphql.Kind.NAMED_TYPE] = function (node) {
194 var name = node.name.value;
195 if (name in _this.reverseMap) {
196 return tslib.__assign(tslib.__assign({}, node), { name: {
197 kind: graphql.Kind.NAME,
198 value: _this.reverseMap[name],
199 } });
200 }
201 },
202 _a));
203 return tslib.__assign(tslib.__assign({}, originalRequest), { document: document });
204 };
205 RenameTypes.prototype.transformResult = function (result) {
206 var _this = this;
207 return tslib.__assign(tslib.__assign({}, result), { data: utils.visitData(result.data, function (object) {
208 var typeName = object === null || object === void 0 ? void 0 : object.__typename;
209 if (typeName != null && typeName in _this.map) {
210 object.__typename = _this.map[typeName];
211 }
212 return object;
213 }) });
214 };
215 return RenameTypes;
216}());
217
218var FilterTypes = /** @class */ (function () {
219 function FilterTypes(filter) {
220 this.filter = filter;
221 }
222 FilterTypes.prototype.transformSchema = function (schema) {
223 var _a;
224 var _this = this;
225 return utils.mapSchema(schema, (_a = {},
226 _a[utils.MapperKind.TYPE] = function (type) {
227 if (_this.filter(type)) {
228 return undefined;
229 }
230 return null;
231 },
232 _a));
233 };
234 return FilterTypes;
235}());
236
237var RenameRootTypes = /** @class */ (function () {
238 function RenameRootTypes(renamer) {
239 this.renamer = renamer;
240 this.map = Object.create(null);
241 this.reverseMap = Object.create(null);
242 }
243 RenameRootTypes.prototype.transformSchema = function (originalSchema) {
244 var _a;
245 var _this = this;
246 return utils.mapSchema(originalSchema, (_a = {},
247 _a[utils.MapperKind.ROOT_OBJECT] = function (type) {
248 var oldName = type.name;
249 var newName = _this.renamer(oldName);
250 if (newName !== undefined && newName !== oldName) {
251 _this.map[oldName] = newName;
252 _this.reverseMap[newName] = oldName;
253 return utils.renameType(type, newName);
254 }
255 },
256 _a));
257 };
258 RenameRootTypes.prototype.transformRequest = function (originalRequest) {
259 var _a;
260 var _this = this;
261 var document = graphql.visit(originalRequest.document, (_a = {},
262 _a[graphql.Kind.NAMED_TYPE] = function (node) {
263 var name = node.name.value;
264 if (name in _this.reverseMap) {
265 return tslib.__assign(tslib.__assign({}, node), { name: {
266 kind: graphql.Kind.NAME,
267 value: _this.reverseMap[name],
268 } });
269 }
270 },
271 _a));
272 return tslib.__assign(tslib.__assign({}, originalRequest), { document: document });
273 };
274 RenameRootTypes.prototype.transformResult = function (result) {
275 var _this = this;
276 return tslib.__assign(tslib.__assign({}, result), { data: utils.visitData(result.data, function (object) {
277 var typeName = object === null || object === void 0 ? void 0 : object.__typename;
278 if (typeName != null && typeName in _this.map) {
279 object.__typename = _this.map[typeName];
280 }
281 return object;
282 }) });
283 };
284 return RenameRootTypes;
285}());
286
287var TransformCompositeFields = /** @class */ (function () {
288 function TransformCompositeFields(fieldTransformer, fieldNodeTransformer, dataTransformer, errorsTransformer) {
289 this.fieldTransformer = fieldTransformer;
290 this.fieldNodeTransformer = fieldNodeTransformer;
291 this.dataTransformer = dataTransformer;
292 this.errorsTransformer = errorsTransformer;
293 this.mapping = {};
294 }
295 TransformCompositeFields.prototype.transformSchema = function (originalSchema) {
296 var _a;
297 var _this = this;
298 this.transformedSchema = utils.mapSchema(originalSchema, (_a = {},
299 _a[utils.MapperKind.COMPOSITE_FIELD] = function (fieldConfig, fieldName, typeName) {
300 var transformedField = _this.fieldTransformer(typeName, fieldName, fieldConfig);
301 if (Array.isArray(transformedField)) {
302 var newFieldName = transformedField[0];
303 if (newFieldName !== fieldName) {
304 if (!(typeName in _this.mapping)) {
305 _this.mapping[typeName] = {};
306 }
307 _this.mapping[typeName][newFieldName] = fieldName;
308 }
309 }
310 return transformedField;
311 },
312 _a));
313 this.typeInfo = new graphql.TypeInfo(this.transformedSchema);
314 return this.transformedSchema;
315 };
316 TransformCompositeFields.prototype.transformRequest = function (originalRequest, _delegationContext, transformationContext) {
317 var document = originalRequest.document;
318 var fragments = Object.create(null);
319 document.definitions.forEach(function (def) {
320 if (def.kind === graphql.Kind.FRAGMENT_DEFINITION) {
321 fragments[def.name.value] = def;
322 }
323 });
324 return tslib.__assign(tslib.__assign({}, originalRequest), { document: this.transformDocument(document, fragments, transformationContext) });
325 };
326 TransformCompositeFields.prototype.transformResult = function (result, _delegationContext, transformationContext) {
327 var _this = this;
328 if (this.dataTransformer != null) {
329 result.data = utils.visitData(result.data, function (value) { return _this.dataTransformer(value, transformationContext); });
330 }
331 if (this.errorsTransformer != null) {
332 result.errors = this.errorsTransformer(result.errors, transformationContext);
333 }
334 return result;
335 };
336 TransformCompositeFields.prototype.transformDocument = function (document, fragments, transformationContext) {
337 var _a;
338 var _this = this;
339 return graphql.visit(document, graphql.visitWithTypeInfo(this.typeInfo, {
340 leave: (_a = {},
341 _a[graphql.Kind.SELECTION_SET] = function (node) {
342 return _this.transformSelectionSet(node, _this.typeInfo, fragments, transformationContext);
343 },
344 _a),
345 }));
346 };
347 TransformCompositeFields.prototype.transformSelectionSet = function (node, typeInfo, fragments, transformationContext) {
348 var _this = this;
349 var parentType = typeInfo.getParentType();
350 if (parentType == null) {
351 return undefined;
352 }
353 var parentTypeName = parentType.name;
354 var newSelections = [];
355 node.selections.forEach(function (selection) {
356 var _a, _b;
357 if (selection.kind !== graphql.Kind.FIELD) {
358 newSelections.push(selection);
359 return;
360 }
361 var newName = selection.name.value;
362 if (_this.dataTransformer != null || _this.errorsTransformer != null) {
363 newSelections.push({
364 kind: graphql.Kind.FIELD,
365 name: {
366 kind: graphql.Kind.NAME,
367 value: '__typename',
368 },
369 });
370 }
371 var transformedSelection;
372 if (_this.fieldNodeTransformer == null) {
373 transformedSelection = selection;
374 }
375 else {
376 transformedSelection = _this.fieldNodeTransformer(parentTypeName, newName, selection, fragments, transformationContext);
377 transformedSelection = transformedSelection === undefined ? selection : transformedSelection;
378 }
379 if (Array.isArray(transformedSelection)) {
380 newSelections = newSelections.concat(transformedSelection);
381 return;
382 }
383 if (transformedSelection.kind !== graphql.Kind.FIELD) {
384 newSelections.push(transformedSelection);
385 return;
386 }
387 var typeMapping = _this.mapping[parentTypeName];
388 if (typeMapping == null) {
389 newSelections.push(transformedSelection);
390 return;
391 }
392 var oldName = _this.mapping[parentTypeName][newName];
393 if (oldName == null) {
394 newSelections.push(transformedSelection);
395 return;
396 }
397 newSelections.push(tslib.__assign(tslib.__assign({}, transformedSelection), { name: {
398 kind: graphql.Kind.NAME,
399 value: oldName,
400 }, alias: {
401 kind: graphql.Kind.NAME,
402 value: (_b = (_a = transformedSelection.alias) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : newName,
403 } }));
404 });
405 return tslib.__assign(tslib.__assign({}, node), { selections: newSelections });
406 };
407 return TransformCompositeFields;
408}());
409
410var TransformObjectFields = /** @class */ (function () {
411 function TransformObjectFields(objectFieldTransformer, fieldNodeTransformer) {
412 this.objectFieldTransformer = objectFieldTransformer;
413 this.fieldNodeTransformer = fieldNodeTransformer;
414 }
415 TransformObjectFields.prototype.transformSchema = function (originalSchema) {
416 var _this = this;
417 var compositeToObjectFieldTransformer = function (typeName, fieldName, fieldConfig) {
418 if (graphql.isObjectType(originalSchema.getType(typeName))) {
419 return _this.objectFieldTransformer(typeName, fieldName, fieldConfig);
420 }
421 return undefined;
422 };
423 this.transformer = new TransformCompositeFields(compositeToObjectFieldTransformer, this.fieldNodeTransformer);
424 return this.transformer.transformSchema(originalSchema);
425 };
426 TransformObjectFields.prototype.transformRequest = function (originalRequest, delegationContext, transformationContext) {
427 return this.transformer.transformRequest(originalRequest, delegationContext, transformationContext);
428 };
429 TransformObjectFields.prototype.transformResult = function (originalResult, delegationContext, transformationContext) {
430 return this.transformer.transformResult(originalResult, delegationContext, transformationContext);
431 };
432 return TransformObjectFields;
433}());
434
435var TransformRootFields = /** @class */ (function () {
436 function TransformRootFields(rootFieldTransformer, fieldNodeTransformer) {
437 this.rootFieldTransformer = rootFieldTransformer;
438 this.fieldNodeTransformer = fieldNodeTransformer;
439 }
440 TransformRootFields.prototype.transformSchema = function (originalSchema) {
441 var _this = this;
442 var _a, _b, _c;
443 var queryTypeName = (_a = originalSchema.getQueryType()) === null || _a === void 0 ? void 0 : _a.name;
444 var mutationTypeName = (_b = originalSchema.getMutationType()) === null || _b === void 0 ? void 0 : _b.name;
445 var subscriptionTypeName = (_c = originalSchema.getSubscriptionType()) === null || _c === void 0 ? void 0 : _c.name;
446 var rootToObjectFieldTransformer = function (typeName, fieldName, fieldConfig) {
447 if (typeName === queryTypeName) {
448 return _this.rootFieldTransformer('Query', fieldName, fieldConfig);
449 }
450 if (typeName === mutationTypeName) {
451 return _this.rootFieldTransformer('Mutation', fieldName, fieldConfig);
452 }
453 if (typeName === subscriptionTypeName) {
454 return _this.rootFieldTransformer('Subscription', fieldName, fieldConfig);
455 }
456 return undefined;
457 };
458 this.transformer = new TransformObjectFields(rootToObjectFieldTransformer, this.fieldNodeTransformer);
459 return this.transformer.transformSchema(originalSchema);
460 };
461 TransformRootFields.prototype.transformRequest = function (originalRequest, delegationContext, transformationContext) {
462 return this.transformer.transformRequest(originalRequest, delegationContext, transformationContext);
463 };
464 TransformRootFields.prototype.transformResult = function (originalResult, delegationContext, transformationContext) {
465 return this.transformer.transformResult(originalResult, delegationContext, transformationContext);
466 };
467 return TransformRootFields;
468}());
469
470var RenameRootFields = /** @class */ (function () {
471 function RenameRootFields(renamer) {
472 this.transformer = new TransformRootFields(function (operation, fieldName, fieldConfig) { return [renamer(operation, fieldName, fieldConfig), fieldConfig]; });
473 }
474 RenameRootFields.prototype.transformSchema = function (originalSchema) {
475 return this.transformer.transformSchema(originalSchema);
476 };
477 RenameRootFields.prototype.transformRequest = function (originalRequest) {
478 return this.transformer.transformRequest(originalRequest);
479 };
480 return RenameRootFields;
481}());
482
483var FilterRootFields = /** @class */ (function () {
484 function FilterRootFields(filter) {
485 this.transformer = new TransformRootFields(function (operation, fieldName, fieldConfig) {
486 if (filter(operation, fieldName, fieldConfig)) {
487 return undefined;
488 }
489 return null;
490 });
491 }
492 FilterRootFields.prototype.transformSchema = function (originalSchema) {
493 return this.transformer.transformSchema(originalSchema);
494 };
495 return FilterRootFields;
496}());
497
498var RenameObjectFields = /** @class */ (function () {
499 function RenameObjectFields(renamer) {
500 this.transformer = new TransformObjectFields(function (typeName, fieldName, fieldConfig) { return [
501 renamer(typeName, fieldName, fieldConfig),
502 fieldConfig,
503 ]; });
504 }
505 RenameObjectFields.prototype.transformSchema = function (originalSchema) {
506 return this.transformer.transformSchema(originalSchema);
507 };
508 RenameObjectFields.prototype.transformRequest = function (originalRequest) {
509 return this.transformer.transformRequest(originalRequest);
510 };
511 return RenameObjectFields;
512}());
513
514var FilterObjectFields = /** @class */ (function () {
515 function FilterObjectFields(filter) {
516 this.transformer = new TransformObjectFields(function (typeName, fieldName, fieldConfig) {
517 return filter(typeName, fieldName, fieldConfig) ? undefined : null;
518 });
519 }
520 FilterObjectFields.prototype.transformSchema = function (originalSchema) {
521 return this.transformer.transformSchema(originalSchema);
522 };
523 return FilterObjectFields;
524}());
525
526var TransformInterfaceFields = /** @class */ (function () {
527 function TransformInterfaceFields(interfaceFieldTransformer, fieldNodeTransformer) {
528 this.interfaceFieldTransformer = interfaceFieldTransformer;
529 this.fieldNodeTransformer = fieldNodeTransformer;
530 }
531 TransformInterfaceFields.prototype.transformSchema = function (originalSchema) {
532 var _this = this;
533 var compositeToObjectFieldTransformer = function (typeName, fieldName, fieldConfig) {
534 if (graphql.isInterfaceType(originalSchema.getType(typeName))) {
535 return _this.interfaceFieldTransformer(typeName, fieldName, fieldConfig);
536 }
537 return undefined;
538 };
539 this.transformer = new TransformCompositeFields(compositeToObjectFieldTransformer, this.fieldNodeTransformer);
540 return this.transformer.transformSchema(originalSchema);
541 };
542 TransformInterfaceFields.prototype.transformRequest = function (originalRequest, delegationContext, transformationContext) {
543 return this.transformer.transformRequest(originalRequest, delegationContext, transformationContext);
544 };
545 TransformInterfaceFields.prototype.transformResult = function (originalResult, delegationContext, transformationContext) {
546 return this.transformer.transformResult(originalResult, delegationContext, transformationContext);
547 };
548 return TransformInterfaceFields;
549}());
550
551var RenameInterfaceFields = /** @class */ (function () {
552 function RenameInterfaceFields(renamer) {
553 this.transformer = new TransformInterfaceFields(function (typeName, fieldName, fieldConfig) { return [
554 renamer(typeName, fieldName, fieldConfig),
555 fieldConfig,
556 ]; });
557 }
558 RenameInterfaceFields.prototype.transformSchema = function (originalSchema) {
559 return this.transformer.transformSchema(originalSchema);
560 };
561 RenameInterfaceFields.prototype.transformRequest = function (originalRequest) {
562 return this.transformer.transformRequest(originalRequest);
563 };
564 return RenameInterfaceFields;
565}());
566
567var FilterInterfaceFields = /** @class */ (function () {
568 function FilterInterfaceFields(filter) {
569 this.transformer = new TransformInterfaceFields(function (typeName, fieldName, fieldConfig) {
570 return filter(typeName, fieldName, fieldConfig) ? undefined : null;
571 });
572 }
573 FilterInterfaceFields.prototype.transformSchema = function (originalSchema) {
574 return this.transformer.transformSchema(originalSchema);
575 };
576 return FilterInterfaceFields;
577}());
578
579var TransformInputObjectFields = /** @class */ (function () {
580 function TransformInputObjectFields(inputFieldTransformer, inputFieldNodeTransformer, inputObjectNodeTransformer) {
581 this.inputFieldTransformer = inputFieldTransformer;
582 this.inputFieldNodeTransformer = inputFieldNodeTransformer;
583 this.inputObjectNodeTransformer = inputObjectNodeTransformer;
584 this.mapping = {};
585 }
586 TransformInputObjectFields.prototype.transformSchema = function (originalSchema) {
587 var _a;
588 var _this = this;
589 this.transformedSchema = utils.mapSchema(originalSchema, (_a = {},
590 _a[utils.MapperKind.INPUT_OBJECT_FIELD] = function (inputFieldConfig, fieldName, typeName) {
591 var transformedInputField = _this.inputFieldTransformer(typeName, fieldName, inputFieldConfig);
592 if (Array.isArray(transformedInputField)) {
593 var newFieldName = transformedInputField[0];
594 if (newFieldName !== fieldName) {
595 if (!(typeName in _this.mapping)) {
596 _this.mapping[typeName] = {};
597 }
598 _this.mapping[typeName][newFieldName] = fieldName;
599 }
600 }
601 return transformedInputField;
602 },
603 _a));
604 return this.transformedSchema;
605 };
606 TransformInputObjectFields.prototype.transformRequest = function (originalRequest, delegationContext) {
607 var fragments = Object.create(null);
608 originalRequest.document.definitions
609 .filter(function (def) { return def.kind === graphql.Kind.FRAGMENT_DEFINITION; })
610 .forEach(function (def) {
611 fragments[def.name.value] = def;
612 });
613 var document = this.transformDocument(originalRequest.document, this.mapping, this.inputFieldNodeTransformer, this.inputObjectNodeTransformer, originalRequest,
614 // cast to DelegationContext as workaround to avoid breaking change in types until next major version
615 delegationContext);
616 return tslib.__assign(tslib.__assign({}, originalRequest), { document: document });
617 };
618 TransformInputObjectFields.prototype.transformDocument = function (document, mapping, inputFieldNodeTransformer, inputObjectNodeTransformer, request, delegationContext) {
619 var _a;
620 var typeInfo = new graphql.TypeInfo(this.transformedSchema);
621 var newDocument = graphql.visit(document, graphql.visitWithTypeInfo(typeInfo, {
622 leave: (_a = {},
623 _a[graphql.Kind.OBJECT] = function (node) {
624 var parentType = typeInfo.getInputType();
625 if (parentType != null) {
626 var parentTypeName_1 = parentType.name;
627 var newInputFields_1 = [];
628 node.fields.forEach(function (inputField) {
629 var newName = inputField.name.value;
630 var transformedInputField = inputFieldNodeTransformer != null
631 ? inputFieldNodeTransformer(parentTypeName_1, newName, inputField, request, delegationContext)
632 : inputField;
633 if (Array.isArray(transformedInputField)) {
634 transformedInputField.forEach(function (individualTransformedInputField) {
635 var typeMapping = mapping[parentTypeName_1];
636 if (typeMapping == null) {
637 newInputFields_1.push(individualTransformedInputField);
638 return;
639 }
640 var oldName = typeMapping[newName];
641 if (oldName == null) {
642 newInputFields_1.push(individualTransformedInputField);
643 return;
644 }
645 newInputFields_1.push(tslib.__assign(tslib.__assign({}, individualTransformedInputField), { name: tslib.__assign(tslib.__assign({}, individualTransformedInputField.name), { value: oldName }) }));
646 });
647 return;
648 }
649 var typeMapping = mapping[parentTypeName_1];
650 if (typeMapping == null) {
651 newInputFields_1.push(transformedInputField);
652 return;
653 }
654 var oldName = typeMapping[newName];
655 if (oldName == null) {
656 newInputFields_1.push(transformedInputField);
657 return;
658 }
659 newInputFields_1.push(tslib.__assign(tslib.__assign({}, transformedInputField), { name: tslib.__assign(tslib.__assign({}, transformedInputField.name), { value: oldName }) }));
660 });
661 var newNode = tslib.__assign(tslib.__assign({}, node), { fields: newInputFields_1 });
662 return inputObjectNodeTransformer != null
663 ? inputObjectNodeTransformer(parentTypeName_1, newNode, request, delegationContext)
664 : newNode;
665 }
666 },
667 _a),
668 }));
669 return newDocument;
670 };
671 return TransformInputObjectFields;
672}());
673
674var RenameInputObjectFields = /** @class */ (function () {
675 function RenameInputObjectFields(renamer) {
676 var _this = this;
677 this.renamer = renamer;
678 this.transformer = new TransformInputObjectFields(function (typeName, inputFieldName, inputFieldConfig) {
679 var newName = renamer(typeName, inputFieldName, inputFieldConfig);
680 if (newName !== undefined && newName !== inputFieldName) {
681 return [renamer(typeName, inputFieldName, inputFieldConfig), inputFieldConfig];
682 }
683 }, function (typeName, inputFieldName, inputFieldNode) {
684 if (!(typeName in _this.reverseMap)) {
685 return inputFieldNode;
686 }
687 var inputFieldNameMap = _this.reverseMap[typeName];
688 if (!(inputFieldName in inputFieldNameMap)) {
689 return inputFieldNode;
690 }
691 return tslib.__assign(tslib.__assign({}, inputFieldNode), { name: tslib.__assign(tslib.__assign({}, inputFieldNode.name), { value: inputFieldNameMap[inputFieldName] }) });
692 });
693 this.reverseMap = Object.create(null);
694 }
695 RenameInputObjectFields.prototype.transformSchema = function (originalSchema) {
696 var _a;
697 var _this = this;
698 utils.mapSchema(originalSchema, (_a = {},
699 _a[utils.MapperKind.INPUT_OBJECT_FIELD] = function (inputFieldConfig, fieldName, typeName) {
700 var newName = _this.renamer(typeName, fieldName, inputFieldConfig);
701 if (newName !== undefined && newName !== fieldName) {
702 if (_this.reverseMap[typeName] == null) {
703 _this.reverseMap[typeName] = Object.create(null);
704 }
705 _this.reverseMap[typeName][newName] = fieldName;
706 }
707 return undefined;
708 },
709 _a[utils.MapperKind.ROOT_OBJECT] = function () {
710 return undefined;
711 },
712 _a));
713 return this.transformer.transformSchema(originalSchema);
714 };
715 RenameInputObjectFields.prototype.transformRequest = function (originalRequest, delegationContext) {
716 return this.transformer.transformRequest(originalRequest, delegationContext);
717 };
718 return RenameInputObjectFields;
719}());
720
721var FilterInputObjectFields = /** @class */ (function () {
722 function FilterInputObjectFields(filter, inputObjectNodeTransformer) {
723 this.transformer = new TransformInputObjectFields(function (typeName, fieldName, inputFieldConfig) {
724 return filter(typeName, fieldName, inputFieldConfig) ? undefined : null;
725 }, undefined, inputObjectNodeTransformer);
726 }
727 FilterInputObjectFields.prototype.transformSchema = function (originalSchema) {
728 return this.transformer.transformSchema(originalSchema);
729 };
730 FilterInputObjectFields.prototype.transformRequest = function (originalRequest, delegationContext) {
731 return this.transformer.transformRequest(originalRequest, delegationContext);
732 };
733 return FilterInputObjectFields;
734}());
735
736var MapLeafValues = /** @class */ (function () {
737 function MapLeafValues(inputValueTransformer, outputValueTransformer) {
738 this.inputValueTransformer = inputValueTransformer;
739 this.outputValueTransformer = outputValueTransformer;
740 this.resultVisitorMap = Object.create(null);
741 }
742 MapLeafValues.prototype.transformSchema = function (originalSchema) {
743 var _this = this;
744 this.originalSchema = originalSchema;
745 var typeMap = originalSchema.getTypeMap();
746 Object.keys(typeMap).forEach(function (typeName) {
747 var type = typeMap[typeName];
748 if (!typeName.startsWith('__')) {
749 if (graphql.isLeafType(type)) {
750 _this.resultVisitorMap[typeName] = function (value) { return _this.outputValueTransformer(typeName, value); };
751 }
752 }
753 });
754 this.typeInfo = new graphql.TypeInfo(originalSchema);
755 return originalSchema;
756 };
757 MapLeafValues.prototype.transformRequest = function (originalRequest, _delegationContext, transformationContext) {
758 var document = originalRequest.document;
759 var variableValues = originalRequest.variables;
760 var operations = document.definitions.filter(function (def) { return def.kind === graphql.Kind.OPERATION_DEFINITION; });
761 var fragments = document.definitions.filter(function (def) { return def.kind === graphql.Kind.FRAGMENT_DEFINITION; });
762 var newOperations = this.transformOperations(operations, variableValues);
763 var transformedRequest = tslib.__assign(tslib.__assign({}, originalRequest), { document: tslib.__assign(tslib.__assign({}, document), { definitions: tslib.__spread(newOperations, fragments) }), variables: variableValues });
764 transformationContext.transformedRequest = transformedRequest;
765 return transformedRequest;
766 };
767 MapLeafValues.prototype.transformResult = function (originalResult, _delegationContext, transformationContext) {
768 return utils.visitResult(originalResult, transformationContext.transformedRequest, this.originalSchema, this.resultVisitorMap);
769 };
770 MapLeafValues.prototype.transformOperations = function (operations, variableValues) {
771 var _this = this;
772 return operations.map(function (operation) {
773 var _a;
774 var variableDefinitionMap = operation.variableDefinitions.reduce(function (prev, def) {
775 var _a;
776 return (tslib.__assign(tslib.__assign({}, prev), (_a = {}, _a[def.variable.name.value] = def, _a)));
777 }, {});
778 var newOperation = graphql.visit(operation, graphql.visitWithTypeInfo(_this.typeInfo, (_a = {},
779 _a[graphql.Kind.FIELD] = function (node) { return _this.transformFieldNode(node, variableDefinitionMap, variableValues); },
780 _a)));
781 return tslib.__assign(tslib.__assign({}, newOperation), { variableDefinitions: Object.keys(variableDefinitionMap).map(function (varName) { return variableDefinitionMap[varName]; }) });
782 });
783 };
784 MapLeafValues.prototype.transformFieldNode = function (field, variableDefinitionMap, variableValues) {
785 var _this = this;
786 var targetField = this.typeInfo.getFieldDef();
787 if (!targetField.name.startsWith('__')) {
788 var argumentNodes = field.arguments;
789 if (argumentNodes != null) {
790 var argumentNodeMap_1 = argumentNodes.reduce(function (prev, argument) {
791 var _a;
792 return (tslib.__assign(tslib.__assign({}, prev), (_a = {}, _a[argument.name.value] = argument, _a)));
793 }, Object.create(null));
794 targetField.args.forEach(function (argument) {
795 var argName = argument.name;
796 var argType = argument.type;
797 var argumentNode = argumentNodeMap_1[argName];
798 var argValue = argumentNode === null || argumentNode === void 0 ? void 0 : argumentNode.value;
799 var value;
800 if (argValue != null) {
801 value = graphql.valueFromAST(argValue, argType, variableValues);
802 }
803 utils.updateArgument(argName, argType, argumentNodeMap_1, variableDefinitionMap, variableValues, utils.transformInputValue(argType, value, function (t, v) {
804 var newValue = _this.inputValueTransformer(t.name, v);
805 return newValue === undefined ? v : newValue;
806 }));
807 });
808 return tslib.__assign(tslib.__assign({}, field), { arguments: Object.keys(argumentNodeMap_1).map(function (argName) { return argumentNodeMap_1[argName]; }) });
809 }
810 }
811 };
812 return MapLeafValues;
813}());
814
815var TransformEnumValues = /** @class */ (function () {
816 function TransformEnumValues(enumValueTransformer, inputValueTransformer, outputValueTransformer) {
817 this.enumValueTransformer = enumValueTransformer;
818 this.mapping = Object.create(null);
819 this.reverseMapping = Object.create(null);
820 this.transformer = new MapLeafValues(generateValueTransformer(inputValueTransformer, this.reverseMapping), generateValueTransformer(outputValueTransformer, this.mapping));
821 }
822 TransformEnumValues.prototype.transformSchema = function (originalSchema) {
823 var _a;
824 var _this = this;
825 var transformedSchema = this.transformer.transformSchema(originalSchema);
826 this.transformedSchema = utils.mapSchema(transformedSchema, (_a = {},
827 _a[utils.MapperKind.ENUM_VALUE] = function (valueConfig, typeName, _schema, externalValue) {
828 return _this.transformEnumValue(typeName, externalValue, valueConfig);
829 },
830 _a));
831 return this.transformedSchema;
832 };
833 TransformEnumValues.prototype.transformRequest = function (originalRequest, delegationContext, transformationContext) {
834 return this.transformer.transformRequest(originalRequest, delegationContext, transformationContext);
835 };
836 TransformEnumValues.prototype.transformResult = function (originalResult, delegationContext, transformationContext) {
837 return this.transformer.transformResult(originalResult, delegationContext, transformationContext);
838 };
839 TransformEnumValues.prototype.transformEnumValue = function (typeName, externalValue, enumValueConfig) {
840 var transformedEnumValue = this.enumValueTransformer(typeName, externalValue, enumValueConfig);
841 if (Array.isArray(transformedEnumValue)) {
842 var newExternalValue = transformedEnumValue[0];
843 if (newExternalValue !== externalValue) {
844 if (!(typeName in this.mapping)) {
845 this.mapping[typeName] = Object.create(null);
846 this.reverseMapping[typeName] = Object.create(null);
847 }
848 this.mapping[typeName][externalValue] = newExternalValue;
849 this.reverseMapping[typeName][newExternalValue] = externalValue;
850 }
851 }
852 return transformedEnumValue;
853 };
854 return TransformEnumValues;
855}());
856function mapEnumValues(typeName, value, mapping) {
857 var _a;
858 var newExternalValue = (_a = mapping[typeName]) === null || _a === void 0 ? void 0 : _a[value];
859 return newExternalValue != null ? newExternalValue : value;
860}
861function generateValueTransformer(valueTransformer, mapping) {
862 if (valueTransformer == null) {
863 return function (typeName, value) { return mapEnumValues(typeName, value, mapping); };
864 }
865 else {
866 return function (typeName, value) { return mapEnumValues(typeName, valueTransformer(typeName, value), mapping); };
867 }
868}
869
870var TransformQuery = /** @class */ (function () {
871 function TransformQuery(_a) {
872 var path = _a.path, queryTransformer = _a.queryTransformer, _b = _a.resultTransformer, resultTransformer = _b === void 0 ? function (result) { return result; } : _b, _c = _a.errorPathTransformer, errorPathTransformer = _c === void 0 ? function (errorPath) { return [].concat(errorPath); } : _c, _d = _a.fragments, fragments = _d === void 0 ? {} : _d;
873 this.path = path;
874 this.queryTransformer = queryTransformer;
875 this.resultTransformer = resultTransformer;
876 this.errorPathTransformer = errorPathTransformer;
877 this.fragments = fragments;
878 }
879 TransformQuery.prototype.transformRequest = function (originalRequest) {
880 var _a;
881 var _this = this;
882 var pathLength = this.path.length;
883 var index = 0;
884 var document = graphql.visit(originalRequest.document, (_a = {},
885 _a[graphql.Kind.FIELD] = {
886 enter: function (node) {
887 if (index === pathLength || node.name.value !== _this.path[index]) {
888 return false;
889 }
890 index++;
891 if (index === pathLength) {
892 var selectionSet = _this.queryTransformer(node.selectionSet, _this.fragments);
893 return tslib.__assign(tslib.__assign({}, node), { selectionSet: selectionSet });
894 }
895 },
896 leave: function () {
897 index--;
898 },
899 },
900 _a));
901 return tslib.__assign(tslib.__assign({}, originalRequest), { document: document });
902 };
903 TransformQuery.prototype.transformResult = function (originalResult) {
904 var data = this.transformData(originalResult.data);
905 var errors = originalResult.errors;
906 return {
907 data: data,
908 errors: errors != null ? this.transformErrors(errors) : undefined,
909 };
910 };
911 TransformQuery.prototype.transformData = function (data) {
912 var leafIndex = this.path.length - 1;
913 var index = 0;
914 var newData = data;
915 if (newData) {
916 var next = this.path[index];
917 while (index < leafIndex) {
918 if (data[next]) {
919 newData = newData[next];
920 }
921 else {
922 break;
923 }
924 index++;
925 next = this.path[index];
926 }
927 newData[next] = this.resultTransformer(newData[next]);
928 }
929 return newData;
930 };
931 TransformQuery.prototype.transformErrors = function (errors) {
932 var _this = this;
933 return errors.map(function (error) {
934 var path = error.path;
935 var match = true;
936 var index = 0;
937 while (index < _this.path.length) {
938 if (path[index] !== _this.path[index]) {
939 match = false;
940 break;
941 }
942 index++;
943 }
944 var newPath = match ? path.slice(0, index).concat(_this.errorPathTransformer(path.slice(index))) : path;
945 return utils.relocatedError(error, newPath);
946 });
947 };
948 return TransformQuery;
949}());
950
951var FilterObjectFieldDirectives = /** @class */ (function () {
952 function FilterObjectFieldDirectives(filter) {
953 this.filter = filter;
954 }
955 FilterObjectFieldDirectives.prototype.transformSchema = function (originalSchema) {
956 var _this = this;
957 var transformer = new TransformObjectFields(function (_typeName, _fieldName, fieldConfig) {
958 var keepDirectives = fieldConfig.astNode.directives.filter(function (dir) {
959 var directiveDef = originalSchema.getDirective(dir.name.value);
960 var directiveValue = directiveDef ? utils.getArgumentValues(directiveDef, dir) : undefined;
961 return _this.filter(dir.name.value, directiveValue);
962 });
963 if (keepDirectives.length !== fieldConfig.astNode.directives.length) {
964 fieldConfig = tslib.__assign(tslib.__assign({}, fieldConfig), { astNode: tslib.__assign(tslib.__assign({}, fieldConfig.astNode), { directives: keepDirectives }) });
965 return fieldConfig;
966 }
967 });
968 return transformer.transformSchema(originalSchema);
969 };
970 return FilterObjectFieldDirectives;
971}());
972
973var RemoveObjectFieldDirectives = /** @class */ (function () {
974 function RemoveObjectFieldDirectives(directiveName, args) {
975 if (args === void 0) { args = {}; }
976 this.transformer = new FilterObjectFieldDirectives(function (dirName, dirValue) {
977 return !(utils.valueMatchesCriteria(dirName, directiveName) && utils.valueMatchesCriteria(dirValue, args));
978 });
979 }
980 RemoveObjectFieldDirectives.prototype.transformSchema = function (originalSchema) {
981 return this.transformer.transformSchema(originalSchema);
982 };
983 return RemoveObjectFieldDirectives;
984}());
985
986var RemoveObjectFieldsWithDirective = /** @class */ (function () {
987 function RemoveObjectFieldsWithDirective(directiveName, args) {
988 if (args === void 0) { args = {}; }
989 this.directiveName = directiveName;
990 this.args = args;
991 }
992 RemoveObjectFieldsWithDirective.prototype.transformSchema = function (originalSchema) {
993 var _this = this;
994 var transformer = new FilterObjectFields(function (_typeName, _fieldName, fieldConfig) {
995 var valueMap = utils.getDirectives(originalSchema, fieldConfig);
996 return !Object.keys(valueMap).some(function (directiveName) {
997 return utils.valueMatchesCriteria(directiveName, _this.directiveName) &&
998 ((Array.isArray(valueMap[directiveName]) &&
999 valueMap[directiveName].some(function (value) { return utils.valueMatchesCriteria(value, _this.args); })) ||
1000 utils.valueMatchesCriteria(valueMap[directiveName], _this.args));
1001 });
1002 });
1003 return transformer.transformSchema(originalSchema);
1004 };
1005 return RemoveObjectFieldsWithDirective;
1006}());
1007
1008var RemoveObjectFieldDeprecations = /** @class */ (function () {
1009 function RemoveObjectFieldDeprecations(reason) {
1010 var args = { reason: reason };
1011 this.removeDirectives = new FilterObjectFieldDirectives(function (dirName, dirValue) {
1012 return !(dirName === 'deprecated' && utils.valueMatchesCriteria(dirValue, args));
1013 });
1014 this.removeDeprecations = new TransformObjectFields(function (_typeName, _fieldName, fieldConfig) {
1015 if (fieldConfig.deprecationReason && utils.valueMatchesCriteria(fieldConfig.deprecationReason, reason)) {
1016 fieldConfig = tslib.__assign({}, fieldConfig);
1017 delete fieldConfig.deprecationReason;
1018 }
1019 return fieldConfig;
1020 });
1021 }
1022 RemoveObjectFieldDeprecations.prototype.transformSchema = function (originalSchema) {
1023 return this.removeDeprecations.transformSchema(this.removeDirectives.transformSchema(originalSchema));
1024 };
1025 return RemoveObjectFieldDeprecations;
1026}());
1027
1028var RemoveObjectFieldsWithDeprecation = /** @class */ (function () {
1029 function RemoveObjectFieldsWithDeprecation(reason) {
1030 this.transformer = new FilterObjectFields(function (_typeName, _fieldName, fieldConfig) {
1031 if (fieldConfig.deprecationReason) {
1032 return !utils.valueMatchesCriteria(fieldConfig.deprecationReason, reason);
1033 }
1034 return true;
1035 });
1036 }
1037 RemoveObjectFieldsWithDeprecation.prototype.transformSchema = function (originalSchema) {
1038 return this.transformer.transformSchema(originalSchema);
1039 };
1040 return RemoveObjectFieldsWithDeprecation;
1041}());
1042
1043var MapFields = /** @class */ (function () {
1044 function MapFields(fieldNodeTransformerMap, objectValueTransformerMap, errorsTransformer) {
1045 this.transformer = new TransformCompositeFields(function () { return undefined; }, function (typeName, fieldName, fieldNode, fragments, transformationContext) {
1046 var typeTransformers = fieldNodeTransformerMap[typeName];
1047 if (typeTransformers == null) {
1048 return undefined;
1049 }
1050 var fieldNodeTransformer = typeTransformers[fieldName];
1051 if (fieldNodeTransformer == null) {
1052 return undefined;
1053 }
1054 return fieldNodeTransformer(fieldNode, fragments, transformationContext);
1055 }, objectValueTransformerMap != null
1056 ? function (data, transformationContext) {
1057 if (data == null) {
1058 return data;
1059 }
1060 var typeName = data.__typename;
1061 if (typeName == null) {
1062 return data;
1063 }
1064 var transformer = objectValueTransformerMap[typeName];
1065 if (transformer == null) {
1066 return data;
1067 }
1068 return transformer(data, transformationContext);
1069 }
1070 : undefined, errorsTransformer != null ? errorsTransformer : undefined);
1071 }
1072 MapFields.prototype.transformSchema = function (schema) {
1073 return this.transformer.transformSchema(schema);
1074 };
1075 MapFields.prototype.transformRequest = function (originalRequest, delegationContext, transformationContext) {
1076 return this.transformer.transformRequest(originalRequest, delegationContext, transformationContext);
1077 };
1078 MapFields.prototype.transformResult = function (originalResult, delegationContext, transformationContext) {
1079 return this.transformer.transformResult(originalResult, delegationContext, transformationContext);
1080 };
1081 return MapFields;
1082}());
1083
1084var ExtendSchema = /** @class */ (function () {
1085 function ExtendSchema(_a) {
1086 var typeDefs = _a.typeDefs, _b = _a.resolvers, resolvers = _b === void 0 ? {} : _b, defaultFieldResolver = _a.defaultFieldResolver, fieldNodeTransformerMap = _a.fieldNodeTransformerMap, objectValueTransformerMap = _a.objectValueTransformerMap, errorsTransformer = _a.errorsTransformer;
1087 this.typeDefs = typeDefs;
1088 this.resolvers = resolvers;
1089 this.defaultFieldResolver = defaultFieldResolver != null ? defaultFieldResolver : delegate.defaultMergedResolver;
1090 this.transformer = new MapFields(fieldNodeTransformerMap != null ? fieldNodeTransformerMap : {}, objectValueTransformerMap, errorsTransformer);
1091 }
1092 ExtendSchema.prototype.transformSchema = function (schema$1) {
1093 // MapFields's transformSchema function does not actually modify the schema --
1094 // it saves the current schema state, to be used later to transform requests.
1095 this.transformer.transformSchema(schema$1);
1096 return schema.addResolversToSchema({
1097 schema: this.typeDefs ? graphql.extendSchema(schema$1, graphql.parse(this.typeDefs)) : schema$1,
1098 resolvers: this.resolvers != null ? this.resolvers : {},
1099 defaultFieldResolver: this.defaultFieldResolver,
1100 });
1101 };
1102 ExtendSchema.prototype.transformRequest = function (originalRequest, delegationContext, transformationContext) {
1103 return this.transformer.transformRequest(originalRequest, delegationContext, transformationContext);
1104 };
1105 ExtendSchema.prototype.transformResult = function (originalResult, delegationContext, transformationContext) {
1106 return this.transformer.transformResult(originalResult, delegationContext, transformationContext);
1107 };
1108 return ExtendSchema;
1109}());
1110
1111var PruneTypes = /** @class */ (function () {
1112 function PruneTypes(options) {
1113 this.options = options;
1114 }
1115 PruneTypes.prototype.transformSchema = function (schema) {
1116 return utils.pruneSchema(schema, this.options);
1117 };
1118 return PruneTypes;
1119}());
1120
1121function defaultWrappingResolver(parent, args, context, info) {
1122 if (!parent) {
1123 return {};
1124 }
1125 return delegate.defaultMergedResolver(parent, args, context, info);
1126}
1127var WrapFields = /** @class */ (function () {
1128 function WrapFields(outerTypeName, wrappingFieldNames, wrappingTypeNames, fieldNames, wrappingResolver, prefix) {
1129 var _a, _b, _c;
1130 if (wrappingResolver === void 0) { wrappingResolver = defaultWrappingResolver; }
1131 if (prefix === void 0) { prefix = 'gqtld'; }
1132 this.outerTypeName = outerTypeName;
1133 this.wrappingFieldNames = wrappingFieldNames;
1134 this.wrappingTypeNames = wrappingTypeNames;
1135 this.numWraps = wrappingFieldNames.length;
1136 this.fieldNames = fieldNames;
1137 this.wrappingResolver = wrappingResolver;
1138 var remainingWrappingFieldNames = this.wrappingFieldNames.slice();
1139 var outerMostWrappingFieldName = remainingWrappingFieldNames.shift();
1140 this.transformer = new MapFields((_a = {},
1141 _a[outerTypeName] = (_b = {},
1142 _b[outerMostWrappingFieldName] = function (fieldNode, fragments, transformationContext) {
1143 return hoistFieldNodes({
1144 fieldNode: fieldNode,
1145 path: remainingWrappingFieldNames,
1146 fieldNames: fieldNames,
1147 fragments: fragments,
1148 transformationContext: transformationContext,
1149 prefix: prefix,
1150 });
1151 },
1152 _b),
1153 _a), (_c = {},
1154 _c[outerTypeName] = function (value, context) { return dehoistValue(value, context); },
1155 _c), function (errors, context) { return dehoistErrors(errors, context); });
1156 }
1157 WrapFields.prototype.transformSchema = function (schema) {
1158 var _a, _b, _c;
1159 var _this = this;
1160 var targetFieldConfigMap = utils.selectObjectFields(schema, this.outerTypeName, !this.fieldNames ? function () { return true; } : function (fieldName) { return _this.fieldNames.includes(fieldName); });
1161 var wrapIndex = this.numWraps - 1;
1162 var wrappingTypeName = this.wrappingTypeNames[wrapIndex];
1163 var wrappingFieldName = this.wrappingFieldNames[wrapIndex];
1164 var newSchema = utils.appendObjectFields(schema, wrappingTypeName, targetFieldConfigMap);
1165 for (wrapIndex--; wrapIndex > -1; wrapIndex--) {
1166 var nextWrappingTypeName = this.wrappingTypeNames[wrapIndex];
1167 newSchema = utils.appendObjectFields(newSchema, nextWrappingTypeName, (_a = {},
1168 _a[wrappingFieldName] = {
1169 type: newSchema.getType(wrappingTypeName),
1170 resolve: this.wrappingResolver,
1171 },
1172 _a));
1173 wrappingTypeName = nextWrappingTypeName;
1174 wrappingFieldName = this.wrappingFieldNames[wrapIndex];
1175 }
1176 var selectedFieldNames = Object.keys(targetFieldConfigMap);
1177 _c = tslib.__read(utils.modifyObjectFields(newSchema, this.outerTypeName, function (fieldName) { return selectedFieldNames.includes(fieldName); }, (_b = {},
1178 _b[wrappingFieldName] = {
1179 type: newSchema.getType(wrappingTypeName),
1180 resolve: this.wrappingResolver,
1181 },
1182 _b)), 1), newSchema = _c[0];
1183 return this.transformer.transformSchema(newSchema);
1184 };
1185 WrapFields.prototype.transformRequest = function (originalRequest, delegationContext, transformationContext) {
1186 transformationContext.nextIndex = 0;
1187 transformationContext.paths = Object.create(null);
1188 return this.transformer.transformRequest(originalRequest, delegationContext, transformationContext);
1189 };
1190 WrapFields.prototype.transformResult = function (originalResult, delegationContext, transformationContext) {
1191 return this.transformer.transformResult(originalResult, delegationContext, transformationContext);
1192 };
1193 return WrapFields;
1194}());
1195function collectFields(selectionSet, fragments, fields, visitedFragmentNames) {
1196 if (fields === void 0) { fields = []; }
1197 if (visitedFragmentNames === void 0) { visitedFragmentNames = {}; }
1198 if (selectionSet != null) {
1199 selectionSet.selections.forEach(function (selection) {
1200 switch (selection.kind) {
1201 case graphql.Kind.FIELD:
1202 fields.push(selection);
1203 break;
1204 case graphql.Kind.INLINE_FRAGMENT:
1205 collectFields(selection.selectionSet, fragments, fields, visitedFragmentNames);
1206 break;
1207 case graphql.Kind.FRAGMENT_SPREAD: {
1208 var fragmentName = selection.name.value;
1209 if (!visitedFragmentNames[fragmentName]) {
1210 visitedFragmentNames[fragmentName] = true;
1211 collectFields(fragments[fragmentName].selectionSet, fragments, fields, visitedFragmentNames);
1212 }
1213 break;
1214 }
1215 }
1216 });
1217 }
1218 return fields;
1219}
1220function aliasFieldNode(fieldNode, str) {
1221 return tslib.__assign(tslib.__assign({}, fieldNode), { alias: {
1222 kind: graphql.Kind.NAME,
1223 value: str,
1224 } });
1225}
1226function hoistFieldNodes(_a) {
1227 var fieldNode = _a.fieldNode, fieldNames = _a.fieldNames, path = _a.path, fragments = _a.fragments, transformationContext = _a.transformationContext, prefix = _a.prefix, _b = _a.index, index = _b === void 0 ? 0 : _b, _c = _a.wrappingPath, wrappingPath = _c === void 0 ? [] : _c;
1228 var alias = fieldNode.alias != null ? fieldNode.alias.value : fieldNode.name.value;
1229 var newFieldNodes = [];
1230 if (index < path.length) {
1231 var pathSegment_1 = path[index];
1232 collectFields(fieldNode.selectionSet, fragments).forEach(function (possibleFieldNode) {
1233 if (possibleFieldNode.name.value === pathSegment_1) {
1234 var newWrappingPath = wrappingPath.concat([alias]);
1235 newFieldNodes = newFieldNodes.concat(hoistFieldNodes({
1236 fieldNode: possibleFieldNode,
1237 fieldNames: fieldNames,
1238 path: path,
1239 fragments: fragments,
1240 transformationContext: transformationContext,
1241 prefix: prefix,
1242 index: index + 1,
1243 wrappingPath: newWrappingPath,
1244 }));
1245 }
1246 });
1247 }
1248 else {
1249 collectFields(fieldNode.selectionSet, fragments).forEach(function (possibleFieldNode) {
1250 if (!fieldNames || fieldNames.includes(possibleFieldNode.name.value)) {
1251 var nextIndex = transformationContext.nextIndex;
1252 transformationContext.nextIndex++;
1253 var indexingAlias = "__" + prefix + nextIndex + "__";
1254 transformationContext.paths[indexingAlias] = {
1255 pathToField: wrappingPath.concat([alias]),
1256 alias: possibleFieldNode.alias != null ? possibleFieldNode.alias.value : possibleFieldNode.name.value,
1257 };
1258 newFieldNodes.push(aliasFieldNode(possibleFieldNode, indexingAlias));
1259 }
1260 });
1261 }
1262 return newFieldNodes;
1263}
1264function dehoistValue(originalValue, context) {
1265 if (originalValue == null) {
1266 return originalValue;
1267 }
1268 var newValue = Object.create(null);
1269 Object.keys(originalValue).forEach(function (alias) {
1270 var obj = newValue;
1271 var path = context.paths[alias];
1272 if (path == null) {
1273 newValue[alias] = originalValue[alias];
1274 return;
1275 }
1276 var pathToField = path.pathToField;
1277 var fieldAlias = path.alias;
1278 pathToField.forEach(function (key) {
1279 obj = obj[key] = obj[key] || Object.create(null);
1280 });
1281 obj[fieldAlias] = originalValue[alias];
1282 });
1283 return newValue;
1284}
1285function dehoistErrors(errors, context) {
1286 if (errors === undefined) {
1287 return undefined;
1288 }
1289 return errors.map(function (error) {
1290 var originalPath = error.path;
1291 if (originalPath == null) {
1292 return error;
1293 }
1294 var newPath = [];
1295 originalPath.forEach(function (pathSegment) {
1296 if (typeof pathSegment !== 'string') {
1297 newPath.push(pathSegment);
1298 return;
1299 }
1300 var path = context.paths[pathSegment];
1301 if (path == null) {
1302 newPath.push(pathSegment);
1303 return;
1304 }
1305 newPath = newPath.concat(path.pathToField, [path.alias]);
1306 });
1307 return utils.relocatedError(error, newPath);
1308 });
1309}
1310
1311var WrapType = /** @class */ (function () {
1312 function WrapType(outerTypeName, innerTypeName, fieldName) {
1313 this.transformer = new WrapFields(outerTypeName, [fieldName], [innerTypeName]);
1314 }
1315 WrapType.prototype.transformSchema = function (schema) {
1316 return this.transformer.transformSchema(schema);
1317 };
1318 WrapType.prototype.transformRequest = function (originalRequest, delegationContext, transformationContext) {
1319 return this.transformer.transformRequest(originalRequest, delegationContext, transformationContext);
1320 };
1321 WrapType.prototype.transformResult = function (originalResult, delegationContext, transformationContext) {
1322 return this.transformer.transformResult(originalResult, delegationContext, transformationContext);
1323 };
1324 return WrapType;
1325}());
1326
1327var HoistField = /** @class */ (function () {
1328 function HoistField(typeName, path, newFieldName, alias) {
1329 var _a, _b, _c;
1330 if (alias === void 0) { alias = '__gqtlw__'; }
1331 this.typeName = typeName;
1332 this.newFieldName = newFieldName;
1333 var pathToField = path.slice();
1334 var oldFieldName = pathToField.pop();
1335 this.oldFieldName = oldFieldName;
1336 this.pathToField = pathToField;
1337 this.transformer = new MapFields((_a = {},
1338 _a[typeName] = (_b = {},
1339 _b[newFieldName] = function (fieldNode) { return wrapFieldNode(utils.renameFieldNode(fieldNode, oldFieldName), pathToField, alias); },
1340 _b),
1341 _a), (_c = {},
1342 _c[typeName] = function (value) { return unwrapValue(value, alias); },
1343 _c), function (errors) { return unwrapErrors(errors, alias); });
1344 }
1345 HoistField.prototype.transformSchema = function (schema) {
1346 var _a;
1347 var _this = this;
1348 var innerType = this.pathToField.reduce(function (acc, pathSegment) { return graphql.getNullableType(acc.getFields()[pathSegment].type); }, schema.getType(this.typeName));
1349 var _b = tslib.__read(utils.removeObjectFields(schema, innerType.name, function (fieldName) { return fieldName === _this.oldFieldName; }), 2), newSchema = _b[0], targetFieldConfigMap = _b[1];
1350 var targetField = targetFieldConfigMap[this.oldFieldName];
1351 var targetType = targetField.type;
1352 newSchema = utils.appendObjectFields(newSchema, this.typeName, (_a = {},
1353 _a[this.newFieldName] = {
1354 type: targetType,
1355 resolve: delegate.defaultMergedResolver,
1356 },
1357 _a));
1358 return this.transformer.transformSchema(newSchema);
1359 };
1360 HoistField.prototype.transformRequest = function (originalRequest, delegationContext, transformationContext) {
1361 return this.transformer.transformRequest(originalRequest, delegationContext, transformationContext);
1362 };
1363 HoistField.prototype.transformResult = function (originalResult, delegationContext, transformationContext) {
1364 return this.transformer.transformResult(originalResult, delegationContext, transformationContext);
1365 };
1366 return HoistField;
1367}());
1368function wrapFieldNode(fieldNode, path, alias) {
1369 var newFieldNode = fieldNode;
1370 path.forEach(function (fieldName) {
1371 newFieldNode = {
1372 kind: graphql.Kind.FIELD,
1373 alias: {
1374 kind: graphql.Kind.NAME,
1375 value: alias,
1376 },
1377 name: {
1378 kind: graphql.Kind.NAME,
1379 value: fieldName,
1380 },
1381 selectionSet: {
1382 kind: graphql.Kind.SELECTION_SET,
1383 selections: [fieldNode],
1384 },
1385 };
1386 });
1387 return newFieldNode;
1388}
1389function unwrapValue(originalValue, alias) {
1390 var newValue = originalValue;
1391 var object = newValue[alias];
1392 while (object != null) {
1393 newValue = object;
1394 object = newValue[alias];
1395 }
1396 delete originalValue[alias];
1397 Object.assign(originalValue, newValue);
1398 return originalValue;
1399}
1400function unwrapErrors(errors, alias) {
1401 if (errors === undefined) {
1402 return undefined;
1403 }
1404 return errors.map(function (error) {
1405 var originalPath = error.path;
1406 if (originalPath == null) {
1407 return error;
1408 }
1409 var newPath = originalPath.filter(function (pathSegment) { return pathSegment !== alias; });
1410 return utils.relocatedError(error, newPath);
1411 });
1412}
1413
1414var WrapQuery = /** @class */ (function () {
1415 function WrapQuery(path, wrapper, extractor) {
1416 this.path = path;
1417 this.wrapper = wrapper;
1418 this.extractor = extractor;
1419 }
1420 WrapQuery.prototype.transformRequest = function (originalRequest) {
1421 var _a;
1422 var _this = this;
1423 var fieldPath = [];
1424 var ourPath = JSON.stringify(this.path);
1425 var document = graphql.visit(originalRequest.document, (_a = {},
1426 _a[graphql.Kind.FIELD] = {
1427 enter: function (node) {
1428 fieldPath.push(node.name.value);
1429 if (ourPath === JSON.stringify(fieldPath)) {
1430 var wrapResult = _this.wrapper(node.selectionSet);
1431 // Selection can be either a single selection or a selection set. If it's just one selection,
1432 // let's wrap it in a selection set. Otherwise, keep it as is.
1433 var selectionSet = wrapResult != null && wrapResult.kind === graphql.Kind.SELECTION_SET
1434 ? wrapResult
1435 : {
1436 kind: graphql.Kind.SELECTION_SET,
1437 selections: [wrapResult],
1438 };
1439 return tslib.__assign(tslib.__assign({}, node), { selectionSet: selectionSet });
1440 }
1441 },
1442 leave: function () {
1443 fieldPath.pop();
1444 },
1445 },
1446 _a));
1447 return tslib.__assign(tslib.__assign({}, originalRequest), { document: document });
1448 };
1449 WrapQuery.prototype.transformResult = function (originalResult) {
1450 var rootData = originalResult.data;
1451 if (rootData != null) {
1452 var data = rootData;
1453 var path = tslib.__spread(this.path);
1454 while (path.length > 1) {
1455 var next = path.shift();
1456 if (data[next]) {
1457 data = data[next];
1458 }
1459 }
1460 data[path[0]] = this.extractor(data[path[0]]);
1461 }
1462 return {
1463 data: rootData,
1464 errors: originalResult.errors,
1465 };
1466 };
1467 return WrapQuery;
1468}());
1469
1470var ExtractField = /** @class */ (function () {
1471 function ExtractField(_a) {
1472 var from = _a.from, to = _a.to;
1473 this.from = from;
1474 this.to = to;
1475 }
1476 ExtractField.prototype.transformRequest = function (originalRequest) {
1477 var _a, _b;
1478 var fromSelection;
1479 var ourPathFrom = JSON.stringify(this.from);
1480 var ourPathTo = JSON.stringify(this.to);
1481 var fieldPath = [];
1482 graphql.visit(originalRequest.document, (_a = {},
1483 _a[graphql.Kind.FIELD] = {
1484 enter: function (node) {
1485 fieldPath.push(node.name.value);
1486 if (ourPathFrom === JSON.stringify(fieldPath)) {
1487 fromSelection = node.selectionSet;
1488 return graphql.BREAK;
1489 }
1490 },
1491 leave: function () {
1492 fieldPath.pop();
1493 },
1494 },
1495 _a));
1496 fieldPath = [];
1497 var document = graphql.visit(originalRequest.document, (_b = {},
1498 _b[graphql.Kind.FIELD] = {
1499 enter: function (node) {
1500 fieldPath.push(node.name.value);
1501 if (ourPathTo === JSON.stringify(fieldPath) && fromSelection != null) {
1502 return tslib.__assign(tslib.__assign({}, node), { selectionSet: fromSelection });
1503 }
1504 },
1505 leave: function () {
1506 fieldPath.pop();
1507 },
1508 },
1509 _b));
1510 return tslib.__assign(tslib.__assign({}, originalRequest), { document: document });
1511 };
1512 return ExtractField;
1513}());
1514
1515function makeRemoteExecutableSchema(_a) {
1516 var schemaOrTypeDefs = _a.schema, executor = _a.executor, subscriber = _a.subscriber, _b = _a.createResolver, createResolver = _b === void 0 ? defaultCreateRemoteResolver : _b, buildSchemaOptions = _a.buildSchemaOptions;
1517 var targetSchema = typeof schemaOrTypeDefs === 'string' ? graphql.buildSchema(schemaOrTypeDefs, buildSchemaOptions) : schemaOrTypeDefs;
1518 return wrapSchema({
1519 schema: targetSchema,
1520 createProxyingResolver: function () { return createResolver(executor, subscriber); },
1521 });
1522}
1523function defaultCreateRemoteResolver(executor, subscriber) {
1524 return function (_parent, _args, context, info) {
1525 return delegate.delegateToSchema({
1526 schema: { schema: info.schema, executor: executor, subscriber: subscriber },
1527 context: context,
1528 info: info,
1529 });
1530 };
1531}
1532
1533var cleanInternalStack = function (stack) { return stack.replace(/\s+at .*aggregate-error\/index.js:\d+:\d+\)?/g, ''); };
1534
1535/**
1536Escape RegExp special characters.
1537You can also use this to escape a string that is inserted into the middle of a regex, for example, into a character class.
1538@example
1539```
1540import escapeStringRegexp = require('escape-string-regexp');
1541const escapedString = escapeStringRegexp('How much $ for a 🦄?');
1542//=> 'How much \\$ for a 🦄\\?'
1543new RegExp(escapedString);
1544```
1545*/
1546var escapeStringRegexp = function (string) {
1547 if (typeof string !== 'string') {
1548 throw new TypeError('Expected a string');
1549 }
1550 // Escape characters with special meaning either inside or outside character sets.
1551 // Use a simple backslash escape when it’s always valid, and a `\xnn` escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.
1552 return string
1553 .replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
1554 .replace(/-/g, '\\x2d');
1555};
1556
1557var extractPathRegex = /\s+at.*[(\s](.*)\)?/;
1558var pathRegex = /^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/(?:babel-polyfill|pirates)\/.*)?\w+)\.js:\d+:\d+)|native)/;
1559/**
1560Clean up error stack traces. Removes the mostly unhelpful internal Node.js entries.
1561@param stack - The `stack` property of an `Error`.
1562@example
1563```
1564import cleanStack = require('clean-stack');
1565const error = new Error('Missing unicorn');
1566console.log(error.stack);
1567// Error: Missing unicorn
1568// at Object.<anonymous> (/Users/sindresorhus/dev/clean-stack/unicorn.js:2:15)
1569// at Module._compile (module.js:409:26)
1570// at Object.Module._extensions..js (module.js:416:10)
1571// at Module.load (module.js:343:32)
1572// at Function.Module._load (module.js:300:12)
1573// at Function.Module.runMain (module.js:441:10)
1574// at startup (node.js:139:18)
1575console.log(cleanStack(error.stack));
1576// Error: Missing unicorn
1577// at Object.<anonymous> (/Users/sindresorhus/dev/clean-stack/unicorn.js:2:15)
1578```
1579*/
1580var cleanStack = function (stack, basePath) {
1581 var basePathRegex = basePath && new RegExp("(at | \\()" + escapeStringRegexp(basePath), 'g');
1582 return stack.replace(/\\/g, '/')
1583 .split('\n')
1584 .filter(function (line) {
1585 var pathMatches = line.match(extractPathRegex);
1586 if (pathMatches === null || !pathMatches[1]) {
1587 return true;
1588 }
1589 var match = pathMatches[1];
1590 // Electron
1591 if (match.includes('.app/Contents/Resources/electron.asar') ||
1592 match.includes('.app/Contents/Resources/default_app.asar')) {
1593 return false;
1594 }
1595 return !pathRegex.test(match);
1596 })
1597 .filter(function (line) { return line.trim() !== ''; })
1598 .map(function (line) {
1599 if (basePathRegex) {
1600 line = line.replace(basePathRegex, '$1');
1601 }
1602 return line;
1603 })
1604 .join('\n');
1605};
1606
1607/**
1608Indent each line in a string.
1609@param string - The string to indent.
1610@param count - How many times you want `options.indent` repeated. Default: `1`.
1611@example
1612```
1613import indentString = require('indent-string');
1614indentString('Unicorns\nRainbows', 4);
1615//=> ' Unicorns\n Rainbows'
1616indentString('Unicorns\nRainbows', 4, {indent: '♥'});
1617//=> '♥♥♥♥Unicorns\n♥♥♥♥Rainbows'
1618```
1619*/
1620var indentString = function (string, count, options) {
1621 if (count === void 0) { count = 1; }
1622 options = Object.assign({
1623 indent: ' ',
1624 includeEmptyLines: false,
1625 }, options);
1626 if (typeof string !== 'string') {
1627 throw new TypeError("Expected `input` to be a `string`, got `" + typeof string + "`");
1628 }
1629 if (typeof count !== 'number') {
1630 throw new TypeError("Expected `count` to be a `number`, got `" + typeof count + "`");
1631 }
1632 if (count < 0) {
1633 throw new RangeError("Expected `count` to be at least 0, got `" + count + "`");
1634 }
1635 if (typeof options.indent !== 'string') {
1636 throw new TypeError("Expected `options.indent` to be a `string`, got `" + typeof options.indent + "`");
1637 }
1638 if (count === 0) {
1639 return string;
1640 }
1641 var regex = options.includeEmptyLines ? /^/gm : /^(?!\s*$)/gm;
1642 return string.replace(regex, options.indent.repeat(count));
1643};
1644
1645var AggregateError = /** @class */ (function (_super) {
1646 tslib.__extends(AggregateError, _super);
1647 function AggregateError(errors) {
1648 var _this = this;
1649 if (!Array.isArray(errors)) {
1650 throw new TypeError("Expected input to be an Array, got " + typeof errors);
1651 }
1652 var normalizedErrors = errors.map(function (error) {
1653 if (error instanceof Error) {
1654 return error;
1655 }
1656 if (error !== null && typeof error === 'object') {
1657 // Handle plain error objects with message property and/or possibly other metadata
1658 return Object.assign(new Error(error.message), error);
1659 }
1660 return new Error(error);
1661 });
1662 var message = normalizedErrors
1663 .map(function (error) {
1664 // The `stack` property is not standardized, so we can't assume it exists
1665 return typeof error.stack === 'string' ? cleanInternalStack(cleanStack(error.stack)) : String(error);
1666 })
1667 .join('\n');
1668 message = '\n' + indentString(message, 4);
1669 _this = _super.call(this, message) || this;
1670 _this.name = 'AggregateError';
1671 Object.defineProperty(_this, Symbol.iterator, {
1672 get: function () { return function () { return normalizedErrors[Symbol.iterator](); }; },
1673 });
1674 return _this;
1675 }
1676 return AggregateError;
1677}(Error));
1678
1679function getSchemaFromIntrospection(introspectionResult) {
1680 var _a, _b;
1681 if ((_a = introspectionResult === null || introspectionResult === void 0 ? void 0 : introspectionResult.data) === null || _a === void 0 ? void 0 : _a.__schema) {
1682 return graphql.buildClientSchema(introspectionResult.data);
1683 }
1684 else if ((_b = introspectionResult === null || introspectionResult === void 0 ? void 0 : introspectionResult.errors) === null || _b === void 0 ? void 0 : _b.length) {
1685 if (introspectionResult.errors.length > 1) {
1686 var combinedError = new AggregateError(introspectionResult.errors);
1687 throw combinedError;
1688 }
1689 var error = introspectionResult.errors[0];
1690 throw error.originalError || error;
1691 }
1692 else {
1693 throw new Error('Could not obtain introspection result, received: ' + JSON.stringify(introspectionResult));
1694 }
1695}
1696function introspectSchema(executor, context, options) {
1697 return tslib.__awaiter(this, void 0, void 0, function () {
1698 var parsedIntrospectionQuery, introspectionResult;
1699 return tslib.__generator(this, function (_a) {
1700 switch (_a.label) {
1701 case 0:
1702 parsedIntrospectionQuery = graphql.parse(graphql.getIntrospectionQuery(options));
1703 return [4 /*yield*/, executor({
1704 document: parsedIntrospectionQuery,
1705 context: context,
1706 })];
1707 case 1:
1708 introspectionResult = _a.sent();
1709 return [2 /*return*/, getSchemaFromIntrospection(introspectionResult)];
1710 }
1711 });
1712 });
1713}
1714function introspectSchemaSync(executor, context, options) {
1715 var parsedIntrospectionQuery = graphql.parse(graphql.getIntrospectionQuery(options));
1716 var introspectionResult = executor({
1717 document: parsedIntrospectionQuery,
1718 context: context,
1719 });
1720 if ('then' in introspectionResult) {
1721 throw new Error("Executor cannot return promise value in introspectSchemaSync!");
1722 }
1723 return getSchemaFromIntrospection(introspectionResult);
1724}
1725
1726exports.ExtendSchema = ExtendSchema;
1727exports.ExtractField = ExtractField;
1728exports.FilterInputObjectFields = FilterInputObjectFields;
1729exports.FilterInterfaceFields = FilterInterfaceFields;
1730exports.FilterObjectFieldDirectives = FilterObjectFieldDirectives;
1731exports.FilterObjectFields = FilterObjectFields;
1732exports.FilterRootFields = FilterRootFields;
1733exports.FilterTypes = FilterTypes;
1734exports.HoistField = HoistField;
1735exports.MapFields = MapFields;
1736exports.MapLeafValues = MapLeafValues;
1737exports.PruneSchema = PruneTypes;
1738exports.RemoveObjectFieldDeprecations = RemoveObjectFieldDeprecations;
1739exports.RemoveObjectFieldDirectives = RemoveObjectFieldDirectives;
1740exports.RemoveObjectFieldsWithDeprecation = RemoveObjectFieldsWithDeprecation;
1741exports.RemoveObjectFieldsWithDirective = RemoveObjectFieldsWithDirective;
1742exports.RenameInputObjectFields = RenameInputObjectFields;
1743exports.RenameInterfaceFields = RenameInterfaceFields;
1744exports.RenameObjectFields = RenameObjectFields;
1745exports.RenameRootFields = RenameRootFields;
1746exports.RenameRootTypes = RenameRootTypes;
1747exports.RenameTypes = RenameTypes;
1748exports.TransformCompositeFields = TransformCompositeFields;
1749exports.TransformEnumValues = TransformEnumValues;
1750exports.TransformInputObjectFields = TransformInputObjectFields;
1751exports.TransformInterfaceFields = TransformInterfaceFields;
1752exports.TransformObjectFields = TransformObjectFields;
1753exports.TransformQuery = TransformQuery;
1754exports.TransformRootFields = TransformRootFields;
1755exports.WrapFields = WrapFields;
1756exports.WrapQuery = WrapQuery;
1757exports.WrapType = WrapType;
1758exports.defaultCreateProxyingResolver = defaultCreateProxyingResolver;
1759exports.defaultCreateRemoteResolver = defaultCreateRemoteResolver;
1760exports.generateProxyingResolvers = generateProxyingResolvers;
1761exports.introspectSchema = introspectSchema;
1762exports.introspectSchemaSync = introspectSchemaSync;
1763exports.makeRemoteExecutableSchema = makeRemoteExecutableSchema;
1764exports.wrapSchema = wrapSchema;
1765//# sourceMappingURL=index.cjs.js.map