@graphql-tools/utils 7.5.0-alpha-3e5e5d87.0 → 7.6.0
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.cjs.js +120 -93
- package/es5/index.cjs.js.map +1 -1
- package/es5/index.esm.js +121 -94
- package/es5/index.esm.js.map +1 -1
- package/es5/package.json +1 -1
- package/es5/types.d.ts +7 -1
- package/index.cjs.js +93 -66
- package/index.cjs.js.map +1 -1
- package/index.esm.js +93 -66
- package/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/types.d.ts +7 -1
package/es5/index.cjs.js
CHANGED
|
@@ -81,7 +81,7 @@ function debugLog() {
|
|
|
81
81
|
}
|
|
82
82
|
if (process && process.env && process.env.DEBUG && !process.env.GQL_tools_NODEBUG) {
|
|
83
83
|
// tslint:disable-next-line: no-console
|
|
84
|
-
console.log.apply(console, tslib.
|
|
84
|
+
console.log.apply(console, tslib.__spreadArray([], tslib.__read(args)));
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
|
|
@@ -118,7 +118,7 @@ function formatObjectValue(value, previouslySeenValues) {
|
|
|
118
118
|
if (previouslySeenValues.indexOf(value) !== -1) {
|
|
119
119
|
return '[Circular]';
|
|
120
120
|
}
|
|
121
|
-
var seenValues = tslib.
|
|
121
|
+
var seenValues = tslib.__spreadArray(tslib.__spreadArray([], tslib.__read(previouslySeenValues)), [value]);
|
|
122
122
|
var customInspectFn = getCustomFn(value);
|
|
123
123
|
if (customInspectFn !== undefined) {
|
|
124
124
|
var customValue = customInspectFn.call(value);
|
|
@@ -285,7 +285,7 @@ function getDirectives(schema, node, pathToDirectivesInExtensions) {
|
|
|
285
285
|
astNodes.push(node.astNode);
|
|
286
286
|
}
|
|
287
287
|
if ('extensionASTNodes' in node && node.extensionASTNodes) {
|
|
288
|
-
astNodes = tslib.
|
|
288
|
+
astNodes = tslib.__spreadArray(tslib.__spreadArray([], tslib.__read(astNodes)), tslib.__read(node.extensionASTNodes));
|
|
289
289
|
}
|
|
290
290
|
var result = {};
|
|
291
291
|
astNodes.forEach(function (astNode) {
|
|
@@ -338,7 +338,7 @@ function getFieldsWithDirectives(documentNode, options) {
|
|
|
338
338
|
var result = {};
|
|
339
339
|
var selected = ['ObjectTypeDefinition', 'ObjectTypeExtension'];
|
|
340
340
|
if (options.includeInputTypes) {
|
|
341
|
-
selected = tslib.
|
|
341
|
+
selected = tslib.__spreadArray(tslib.__spreadArray([], tslib.__read(selected)), ['InputObjectTypeDefinition', 'InputObjectTypeExtension']);
|
|
342
342
|
}
|
|
343
343
|
var allTypes = documentNode.definitions.filter(function (obj) { return selected.includes(obj.kind); });
|
|
344
344
|
try {
|
|
@@ -612,11 +612,12 @@ function astFromSchema(schema, pathToDirectivesInExtensions) {
|
|
|
612
612
|
directives: directives,
|
|
613
613
|
};
|
|
614
614
|
schemaNode.description =
|
|
615
|
-
((_b = (_a = schema.astNode) === null || _a === void 0 ? void 0 : _a.description) !== null && _b !== void 0 ? _b : schema.description != null)
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
615
|
+
((_b = (_a = schema.astNode) === null || _a === void 0 ? void 0 : _a.description) !== null && _b !== void 0 ? _b : schema.description != null)
|
|
616
|
+
? {
|
|
617
|
+
kind: graphql.Kind.STRING,
|
|
618
|
+
value: schema.description,
|
|
619
|
+
block: true,
|
|
620
|
+
}
|
|
620
621
|
: undefined;
|
|
621
622
|
return schemaNode;
|
|
622
623
|
}
|
|
@@ -634,13 +635,15 @@ function astFromDirective(directive, schema, pathToDirectivesInExtensions) {
|
|
|
634
635
|
kind: graphql.Kind.NAME,
|
|
635
636
|
value: directive.name,
|
|
636
637
|
},
|
|
637
|
-
arguments: (directive === null || directive === void 0 ? void 0 : directive.args)
|
|
638
|
+
arguments: (directive === null || directive === void 0 ? void 0 : directive.args)
|
|
639
|
+
? directive.args.map(function (arg) { return astFromArg(arg, schema, pathToDirectivesInExtensions); })
|
|
638
640
|
: undefined,
|
|
639
641
|
repeatable: directive.isRepeatable,
|
|
640
|
-
locations: (directive === null || directive === void 0 ? void 0 : directive.locations)
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
642
|
+
locations: (directive === null || directive === void 0 ? void 0 : directive.locations)
|
|
643
|
+
? directive.locations.map(function (location) { return ({
|
|
644
|
+
kind: graphql.Kind.NAME,
|
|
645
|
+
value: location,
|
|
646
|
+
}); })
|
|
644
647
|
: undefined,
|
|
645
648
|
};
|
|
646
649
|
}
|
|
@@ -658,7 +661,7 @@ function getDirectiveNodes(entity, schema, pathToDirectivesInExtensions) {
|
|
|
658
661
|
directives = makeDirectiveNodes(schema, directivesInExtensions);
|
|
659
662
|
}
|
|
660
663
|
else {
|
|
661
|
-
directives = [].concat.apply([], tslib.
|
|
664
|
+
directives = [].concat.apply([], tslib.__spreadArray([], tslib.__read(nodes.filter(function (node) { return node.directives != null; }).map(function (node) { return node.directives; }))));
|
|
662
665
|
}
|
|
663
666
|
return directives;
|
|
664
667
|
}
|
|
@@ -692,11 +695,12 @@ function astFromArg(arg, schema, pathToDirectivesInExtensions) {
|
|
|
692
695
|
var _a, _b;
|
|
693
696
|
return {
|
|
694
697
|
kind: graphql.Kind.INPUT_VALUE_DEFINITION,
|
|
695
|
-
description: ((_b = (_a = arg.astNode) === null || _a === void 0 ? void 0 : _a.description) !== null && _b !== void 0 ? _b : arg.description)
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
698
|
+
description: ((_b = (_a = arg.astNode) === null || _a === void 0 ? void 0 : _a.description) !== null && _b !== void 0 ? _b : arg.description)
|
|
699
|
+
? {
|
|
700
|
+
kind: graphql.Kind.STRING,
|
|
701
|
+
value: arg.description,
|
|
702
|
+
block: true,
|
|
703
|
+
}
|
|
700
704
|
: undefined,
|
|
701
705
|
name: {
|
|
702
706
|
kind: graphql.Kind.NAME,
|
|
@@ -711,11 +715,12 @@ function astFromObjectType(type, schema, pathToDirectivesInExtensions) {
|
|
|
711
715
|
var _a, _b;
|
|
712
716
|
return {
|
|
713
717
|
kind: graphql.Kind.OBJECT_TYPE_DEFINITION,
|
|
714
|
-
description: ((_b = (_a = type.astNode) === null || _a === void 0 ? void 0 : _a.description) !== null && _b !== void 0 ? _b : type.description)
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
718
|
+
description: ((_b = (_a = type.astNode) === null || _a === void 0 ? void 0 : _a.description) !== null && _b !== void 0 ? _b : type.description)
|
|
719
|
+
? {
|
|
720
|
+
kind: graphql.Kind.STRING,
|
|
721
|
+
value: type.description,
|
|
722
|
+
block: true,
|
|
723
|
+
}
|
|
719
724
|
: undefined,
|
|
720
725
|
name: {
|
|
721
726
|
kind: graphql.Kind.NAME,
|
|
@@ -730,11 +735,12 @@ function astFromInterfaceType(type, schema, pathToDirectivesInExtensions) {
|
|
|
730
735
|
var _a, _b;
|
|
731
736
|
var node = {
|
|
732
737
|
kind: graphql.Kind.INTERFACE_TYPE_DEFINITION,
|
|
733
|
-
description: ((_b = (_a = type.astNode) === null || _a === void 0 ? void 0 : _a.description) !== null && _b !== void 0 ? _b : type.description)
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
+
description: ((_b = (_a = type.astNode) === null || _a === void 0 ? void 0 : _a.description) !== null && _b !== void 0 ? _b : type.description)
|
|
739
|
+
? {
|
|
740
|
+
kind: graphql.Kind.STRING,
|
|
741
|
+
value: type.description,
|
|
742
|
+
block: true,
|
|
743
|
+
}
|
|
738
744
|
: undefined,
|
|
739
745
|
name: {
|
|
740
746
|
kind: graphql.Kind.NAME,
|
|
@@ -752,11 +758,12 @@ function astFromUnionType(type, schema, pathToDirectivesInExtensions) {
|
|
|
752
758
|
var _a, _b;
|
|
753
759
|
return {
|
|
754
760
|
kind: graphql.Kind.UNION_TYPE_DEFINITION,
|
|
755
|
-
description: ((_b = (_a = type.astNode) === null || _a === void 0 ? void 0 : _a.description) !== null && _b !== void 0 ? _b : type.description)
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
761
|
+
description: ((_b = (_a = type.astNode) === null || _a === void 0 ? void 0 : _a.description) !== null && _b !== void 0 ? _b : type.description)
|
|
762
|
+
? {
|
|
763
|
+
kind: graphql.Kind.STRING,
|
|
764
|
+
value: type.description,
|
|
765
|
+
block: true,
|
|
766
|
+
}
|
|
760
767
|
: undefined,
|
|
761
768
|
name: {
|
|
762
769
|
kind: graphql.Kind.NAME,
|
|
@@ -770,11 +777,12 @@ function astFromInputObjectType(type, schema, pathToDirectivesInExtensions) {
|
|
|
770
777
|
var _a, _b;
|
|
771
778
|
return {
|
|
772
779
|
kind: graphql.Kind.INPUT_OBJECT_TYPE_DEFINITION,
|
|
773
|
-
description: ((_b = (_a = type.astNode) === null || _a === void 0 ? void 0 : _a.description) !== null && _b !== void 0 ? _b : type.description)
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
780
|
+
description: ((_b = (_a = type.astNode) === null || _a === void 0 ? void 0 : _a.description) !== null && _b !== void 0 ? _b : type.description)
|
|
781
|
+
? {
|
|
782
|
+
kind: graphql.Kind.STRING,
|
|
783
|
+
value: type.description,
|
|
784
|
+
block: true,
|
|
785
|
+
}
|
|
778
786
|
: undefined,
|
|
779
787
|
name: {
|
|
780
788
|
kind: graphql.Kind.NAME,
|
|
@@ -790,11 +798,12 @@ function astFromEnumType(type, schema, pathToDirectivesInExtensions) {
|
|
|
790
798
|
var _a, _b;
|
|
791
799
|
return {
|
|
792
800
|
kind: graphql.Kind.ENUM_TYPE_DEFINITION,
|
|
793
|
-
description: ((_b = (_a = type.astNode) === null || _a === void 0 ? void 0 : _a.description) !== null && _b !== void 0 ? _b : type.description)
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
801
|
+
description: ((_b = (_a = type.astNode) === null || _a === void 0 ? void 0 : _a.description) !== null && _b !== void 0 ? _b : type.description)
|
|
802
|
+
? {
|
|
803
|
+
kind: graphql.Kind.STRING,
|
|
804
|
+
value: type.description,
|
|
805
|
+
block: true,
|
|
806
|
+
}
|
|
798
807
|
: undefined,
|
|
799
808
|
name: {
|
|
800
809
|
kind: graphql.Kind.NAME,
|
|
@@ -832,11 +841,12 @@ function astFromScalarType(type, schema, pathToDirectivesInExtensions) {
|
|
|
832
841
|
: [specifiedByDirectiveNode].concat(directiveNodesBesidesSpecifiedBy);
|
|
833
842
|
return {
|
|
834
843
|
kind: graphql.Kind.SCALAR_TYPE_DEFINITION,
|
|
835
|
-
description: ((_d = (_c = type.astNode) === null || _c === void 0 ? void 0 : _c.description) !== null && _d !== void 0 ? _d : type.description)
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
844
|
+
description: ((_d = (_c = type.astNode) === null || _c === void 0 ? void 0 : _c.description) !== null && _d !== void 0 ? _d : type.description)
|
|
845
|
+
? {
|
|
846
|
+
kind: graphql.Kind.STRING,
|
|
847
|
+
value: type.description,
|
|
848
|
+
block: true,
|
|
849
|
+
}
|
|
840
850
|
: undefined,
|
|
841
851
|
name: {
|
|
842
852
|
kind: graphql.Kind.NAME,
|
|
@@ -849,11 +859,12 @@ function astFromField(field, schema, pathToDirectivesInExtensions) {
|
|
|
849
859
|
var _a, _b;
|
|
850
860
|
return {
|
|
851
861
|
kind: graphql.Kind.FIELD_DEFINITION,
|
|
852
|
-
description: ((_b = (_a = field.astNode) === null || _a === void 0 ? void 0 : _a.description) !== null && _b !== void 0 ? _b : field.description)
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
862
|
+
description: ((_b = (_a = field.astNode) === null || _a === void 0 ? void 0 : _a.description) !== null && _b !== void 0 ? _b : field.description)
|
|
863
|
+
? {
|
|
864
|
+
kind: graphql.Kind.STRING,
|
|
865
|
+
value: field.description,
|
|
866
|
+
block: true,
|
|
867
|
+
}
|
|
857
868
|
: undefined,
|
|
858
869
|
name: {
|
|
859
870
|
kind: graphql.Kind.NAME,
|
|
@@ -868,11 +879,12 @@ function astFromInputField(field, schema, pathToDirectivesInExtensions) {
|
|
|
868
879
|
var _a, _b;
|
|
869
880
|
return {
|
|
870
881
|
kind: graphql.Kind.INPUT_VALUE_DEFINITION,
|
|
871
|
-
description: ((_b = (_a = field.astNode) === null || _a === void 0 ? void 0 : _a.description) !== null && _b !== void 0 ? _b : field.description)
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
882
|
+
description: ((_b = (_a = field.astNode) === null || _a === void 0 ? void 0 : _a.description) !== null && _b !== void 0 ? _b : field.description)
|
|
883
|
+
? {
|
|
884
|
+
kind: graphql.Kind.STRING,
|
|
885
|
+
value: field.description,
|
|
886
|
+
block: true,
|
|
887
|
+
}
|
|
876
888
|
: undefined,
|
|
877
889
|
name: {
|
|
878
890
|
kind: graphql.Kind.NAME,
|
|
@@ -887,11 +899,12 @@ function astFromEnumValue(value, schema, pathToDirectivesInExtensions) {
|
|
|
887
899
|
var _a, _b;
|
|
888
900
|
return {
|
|
889
901
|
kind: graphql.Kind.ENUM_VALUE_DEFINITION,
|
|
890
|
-
description: ((_b = (_a = value.astNode) === null || _a === void 0 ? void 0 : _a.description) !== null && _b !== void 0 ? _b : value.description)
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
902
|
+
description: ((_b = (_a = value.astNode) === null || _a === void 0 ? void 0 : _a.description) !== null && _b !== void 0 ? _b : value.description)
|
|
903
|
+
? {
|
|
904
|
+
kind: graphql.Kind.STRING,
|
|
905
|
+
value: value.description,
|
|
906
|
+
block: true,
|
|
907
|
+
}
|
|
895
908
|
: undefined,
|
|
896
909
|
name: {
|
|
897
910
|
kind: graphql.Kind.NAME,
|
|
@@ -995,7 +1008,7 @@ function validateGraphQlDocuments(schema, documentFiles, effectiveRules) {
|
|
|
995
1008
|
return tslib.__generator(this, function (_a) {
|
|
996
1009
|
documentToValidate = {
|
|
997
1010
|
kind: graphql.Kind.DOCUMENT,
|
|
998
|
-
definitions: tslib.
|
|
1011
|
+
definitions: tslib.__spreadArray(tslib.__spreadArray([], tslib.__read(allFragments)), tslib.__read(documentFile.document.definitions)).filter(function (definition, index, list) {
|
|
999
1012
|
if (definition.kind === graphql.Kind.FRAGMENT_DEFINITION) {
|
|
1000
1013
|
var firstIndex = list.findIndex(function (def) { return def.kind === graphql.Kind.FRAGMENT_DEFINITION && def.name.value === definition.name.value; });
|
|
1001
1014
|
var isDuplicated = firstIndex !== index;
|
|
@@ -1028,7 +1041,7 @@ function checkValidationErrors(loadDocumentErrors) {
|
|
|
1028
1041
|
if (loadDocumentErrors.length > 0) {
|
|
1029
1042
|
var errors = [];
|
|
1030
1043
|
var _loop_1 = function (loadDocumentError) {
|
|
1031
|
-
var e_3,
|
|
1044
|
+
var e_3, _b;
|
|
1032
1045
|
var _loop_2 = function (graphQLError) {
|
|
1033
1046
|
var error = new Error();
|
|
1034
1047
|
error.name = 'GraphQLDocumentError';
|
|
@@ -1038,15 +1051,15 @@ function checkValidationErrors(loadDocumentErrors) {
|
|
|
1038
1051
|
errors.push(error);
|
|
1039
1052
|
};
|
|
1040
1053
|
try {
|
|
1041
|
-
for (var
|
|
1042
|
-
var graphQLError =
|
|
1054
|
+
for (var _c = (e_3 = void 0, tslib.__values(loadDocumentError.errors)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
1055
|
+
var graphQLError = _d.value;
|
|
1043
1056
|
_loop_2(graphQLError);
|
|
1044
1057
|
}
|
|
1045
1058
|
}
|
|
1046
1059
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
1047
1060
|
finally {
|
|
1048
1061
|
try {
|
|
1049
|
-
if (
|
|
1062
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
1050
1063
|
}
|
|
1051
1064
|
finally { if (e_3) throw e_3.error; }
|
|
1052
1065
|
}
|
|
@@ -1402,7 +1415,7 @@ function buildOperationNodeForField(_a) {
|
|
|
1402
1415
|
selectedFields: selectedFields,
|
|
1403
1416
|
});
|
|
1404
1417
|
// attach variables
|
|
1405
|
-
operationNode.variableDefinitions = tslib.
|
|
1418
|
+
operationNode.variableDefinitions = tslib.__spreadArray([], tslib.__read(operationVariables));
|
|
1406
1419
|
resetOperationVariables();
|
|
1407
1420
|
resetFieldMap();
|
|
1408
1421
|
return operationNode;
|
|
@@ -1466,7 +1479,7 @@ function resolveSelectionSet(_a) {
|
|
|
1466
1479
|
kind: graphql.Kind.SELECTION_SET,
|
|
1467
1480
|
selections: types
|
|
1468
1481
|
.filter(function (t) {
|
|
1469
|
-
return !hasCircularRef(tslib.
|
|
1482
|
+
return !hasCircularRef(tslib.__spreadArray(tslib.__spreadArray([], tslib.__read(ancestors)), [t]), {
|
|
1470
1483
|
depth: circularReferenceDepth,
|
|
1471
1484
|
});
|
|
1472
1485
|
})
|
|
@@ -1505,7 +1518,7 @@ function resolveSelectionSet(_a) {
|
|
|
1505
1518
|
kind: graphql.Kind.SELECTION_SET,
|
|
1506
1519
|
selections: types
|
|
1507
1520
|
.filter(function (t) {
|
|
1508
|
-
return !hasCircularRef(tslib.
|
|
1521
|
+
return !hasCircularRef(tslib.__spreadArray(tslib.__spreadArray([], tslib.__read(ancestors)), [t]), {
|
|
1509
1522
|
depth: circularReferenceDepth,
|
|
1510
1523
|
});
|
|
1511
1524
|
})
|
|
@@ -1560,7 +1573,7 @@ function resolveSelectionSet(_a) {
|
|
|
1560
1573
|
kind: graphql.Kind.SELECTION_SET,
|
|
1561
1574
|
selections: Object.keys(fields_1)
|
|
1562
1575
|
.filter(function (fieldName) {
|
|
1563
|
-
return !hasCircularRef(tslib.
|
|
1576
|
+
return !hasCircularRef(tslib.__spreadArray(tslib.__spreadArray([], tslib.__read(ancestors)), [graphql.getNamedType(fields_1[fieldName].type)]), {
|
|
1564
1577
|
depth: circularReferenceDepth,
|
|
1565
1578
|
});
|
|
1566
1579
|
})
|
|
@@ -1571,7 +1584,7 @@ function resolveSelectionSet(_a) {
|
|
|
1571
1584
|
type: type,
|
|
1572
1585
|
field: fields_1[fieldName],
|
|
1573
1586
|
models: models,
|
|
1574
|
-
path: tslib.
|
|
1587
|
+
path: tslib.__spreadArray(tslib.__spreadArray([], tslib.__read(path)), [fieldName]),
|
|
1575
1588
|
ancestors: ancestors,
|
|
1576
1589
|
ignore: ignore,
|
|
1577
1590
|
depthLimit: depthLimit,
|
|
@@ -1634,7 +1647,7 @@ function resolveVariable(arg, name) {
|
|
|
1634
1647
|
};
|
|
1635
1648
|
}
|
|
1636
1649
|
function getArgumentName(name, path) {
|
|
1637
|
-
return camelCase.camelCase(tslib.
|
|
1650
|
+
return camelCase.camelCase(tslib.__spreadArray(tslib.__spreadArray([], tslib.__read(path)), [name]).join('_'));
|
|
1638
1651
|
}
|
|
1639
1652
|
function resolveField(_a) {
|
|
1640
1653
|
var type = _a.type, field = _a.field, models = _a.models, firstCall = _a.firstCall, path = _a.path, ancestors = _a.ancestors, ignore = _a.ignore, depthLimit = _a.depthLimit, circularReferenceDepth = _a.circularReferenceDepth, schema = _a.schema, depth = _a.depth, argNames = _a.argNames, selectedFields = _a.selectedFields;
|
|
@@ -1674,7 +1687,7 @@ function resolveField(_a) {
|
|
|
1674
1687
|
if (removeField) {
|
|
1675
1688
|
return null;
|
|
1676
1689
|
}
|
|
1677
|
-
var fieldPath = tslib.
|
|
1690
|
+
var fieldPath = tslib.__spreadArray(tslib.__spreadArray([], tslib.__read(path)), [field.name]);
|
|
1678
1691
|
var fieldPathStr = fieldPath.join('.');
|
|
1679
1692
|
var fieldName = field.name;
|
|
1680
1693
|
if (fieldTypeMap.has(fieldPathStr) && fieldTypeMap.get(fieldPathStr) !== field.type.toString()) {
|
|
@@ -1691,7 +1704,7 @@ function resolveField(_a) {
|
|
|
1691
1704
|
models: models,
|
|
1692
1705
|
firstCall: firstCall,
|
|
1693
1706
|
path: fieldPath,
|
|
1694
|
-
ancestors: tslib.
|
|
1707
|
+
ancestors: tslib.__spreadArray(tslib.__spreadArray([], tslib.__read(ancestors)), [type]),
|
|
1695
1708
|
ignore: ignore,
|
|
1696
1709
|
depthLimit: depthLimit,
|
|
1697
1710
|
circularReferenceDepth: circularReferenceDepth,
|
|
@@ -2285,7 +2298,7 @@ function getTypeSpecifiers(schema, typeName) {
|
|
|
2285
2298
|
function getTypeMapper(schema, schemaMapper, typeName) {
|
|
2286
2299
|
var specifiers = getTypeSpecifiers(schema, typeName);
|
|
2287
2300
|
var typeMapper;
|
|
2288
|
-
var stack = tslib.
|
|
2301
|
+
var stack = tslib.__spreadArray([], tslib.__read(specifiers));
|
|
2289
2302
|
while (!typeMapper && stack.length > 0) {
|
|
2290
2303
|
var next = stack.pop();
|
|
2291
2304
|
typeMapper = schemaMapper[next];
|
|
@@ -2321,7 +2334,7 @@ function getFieldSpecifiers(schema, typeName) {
|
|
|
2321
2334
|
function getFieldMapper(schema, schemaMapper, typeName) {
|
|
2322
2335
|
var specifiers = getFieldSpecifiers(schema, typeName);
|
|
2323
2336
|
var fieldMapper;
|
|
2324
|
-
var stack = tslib.
|
|
2337
|
+
var stack = tslib.__spreadArray([], tslib.__read(specifiers));
|
|
2325
2338
|
while (!fieldMapper && stack.length > 0) {
|
|
2326
2339
|
var next = stack.pop();
|
|
2327
2340
|
fieldMapper = schemaMapper[next];
|
|
@@ -2514,7 +2527,7 @@ function cloneType(type) {
|
|
|
2514
2527
|
}
|
|
2515
2528
|
else if (graphql.isInterfaceType(type)) {
|
|
2516
2529
|
var config = type.toConfig();
|
|
2517
|
-
var newConfig = tslib.__assign(tslib.__assign({}, config), { interfaces: tslib.
|
|
2530
|
+
var newConfig = tslib.__assign(tslib.__assign({}, config), { interfaces: tslib.__spreadArray([], tslib.__read(((typeof config.interfaces === 'function' ? config.interfaces() : config.interfaces) || []))) });
|
|
2518
2531
|
return new graphql.GraphQLInterfaceType(newConfig);
|
|
2519
2532
|
}
|
|
2520
2533
|
else if (graphql.isUnionType(type)) {
|
|
@@ -2682,10 +2695,10 @@ function healTypes(originalTypeMap, directives) {
|
|
|
2682
2695
|
function healInterfaces(type) {
|
|
2683
2696
|
if ('getInterfaces' in type) {
|
|
2684
2697
|
var interfaces = type.getInterfaces();
|
|
2685
|
-
interfaces.push.apply(interfaces, tslib.
|
|
2698
|
+
interfaces.push.apply(interfaces, tslib.__spreadArray([], tslib.__read(interfaces
|
|
2686
2699
|
.splice(0)
|
|
2687
2700
|
.map(function (iface) { return healType(iface); })
|
|
2688
|
-
.filter(Boolean)));
|
|
2701
|
+
.filter(Boolean))));
|
|
2689
2702
|
}
|
|
2690
2703
|
}
|
|
2691
2704
|
function healInputFields(type) {
|
|
@@ -2710,10 +2723,10 @@ function healTypes(originalTypeMap, directives) {
|
|
|
2710
2723
|
}
|
|
2711
2724
|
function healUnderlyingTypes(type) {
|
|
2712
2725
|
var types = type.getTypes();
|
|
2713
|
-
types.push.apply(types, tslib.
|
|
2726
|
+
types.push.apply(types, tslib.__spreadArray([], tslib.__read(types
|
|
2714
2727
|
.splice(0)
|
|
2715
2728
|
.map(function (t) { return healType(t); })
|
|
2716
|
-
.filter(Boolean)));
|
|
2729
|
+
.filter(Boolean))));
|
|
2717
2730
|
}
|
|
2718
2731
|
function healType(type) {
|
|
2719
2732
|
// Unwrap the two known wrapper types
|
|
@@ -2846,7 +2859,7 @@ visitorOrVisitorSelector) {
|
|
|
2846
2859
|
visitors.every(function (visitorOrVisitorDef) {
|
|
2847
2860
|
var newType;
|
|
2848
2861
|
if (isSchemaVisitor(visitorOrVisitorDef)) {
|
|
2849
|
-
newType = visitorOrVisitorDef[methodName].apply(visitorOrVisitorDef, tslib.
|
|
2862
|
+
newType = visitorOrVisitorDef[methodName].apply(visitorOrVisitorDef, tslib.__spreadArray([finalType], tslib.__read(args)));
|
|
2850
2863
|
}
|
|
2851
2864
|
else if (graphql.isNamedType(finalType) &&
|
|
2852
2865
|
(methodName === 'visitScalar' ||
|
|
@@ -3082,7 +3095,7 @@ function getTypeSpecifiers$1(type, schema) {
|
|
|
3082
3095
|
}
|
|
3083
3096
|
function getVisitor(visitorDef, specifiers) {
|
|
3084
3097
|
var typeVisitor;
|
|
3085
|
-
var stack = tslib.
|
|
3098
|
+
var stack = tslib.__spreadArray([], tslib.__read(specifiers));
|
|
3086
3099
|
while (!typeVisitor && stack.length > 0) {
|
|
3087
3100
|
var next = stack.pop();
|
|
3088
3101
|
typeVisitor = visitorDef[next];
|
|
@@ -3464,7 +3477,8 @@ function pruneSchema(schema, options) {
|
|
|
3464
3477
|
var type = schema.getType(typeName);
|
|
3465
3478
|
if ('getInterfaces' in type) {
|
|
3466
3479
|
type.getInterfaces().forEach(function (iface) {
|
|
3467
|
-
|
|
3480
|
+
var implementations = getImplementations(pruningContext, iface);
|
|
3481
|
+
if (implementations == null) {
|
|
3468
3482
|
pruningContext.implementations[iface.name] = Object.create(null);
|
|
3469
3483
|
}
|
|
3470
3484
|
pruningContext.implementations[iface.name][type.name] = true;
|
|
@@ -3474,6 +3488,10 @@ function pruneSchema(schema, options) {
|
|
|
3474
3488
|
visitTypes(pruningContext, schema);
|
|
3475
3489
|
return mapSchema(schema, (_a = {},
|
|
3476
3490
|
_a[exports.MapperKind.TYPE] = function (type) {
|
|
3491
|
+
// If we should NOT prune the type, return it immediately as unmodified
|
|
3492
|
+
if (options.skipPruning && options.skipPruning(type)) {
|
|
3493
|
+
return type;
|
|
3494
|
+
}
|
|
3477
3495
|
if (graphql.isObjectType(type) || graphql.isInputObjectType(type)) {
|
|
3478
3496
|
if ((!Object.keys(type.getFields()).length && !options.skipEmptyCompositeTypePruning) ||
|
|
3479
3497
|
(pruningContext.unusedTypes[type.name] && !options.skipUnusedTypesPruning)) {
|
|
@@ -3487,9 +3505,9 @@ function pruneSchema(schema, options) {
|
|
|
3487
3505
|
}
|
|
3488
3506
|
}
|
|
3489
3507
|
else if (graphql.isInterfaceType(type)) {
|
|
3508
|
+
var implementations = getImplementations(pruningContext, type);
|
|
3490
3509
|
if ((!Object.keys(type.getFields()).length && !options.skipEmptyCompositeTypePruning) ||
|
|
3491
|
-
(!Object.keys(
|
|
3492
|
-
!options.skipUnimplementedInterfacesPruning) ||
|
|
3510
|
+
(implementations && !Object.keys(implementations).length && !options.skipUnimplementedInterfacesPruning) ||
|
|
3493
3511
|
(pruningContext.unusedTypes[type.name] && !options.skipUnusedTypesPruning)) {
|
|
3494
3512
|
return null;
|
|
3495
3513
|
}
|
|
@@ -3521,9 +3539,12 @@ function visitOutputType(visitedTypes, pruningContext, type) {
|
|
|
3521
3539
|
});
|
|
3522
3540
|
});
|
|
3523
3541
|
if (graphql.isInterfaceType(type)) {
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3542
|
+
var implementations = getImplementations(pruningContext, type);
|
|
3543
|
+
if (implementations) {
|
|
3544
|
+
Object.keys(implementations).forEach(function (typeName) {
|
|
3545
|
+
visitOutputType(visitedTypes, pruningContext, pruningContext.schema.getType(typeName));
|
|
3546
|
+
});
|
|
3547
|
+
}
|
|
3527
3548
|
}
|
|
3528
3549
|
if ('getInterfaces' in type) {
|
|
3529
3550
|
type.getInterfaces().forEach(function (type) {
|
|
@@ -3536,6 +3557,12 @@ function visitOutputType(visitedTypes, pruningContext, type) {
|
|
|
3536
3557
|
types.forEach(function (type) { return visitOutputType(visitedTypes, pruningContext, type); });
|
|
3537
3558
|
}
|
|
3538
3559
|
}
|
|
3560
|
+
/**
|
|
3561
|
+
* Get the implementations of an interface. May return undefined.
|
|
3562
|
+
*/
|
|
3563
|
+
function getImplementations(pruningContext, type) {
|
|
3564
|
+
return pruningContext.implementations[type.name];
|
|
3565
|
+
}
|
|
3539
3566
|
function visitInputType(visitedTypes, pruningContext, type) {
|
|
3540
3567
|
if (visitedTypes[type.name]) {
|
|
3541
3568
|
return;
|