graphql 14.1.1 → 14.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/error/GraphQLError.js +12 -10
- package/error/GraphQLError.js.flow +11 -6
- package/error/GraphQLError.mjs +20 -3
- package/error/formatError.js +2 -2
- package/error/formatError.js.flow +3 -3
- package/error/formatError.mjs +2 -2
- package/error/index.js +1 -1
- package/error/index.js.flow +5 -2
- package/error/index.mjs +2 -2
- package/error/locatedError.js +2 -2
- package/error/locatedError.js.flow +2 -2
- package/error/locatedError.mjs +2 -2
- package/error/printError.js +2 -2
- package/error/printError.js.flow +4 -5
- package/error/printError.mjs +2 -2
- package/error/syntaxError.js +2 -2
- package/error/syntaxError.js.flow +2 -2
- package/error/syntaxError.mjs +2 -2
- package/execution/execute.js +52 -37
- package/execution/execute.js.flow +66 -51
- package/execution/execute.mjs +50 -38
- package/execution/index.js +7 -1
- package/execution/index.js.flow +9 -4
- package/execution/index.mjs +3 -3
- package/execution/values.js +11 -11
- package/execution/values.js.flow +23 -19
- package/execution/values.mjs +11 -11
- package/graphql.js +13 -9
- package/graphql.js.flow +28 -10
- package/graphql.mjs +10 -9
- package/index.js +83 -53
- package/index.js.flow +60 -47
- package/index.mjs +26 -23
- package/jsutils/ObjMap.js +1 -1
- package/jsutils/ObjMap.js.flow +1 -1
- package/jsutils/ObjMap.mjs +1 -0
- package/jsutils/PromiseOrValue.js +1 -0
- package/jsutils/{MaybePromise.js.flow → PromiseOrValue.js.flow} +2 -2
- package/jsutils/PromiseOrValue.mjs +1 -0
- package/jsutils/dedent.js +2 -2
- package/jsutils/dedent.js.flow +1 -1
- package/jsutils/dedent.mjs +2 -2
- package/jsutils/defineToJSON.js +2 -2
- package/jsutils/defineToJSON.js.flow +1 -1
- package/jsutils/defineToJSON.mjs +2 -2
- package/jsutils/defineToStringTag.js +2 -2
- package/jsutils/defineToStringTag.js.flow +1 -1
- package/jsutils/defineToStringTag.mjs +2 -2
- package/jsutils/inspect.js +94 -19
- package/jsutils/inspect.js.flow +98 -20
- package/jsutils/inspect.mjs +94 -20
- package/jsutils/instanceOf.js +2 -2
- package/jsutils/instanceOf.js.flow +1 -1
- package/jsutils/instanceOf.mjs +2 -2
- package/jsutils/invariant.js +5 -3
- package/jsutils/invariant.js.flow +3 -2
- package/jsutils/invariant.mjs +5 -3
- package/jsutils/isInvalid.js +2 -2
- package/jsutils/isInvalid.js.flow +1 -1
- package/jsutils/isInvalid.mjs +2 -2
- package/jsutils/isNullish.js +2 -2
- package/jsutils/isNullish.js.flow +1 -1
- package/jsutils/isNullish.mjs +2 -2
- package/jsutils/isPromise.js +2 -2
- package/jsutils/isPromise.js.flow +1 -1
- package/jsutils/isPromise.mjs +2 -2
- package/jsutils/keyMap.js +4 -3
- package/jsutils/keyMap.js.flow +6 -6
- package/jsutils/keyMap.mjs +4 -3
- package/jsutils/keyValMap.js +4 -3
- package/jsutils/keyValMap.js.flow +6 -6
- package/jsutils/keyValMap.mjs +4 -3
- package/jsutils/mapValue.js +2 -2
- package/jsutils/mapValue.js.flow +2 -2
- package/jsutils/mapValue.mjs +2 -2
- package/jsutils/memoize3.js +3 -3
- package/jsutils/memoize3.js.flow +2 -2
- package/jsutils/memoize3.mjs +3 -3
- package/jsutils/nodejsCustomInspectSymbol.js +2 -2
- package/jsutils/nodejsCustomInspectSymbol.js.flow +1 -1
- package/jsutils/nodejsCustomInspectSymbol.mjs +2 -2
- package/jsutils/orList.js +2 -2
- package/jsutils/orList.js.flow +1 -1
- package/jsutils/orList.mjs +2 -2
- package/jsutils/promiseForObject.js +2 -2
- package/jsutils/promiseForObject.js.flow +2 -2
- package/jsutils/promiseForObject.mjs +2 -2
- package/jsutils/promiseReduce.js +2 -2
- package/jsutils/promiseReduce.js.flow +5 -5
- package/jsutils/promiseReduce.mjs +2 -2
- package/jsutils/quotedOrList.js +2 -2
- package/jsutils/quotedOrList.js.flow +1 -1
- package/jsutils/quotedOrList.mjs +2 -2
- package/jsutils/suggestionList.js +2 -2
- package/jsutils/suggestionList.js.flow +1 -1
- package/jsutils/suggestionList.mjs +2 -2
- package/language/ast.js +1 -1
- package/language/ast.js.flow +3 -3
- package/language/ast.mjs +1 -0
- package/language/blockString.js +114 -0
- package/language/blockString.js.flow +102 -0
- package/language/blockString.mjs +104 -0
- package/language/directiveLocation.js +2 -2
- package/language/directiveLocation.js.flow +1 -1
- package/language/directiveLocation.mjs +2 -2
- package/language/index.js +9 -9
- package/language/index.js.flow +10 -5
- package/language/index.mjs +3 -3
- package/language/kinds.js +2 -2
- package/language/kinds.js.flow +1 -1
- package/language/kinds.mjs +2 -2
- package/language/lexer.js +52 -44
- package/language/lexer.js.flow +65 -54
- package/language/lexer.mjs +49 -43
- package/language/location.js +2 -2
- package/language/location.js.flow +2 -2
- package/language/location.mjs +2 -2
- package/language/parser.js +75 -67
- package/language/parser.js.flow +138 -127
- package/language/parser.mjs +76 -68
- package/language/predicates.js +2 -2
- package/language/predicates.js.flow +2 -2
- package/language/predicates.mjs +2 -2
- package/language/printer.js +6 -14
- package/language/printer.js.flow +8 -17
- package/language/printer.mjs +5 -14
- package/language/source.js +2 -2
- package/language/source.js.flow +1 -1
- package/language/source.mjs +2 -2
- package/language/visitor.js +4 -6
- package/language/visitor.js.flow +3 -3
- package/language/visitor.mjs +4 -6
- package/package.json +1 -1
- package/polyfills/find.js +2 -2
- package/polyfills/find.js.flow +1 -1
- package/polyfills/find.mjs +2 -2
- package/polyfills/flatMap.js +38 -0
- package/polyfills/flatMap.js.flow +34 -0
- package/polyfills/flatMap.mjs +30 -0
- package/polyfills/isFinite.js +2 -2
- package/polyfills/isFinite.js.flow +1 -1
- package/polyfills/isFinite.mjs +2 -2
- package/polyfills/isInteger.js +2 -2
- package/polyfills/isInteger.js.flow +1 -1
- package/polyfills/isInteger.mjs +2 -2
- package/polyfills/objectEntries.js +2 -2
- package/polyfills/objectEntries.js.flow +2 -2
- package/polyfills/objectEntries.mjs +2 -2
- package/polyfills/objectValues.js +2 -2
- package/polyfills/objectValues.js.flow +2 -2
- package/polyfills/objectValues.mjs +2 -2
- package/subscription/asyncIteratorReject.js +1 -1
- package/subscription/asyncIteratorReject.js.flow +1 -1
- package/subscription/asyncIteratorReject.mjs +2 -2
- package/subscription/index.js +1 -1
- package/subscription/index.js.flow +1 -1
- package/subscription/index.mjs +2 -2
- package/subscription/mapAsyncIterator.js +1 -1
- package/subscription/mapAsyncIterator.js.flow +5 -5
- package/subscription/mapAsyncIterator.mjs +2 -2
- package/subscription/subscribe.js +2 -2
- package/subscription/subscribe.js.flow +6 -6
- package/subscription/subscribe.mjs +2 -2
- package/type/definition.js +138 -22
- package/type/definition.js.flow +184 -36
- package/type/definition.mjs +136 -23
- package/type/directives.js +14 -3
- package/type/directives.js.flow +24 -11
- package/type/directives.mjs +16 -5
- package/type/index.js +7 -7
- package/type/index.js.flow +8 -4
- package/type/index.mjs +10 -6
- package/type/introspection.js +14 -9
- package/type/introspection.js.flow +12 -18
- package/type/introspection.mjs +14 -9
- package/type/scalars.js +5 -4
- package/type/scalars.js.flow +4 -10
- package/type/scalars.mjs +7 -6
- package/type/schema.js +55 -3
- package/type/schema.js.flow +73 -17
- package/type/schema.mjs +56 -4
- package/type/validate.js +19 -47
- package/type/validate.js.flow +17 -29
- package/type/validate.mjs +18 -47
- package/utilities/TypeInfo.js +93 -73
- package/utilities/TypeInfo.js.flow +30 -23
- package/utilities/TypeInfo.mjs +93 -73
- package/utilities/assertValidName.js +2 -2
- package/utilities/assertValidName.js.flow +2 -2
- package/utilities/assertValidName.mjs +2 -2
- package/utilities/astFromValue.js +5 -4
- package/utilities/astFromValue.js.flow +8 -7
- package/utilities/astFromValue.mjs +7 -6
- package/utilities/buildASTSchema.js +63 -62
- package/utilities/buildASTSchema.js.flow +92 -108
- package/utilities/buildASTSchema.mjs +61 -62
- package/utilities/buildClientSchema.js +38 -45
- package/utilities/buildClientSchema.js.flow +66 -79
- package/utilities/buildClientSchema.mjs +37 -44
- package/utilities/coerceValue.js +6 -7
- package/utilities/coerceValue.js.flow +5 -4
- package/utilities/coerceValue.mjs +7 -8
- package/utilities/concatAST.js +9 -13
- package/utilities/concatAST.js.flow +4 -10
- package/utilities/concatAST.mjs +6 -13
- package/utilities/extendSchema.js +219 -511
- package/utilities/extendSchema.js.flow +195 -304
- package/utilities/extendSchema.mjs +218 -512
- package/utilities/findBreakingChanges.js +54 -95
- package/utilities/findBreakingChanges.js.flow +49 -47
- package/utilities/findBreakingChanges.mjs +80 -95
- package/utilities/findDeprecatedUsages.js +4 -4
- package/utilities/findDeprecatedUsages.js.flow +5 -5
- package/utilities/findDeprecatedUsages.mjs +4 -4
- package/utilities/getOperationAST.js +2 -2
- package/utilities/getOperationAST.js.flow +5 -2
- package/utilities/getOperationAST.mjs +2 -2
- package/utilities/getOperationRootType.js +24 -24
- package/utilities/getOperationRootType.js.flow +40 -35
- package/utilities/getOperationRootType.mjs +24 -24
- package/utilities/index.js +9 -1
- package/utilities/index.js.flow +13 -6
- package/utilities/index.mjs +13 -8
- package/utilities/introspectionFromSchema.js +6 -4
- package/utilities/introspectionFromSchema.js.flow +8 -7
- package/utilities/introspectionFromSchema.mjs +6 -5
- package/utilities/introspectionQuery.js +2 -2
- package/utilities/introspectionQuery.js.flow +2 -2
- package/utilities/introspectionQuery.mjs +2 -2
- package/utilities/isValidJSValue.js +4 -2
- package/utilities/isValidJSValue.js.flow +3 -2
- package/utilities/isValidJSValue.mjs +4 -2
- package/utilities/isValidLiteralValue.js +2 -2
- package/utilities/isValidLiteralValue.js.flow +4 -4
- package/utilities/isValidLiteralValue.mjs +2 -2
- package/utilities/lexicographicSortSchema.js +84 -123
- package/utilities/lexicographicSortSchema.js.flow +68 -96
- package/utilities/lexicographicSortSchema.mjs +84 -123
- package/utilities/schemaPrinter.js +47 -73
- package/utilities/schemaPrinter.js.flow +69 -120
- package/utilities/schemaPrinter.mjs +45 -72
- package/utilities/separateOperations.js +8 -12
- package/utilities/separateOperations.js.flow +6 -3
- package/utilities/separateOperations.mjs +8 -12
- package/utilities/stripIgnoredCharacters.js +140 -0
- package/utilities/stripIgnoredCharacters.js.flow +129 -0
- package/utilities/stripIgnoredCharacters.mjs +127 -0
- package/utilities/typeComparators.js +2 -2
- package/utilities/typeComparators.js.flow +4 -3
- package/utilities/typeComparators.mjs +2 -2
- package/utilities/typeFromAST.js +9 -4
- package/utilities/typeFromAST.js.flow +15 -9
- package/utilities/typeFromAST.mjs +6 -4
- package/utilities/valueFromAST.js +7 -4
- package/utilities/valueFromAST.js.flow +7 -5
- package/utilities/valueFromAST.mjs +6 -4
- package/utilities/valueFromASTUntyped.js +11 -6
- package/utilities/valueFromASTUntyped.js.flow +9 -5
- package/utilities/valueFromASTUntyped.mjs +10 -6
- package/validation/ValidationContext.js +1 -1
- package/validation/ValidationContext.js.flow +19 -20
- package/validation/ValidationContext.mjs +2 -2
- package/validation/index.js +1 -1
- package/validation/index.js.flow +2 -1
- package/validation/index.mjs +3 -2
- package/validation/rules/ExecutableDefinitions.js +3 -3
- package/validation/rules/ExecutableDefinitions.js.flow +4 -4
- package/validation/rules/ExecutableDefinitions.mjs +3 -3
- package/validation/rules/FieldsOnCorrectType.js +3 -3
- package/validation/rules/FieldsOnCorrectType.js.flow +7 -7
- package/validation/rules/FieldsOnCorrectType.mjs +3 -3
- package/validation/rules/FragmentsOnCompositeTypes.js +4 -4
- package/validation/rules/FragmentsOnCompositeTypes.js.flow +5 -5
- package/validation/rules/FragmentsOnCompositeTypes.mjs +4 -4
- package/validation/rules/KnownArgumentNames.js +1 -1
- package/validation/rules/KnownArgumentNames.js.flow +5 -5
- package/validation/rules/KnownArgumentNames.mjs +2 -2
- package/validation/rules/KnownDirectives.js +8 -6
- package/validation/rules/KnownDirectives.js.flow +11 -9
- package/validation/rules/KnownDirectives.mjs +8 -6
- package/validation/rules/KnownFragmentNames.js +3 -3
- package/validation/rules/KnownFragmentNames.js.flow +4 -4
- package/validation/rules/KnownFragmentNames.mjs +3 -3
- package/validation/rules/KnownTypeNames.js +2 -2
- package/validation/rules/KnownTypeNames.js.flow +6 -6
- package/validation/rules/KnownTypeNames.mjs +2 -2
- package/validation/rules/LoneAnonymousOperation.js +3 -3
- package/validation/rules/LoneAnonymousOperation.js.flow +4 -4
- package/validation/rules/LoneAnonymousOperation.mjs +3 -3
- package/validation/rules/LoneSchemaDefinition.js +2 -2
- package/validation/rules/LoneSchemaDefinition.js.flow +3 -3
- package/validation/rules/LoneSchemaDefinition.mjs +2 -2
- package/validation/rules/NoFragmentCycles.js +2 -2
- package/validation/rules/NoFragmentCycles.js.flow +4 -4
- package/validation/rules/NoFragmentCycles.mjs +2 -2
- package/validation/rules/NoUndefinedVariables.js +2 -2
- package/validation/rules/NoUndefinedVariables.js.flow +3 -3
- package/validation/rules/NoUndefinedVariables.mjs +2 -2
- package/validation/rules/NoUnusedFragments.js +7 -7
- package/validation/rules/NoUnusedFragments.js.flow +4 -4
- package/validation/rules/NoUnusedFragments.mjs +7 -7
- package/validation/rules/NoUnusedVariables.js +5 -5
- package/validation/rules/NoUnusedVariables.js.flow +6 -5
- package/validation/rules/NoUnusedVariables.mjs +5 -5
- package/validation/rules/OverlappingFieldsCanBeMerged.js +26 -23
- package/validation/rules/OverlappingFieldsCanBeMerged.js.flow +17 -17
- package/validation/rules/OverlappingFieldsCanBeMerged.mjs +26 -23
- package/validation/rules/PossibleFragmentSpreads.js +4 -4
- package/validation/rules/PossibleFragmentSpreads.js.flow +5 -5
- package/validation/rules/PossibleFragmentSpreads.mjs +4 -4
- package/validation/rules/PossibleTypeExtensions.js +3 -3
- package/validation/rules/PossibleTypeExtensions.js.flow +5 -5
- package/validation/rules/PossibleTypeExtensions.mjs +4 -4
- package/validation/rules/ProvidedRequiredArguments.js +6 -8
- package/validation/rules/ProvidedRequiredArguments.js.flow +8 -8
- package/validation/rules/ProvidedRequiredArguments.mjs +7 -9
- package/validation/rules/ScalarLeafs.js +4 -4
- package/validation/rules/ScalarLeafs.js.flow +6 -6
- package/validation/rules/ScalarLeafs.mjs +4 -4
- package/validation/rules/SingleFieldSubscriptions.js +2 -2
- package/validation/rules/SingleFieldSubscriptions.js.flow +4 -4
- package/validation/rules/SingleFieldSubscriptions.mjs +2 -2
- package/validation/rules/UniqueArgumentNames.js +2 -2
- package/validation/rules/UniqueArgumentNames.js.flow +3 -3
- package/validation/rules/UniqueArgumentNames.mjs +2 -2
- package/validation/rules/UniqueDirectiveNames.js +2 -2
- package/validation/rules/UniqueDirectiveNames.js.flow +3 -3
- package/validation/rules/UniqueDirectiveNames.mjs +2 -2
- package/validation/rules/UniqueDirectivesPerLocation.js +3 -2
- package/validation/rules/UniqueDirectivesPerLocation.js.flow +4 -4
- package/validation/rules/UniqueDirectivesPerLocation.mjs +3 -2
- package/validation/rules/UniqueEnumValueNames.js +4 -8
- package/validation/rules/UniqueEnumValueNames.js.flow +6 -8
- package/validation/rules/UniqueEnumValueNames.mjs +4 -8
- package/validation/rules/UniqueFieldDefinitionNames.js +4 -8
- package/validation/rules/UniqueFieldDefinitionNames.js.flow +6 -8
- package/validation/rules/UniqueFieldDefinitionNames.mjs +4 -8
- package/validation/rules/UniqueFragmentNames.js +2 -2
- package/validation/rules/UniqueFragmentNames.js.flow +3 -3
- package/validation/rules/UniqueFragmentNames.mjs +2 -2
- package/validation/rules/UniqueInputFieldNames.js +2 -4
- package/validation/rules/UniqueInputFieldNames.js.flow +3 -4
- package/validation/rules/UniqueInputFieldNames.mjs +2 -4
- package/validation/rules/UniqueOperationNames.js +2 -2
- package/validation/rules/UniqueOperationNames.js.flow +3 -3
- package/validation/rules/UniqueOperationNames.mjs +2 -2
- package/validation/rules/UniqueOperationTypes.js +2 -2
- package/validation/rules/UniqueOperationTypes.js.flow +3 -3
- package/validation/rules/UniqueOperationTypes.mjs +2 -2
- package/validation/rules/UniqueTypeNames.js +2 -2
- package/validation/rules/UniqueTypeNames.js.flow +4 -4
- package/validation/rules/UniqueTypeNames.mjs +2 -2
- package/validation/rules/UniqueVariableNames.js +2 -2
- package/validation/rules/UniqueVariableNames.js.flow +4 -4
- package/validation/rules/UniqueVariableNames.mjs +2 -2
- package/validation/rules/ValuesOfCorrectType.js +2 -2
- package/validation/rules/ValuesOfCorrectType.js.flow +5 -5
- package/validation/rules/ValuesOfCorrectType.mjs +2 -2
- package/validation/rules/VariablesAreInputTypes.js +3 -3
- package/validation/rules/VariablesAreInputTypes.js.flow +5 -5
- package/validation/rules/VariablesAreInputTypes.mjs +3 -3
- package/validation/rules/VariablesInAllowedPosition.js +3 -3
- package/validation/rules/VariablesInAllowedPosition.js.flow +7 -8
- package/validation/rules/VariablesInAllowedPosition.mjs +3 -3
- package/validation/specifiedRules.js +2 -2
- package/validation/specifiedRules.js.flow +13 -6
- package/validation/specifiedRules.mjs +7 -7
- package/validation/validate.js +2 -2
- package/validation/validate.js.flow +10 -6
- package/validation/validate.mjs +2 -2
- package/jsutils/MaybePromise.js +0 -1
- package/jsutils/MaybePromise.mjs +0 -0
- package/language/blockStringValue.js +0 -73
- package/language/blockStringValue.js.flow +0 -64
- package/language/blockStringValue.mjs +0 -66
|
@@ -7,6 +7,8 @@ exports.lexicographicSortSchema = lexicographicSortSchema;
|
|
|
7
7
|
|
|
8
8
|
var _objectValues = _interopRequireDefault(require("../polyfills/objectValues"));
|
|
9
9
|
|
|
10
|
+
var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
|
|
11
|
+
|
|
10
12
|
var _keyValMap = _interopRequireDefault(require("../jsutils/keyValMap"));
|
|
11
13
|
|
|
12
14
|
var _schema = require("../type/schema");
|
|
@@ -15,8 +17,6 @@ var _directives = require("../type/directives");
|
|
|
15
17
|
|
|
16
18
|
var _definition = require("../type/definition");
|
|
17
19
|
|
|
18
|
-
var _scalars = require("../type/scalars");
|
|
19
|
-
|
|
20
20
|
var _introspection = require("../type/introspection");
|
|
21
21
|
|
|
22
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -29,163 +29,124 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
29
29
|
* Sort GraphQLSchema.
|
|
30
30
|
*/
|
|
31
31
|
function lexicographicSortSchema(schema) {
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
32
|
+
var schemaConfig = schema.toConfig();
|
|
33
|
+
var typeMap = (0, _keyValMap.default)(sortByName(schemaConfig.types), function (type) {
|
|
34
|
+
return type.name;
|
|
35
|
+
}, sortNamedType);
|
|
36
|
+
return new _schema.GraphQLSchema(_objectSpread({}, schemaConfig, {
|
|
37
|
+
types: (0, _objectValues.default)(typeMap),
|
|
38
|
+
directives: sortByName(schemaConfig.directives).map(sortDirective),
|
|
39
|
+
query: replaceMaybeType(schemaConfig.query),
|
|
40
|
+
mutation: replaceMaybeType(schemaConfig.mutation),
|
|
41
|
+
subscription: replaceMaybeType(schemaConfig.subscription)
|
|
42
|
+
}));
|
|
43
|
+
|
|
44
|
+
function replaceType(type) {
|
|
45
|
+
if ((0, _definition.isListType)(type)) {
|
|
46
|
+
return new _definition.GraphQLList(replaceType(type.ofType));
|
|
47
|
+
} else if ((0, _definition.isNonNullType)(type)) {
|
|
48
|
+
return new _definition.GraphQLNonNull(replaceType(type.ofType));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return replaceNamedType(type);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function replaceNamedType(type) {
|
|
55
|
+
return typeMap[type.name];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function replaceMaybeType(maybeType) {
|
|
59
|
+
return maybeType && replaceNamedType(maybeType);
|
|
60
|
+
}
|
|
46
61
|
|
|
47
62
|
function sortDirective(directive) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
locations: sortBy(directive.locations, function (x) {
|
|
63
|
+
var config = directive.toConfig();
|
|
64
|
+
return new _directives.GraphQLDirective(_objectSpread({}, config, {
|
|
65
|
+
locations: sortBy(config.locations, function (x) {
|
|
52
66
|
return x;
|
|
53
67
|
}),
|
|
54
|
-
args: sortArgs(
|
|
55
|
-
|
|
56
|
-
});
|
|
68
|
+
args: sortArgs(config.args)
|
|
69
|
+
}));
|
|
57
70
|
}
|
|
58
71
|
|
|
59
72
|
function sortArgs(args) {
|
|
60
|
-
return (
|
|
61
|
-
return arg.name;
|
|
62
|
-
}, function (arg) {
|
|
73
|
+
return sortObjMap(args, function (arg) {
|
|
63
74
|
return _objectSpread({}, arg, {
|
|
64
|
-
type:
|
|
75
|
+
type: replaceType(arg.type)
|
|
65
76
|
});
|
|
66
77
|
});
|
|
67
78
|
}
|
|
68
79
|
|
|
69
80
|
function sortFields(fieldsMap) {
|
|
70
81
|
return sortObjMap(fieldsMap, function (field) {
|
|
71
|
-
return {
|
|
72
|
-
type:
|
|
73
|
-
args: sortArgs(field.args)
|
|
74
|
-
|
|
75
|
-
subscribe: field.subscribe,
|
|
76
|
-
deprecationReason: field.deprecationReason,
|
|
77
|
-
description: field.description,
|
|
78
|
-
astNode: field.astNode
|
|
79
|
-
};
|
|
82
|
+
return _objectSpread({}, field, {
|
|
83
|
+
type: replaceType(field.type),
|
|
84
|
+
args: sortArgs(field.args)
|
|
85
|
+
});
|
|
80
86
|
});
|
|
81
87
|
}
|
|
82
88
|
|
|
83
89
|
function sortInputFields(fieldsMap) {
|
|
84
90
|
return sortObjMap(fieldsMap, function (field) {
|
|
85
|
-
return {
|
|
86
|
-
type:
|
|
87
|
-
|
|
88
|
-
description: field.description,
|
|
89
|
-
astNode: field.astNode
|
|
90
|
-
};
|
|
91
|
+
return _objectSpread({}, field, {
|
|
92
|
+
type: replaceType(field.type)
|
|
93
|
+
});
|
|
91
94
|
});
|
|
92
95
|
}
|
|
93
96
|
|
|
94
|
-
function sortType(type) {
|
|
95
|
-
if ((0, _definition.isListType)(type)) {
|
|
96
|
-
return new _definition.GraphQLList(sortType(type.ofType));
|
|
97
|
-
} else if ((0, _definition.isNonNullType)(type)) {
|
|
98
|
-
return new _definition.GraphQLNonNull(sortType(type.ofType));
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return sortNamedType(type);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
97
|
function sortTypes(arr) {
|
|
105
|
-
return sortByName(arr).map(
|
|
98
|
+
return sortByName(arr).map(replaceNamedType);
|
|
106
99
|
}
|
|
107
100
|
|
|
108
101
|
function sortNamedType(type) {
|
|
109
|
-
if ((0,
|
|
110
|
-
return type;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
var sortedType = cache[type.name];
|
|
114
|
-
|
|
115
|
-
if (!sortedType) {
|
|
116
|
-
sortedType = sortNamedTypeImpl(type);
|
|
117
|
-
cache[type.name] = sortedType;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
return sortedType;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
function sortNamedTypeImpl(type) {
|
|
124
|
-
if ((0, _definition.isScalarType)(type)) {
|
|
102
|
+
if ((0, _definition.isScalarType)(type) || (0, _introspection.isIntrospectionType)(type)) {
|
|
125
103
|
return type;
|
|
126
104
|
} else if ((0, _definition.isObjectType)(type)) {
|
|
127
|
-
|
|
128
|
-
|
|
105
|
+
var config = type.toConfig();
|
|
106
|
+
return new _definition.GraphQLObjectType(_objectSpread({}, config, {
|
|
129
107
|
interfaces: function interfaces() {
|
|
130
|
-
return sortTypes(
|
|
108
|
+
return sortTypes(config.interfaces);
|
|
131
109
|
},
|
|
132
110
|
fields: function fields() {
|
|
133
|
-
return sortFields(
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
description: type.description,
|
|
137
|
-
astNode: type.astNode,
|
|
138
|
-
extensionASTNodes: type.extensionASTNodes
|
|
139
|
-
});
|
|
111
|
+
return sortFields(config.fields);
|
|
112
|
+
}
|
|
113
|
+
}));
|
|
140
114
|
} else if ((0, _definition.isInterfaceType)(type)) {
|
|
141
|
-
|
|
142
|
-
|
|
115
|
+
var _config = type.toConfig();
|
|
116
|
+
|
|
117
|
+
return new _definition.GraphQLInterfaceType(_objectSpread({}, _config, {
|
|
143
118
|
fields: function fields() {
|
|
144
|
-
return sortFields(
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
description: type.description,
|
|
148
|
-
astNode: type.astNode,
|
|
149
|
-
extensionASTNodes: type.extensionASTNodes
|
|
150
|
-
});
|
|
119
|
+
return sortFields(_config.fields);
|
|
120
|
+
}
|
|
121
|
+
}));
|
|
151
122
|
} else if ((0, _definition.isUnionType)(type)) {
|
|
152
|
-
|
|
153
|
-
|
|
123
|
+
var _config2 = type.toConfig();
|
|
124
|
+
|
|
125
|
+
return new _definition.GraphQLUnionType(_objectSpread({}, _config2, {
|
|
154
126
|
types: function types() {
|
|
155
|
-
return sortTypes(
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
description: type.description,
|
|
159
|
-
astNode: type.astNode
|
|
160
|
-
});
|
|
127
|
+
return sortTypes(_config2.types);
|
|
128
|
+
}
|
|
129
|
+
}));
|
|
161
130
|
} else if ((0, _definition.isEnumType)(type)) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
return {
|
|
168
|
-
value: val.value,
|
|
169
|
-
deprecationReason: val.deprecationReason,
|
|
170
|
-
description: val.description,
|
|
171
|
-
astNode: val.astNode
|
|
172
|
-
};
|
|
173
|
-
}),
|
|
174
|
-
description: type.description,
|
|
175
|
-
astNode: type.astNode
|
|
176
|
-
});
|
|
131
|
+
var _config3 = type.toConfig();
|
|
132
|
+
|
|
133
|
+
return new _definition.GraphQLEnumType(_objectSpread({}, _config3, {
|
|
134
|
+
values: sortObjMap(_config3.values)
|
|
135
|
+
}));
|
|
177
136
|
} else if ((0, _definition.isInputObjectType)(type)) {
|
|
178
|
-
|
|
179
|
-
|
|
137
|
+
var _config4 = type.toConfig();
|
|
138
|
+
|
|
139
|
+
return new _definition.GraphQLInputObjectType(_objectSpread({}, _config4, {
|
|
180
140
|
fields: function fields() {
|
|
181
|
-
return sortInputFields(
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
141
|
+
return sortInputFields(_config4.fields);
|
|
142
|
+
}
|
|
143
|
+
}));
|
|
144
|
+
} // Not reachable. All possible types have been considered.
|
|
145
|
+
|
|
146
|
+
/* istanbul ignore next */
|
|
187
147
|
|
|
188
|
-
|
|
148
|
+
|
|
149
|
+
throw new Error("Unexpected type: \"".concat((0, _inspect.default)(type), "\"."));
|
|
189
150
|
}
|
|
190
151
|
}
|
|
191
152
|
|
|
@@ -195,8 +156,8 @@ function sortObjMap(map, sortValueFn) {
|
|
|
195
156
|
return x;
|
|
196
157
|
});
|
|
197
158
|
|
|
198
|
-
for (var _i = 0; _i <
|
|
199
|
-
var key =
|
|
159
|
+
for (var _i = 0, _sortedKeys = sortedKeys; _i < _sortedKeys.length; _i++) {
|
|
160
|
+
var key = _sortedKeys[_i];
|
|
200
161
|
var value = map[key];
|
|
201
162
|
sortedMap[key] = sortValueFn ? sortValueFn(value) : value;
|
|
202
163
|
}
|
|
@@ -216,4 +177,4 @@ function sortBy(array, mapToKey) {
|
|
|
216
177
|
var key2 = mapToKey(obj2);
|
|
217
178
|
return key1.localeCompare(key2);
|
|
218
179
|
});
|
|
219
|
-
}
|
|
180
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -8,12 +8,13 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import objectValues from '../polyfills/objectValues';
|
|
11
|
-
import
|
|
11
|
+
import inspect from '../jsutils/inspect';
|
|
12
12
|
import keyValMap from '../jsutils/keyValMap';
|
|
13
|
+
import { type ObjMap } from '../jsutils/ObjMap';
|
|
13
14
|
import { GraphQLSchema } from '../type/schema';
|
|
14
15
|
import { GraphQLDirective } from '../type/directives';
|
|
15
|
-
import type { GraphQLNamedType } from '../type/definition';
|
|
16
16
|
import {
|
|
17
|
+
type GraphQLNamedType,
|
|
17
18
|
GraphQLObjectType,
|
|
18
19
|
GraphQLInterfaceType,
|
|
19
20
|
GraphQLUnionType,
|
|
@@ -30,148 +31,119 @@ import {
|
|
|
30
31
|
isEnumType,
|
|
31
32
|
isInputObjectType,
|
|
32
33
|
} from '../type/definition';
|
|
33
|
-
import { isSpecifiedScalarType } from '../type/scalars';
|
|
34
34
|
import { isIntrospectionType } from '../type/introspection';
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* Sort GraphQLSchema.
|
|
38
38
|
*/
|
|
39
39
|
export function lexicographicSortSchema(schema: GraphQLSchema): GraphQLSchema {
|
|
40
|
-
const
|
|
40
|
+
const schemaConfig = schema.toConfig();
|
|
41
|
+
const typeMap = keyValMap(
|
|
42
|
+
sortByName(schemaConfig.types),
|
|
43
|
+
type => type.name,
|
|
44
|
+
sortNamedType,
|
|
45
|
+
);
|
|
41
46
|
|
|
42
|
-
const sortMaybeType = maybeType => maybeType && sortNamedType(maybeType);
|
|
43
47
|
return new GraphQLSchema({
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
...schemaConfig,
|
|
49
|
+
types: objectValues(typeMap),
|
|
50
|
+
directives: sortByName(schemaConfig.directives).map(sortDirective),
|
|
51
|
+
query: replaceMaybeType(schemaConfig.query),
|
|
52
|
+
mutation: replaceMaybeType(schemaConfig.mutation),
|
|
53
|
+
subscription: replaceMaybeType(schemaConfig.subscription),
|
|
50
54
|
});
|
|
51
55
|
|
|
56
|
+
function replaceType(type) {
|
|
57
|
+
if (isListType(type)) {
|
|
58
|
+
return new GraphQLList(replaceType(type.ofType));
|
|
59
|
+
} else if (isNonNullType(type)) {
|
|
60
|
+
return new GraphQLNonNull(replaceType(type.ofType));
|
|
61
|
+
}
|
|
62
|
+
return replaceNamedType(type);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function replaceNamedType<T: GraphQLNamedType>(type: T): T {
|
|
66
|
+
return ((typeMap[type.name]: any): T);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function replaceMaybeType(maybeType) {
|
|
70
|
+
return maybeType && replaceNamedType(maybeType);
|
|
71
|
+
}
|
|
72
|
+
|
|
52
73
|
function sortDirective(directive) {
|
|
74
|
+
const config = directive.toConfig();
|
|
53
75
|
return new GraphQLDirective({
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
args: sortArgs(directive.args),
|
|
58
|
-
astNode: directive.astNode,
|
|
76
|
+
...config,
|
|
77
|
+
locations: sortBy(config.locations, x => x),
|
|
78
|
+
args: sortArgs(config.args),
|
|
59
79
|
});
|
|
60
80
|
}
|
|
61
81
|
|
|
62
82
|
function sortArgs(args) {
|
|
63
|
-
return
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
...arg,
|
|
68
|
-
type: sortType(arg.type),
|
|
69
|
-
}),
|
|
70
|
-
);
|
|
83
|
+
return sortObjMap(args, arg => ({
|
|
84
|
+
...arg,
|
|
85
|
+
type: replaceType(arg.type),
|
|
86
|
+
}));
|
|
71
87
|
}
|
|
72
88
|
|
|
73
89
|
function sortFields(fieldsMap) {
|
|
74
90
|
return sortObjMap(fieldsMap, field => ({
|
|
75
|
-
|
|
91
|
+
...field,
|
|
92
|
+
type: replaceType(field.type),
|
|
76
93
|
args: sortArgs(field.args),
|
|
77
|
-
resolve: field.resolve,
|
|
78
|
-
subscribe: field.subscribe,
|
|
79
|
-
deprecationReason: field.deprecationReason,
|
|
80
|
-
description: field.description,
|
|
81
|
-
astNode: field.astNode,
|
|
82
94
|
}));
|
|
83
95
|
}
|
|
84
96
|
|
|
85
97
|
function sortInputFields(fieldsMap) {
|
|
86
98
|
return sortObjMap(fieldsMap, field => ({
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
description: field.description,
|
|
90
|
-
astNode: field.astNode,
|
|
99
|
+
...field,
|
|
100
|
+
type: replaceType(field.type),
|
|
91
101
|
}));
|
|
92
102
|
}
|
|
93
103
|
|
|
94
|
-
function sortType(type) {
|
|
95
|
-
if (isListType(type)) {
|
|
96
|
-
return new GraphQLList(sortType(type.ofType));
|
|
97
|
-
} else if (isNonNullType(type)) {
|
|
98
|
-
return new GraphQLNonNull(sortType(type.ofType));
|
|
99
|
-
}
|
|
100
|
-
return sortNamedType(type);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
104
|
function sortTypes<T: GraphQLNamedType>(arr: Array<T>): Array<T> {
|
|
104
|
-
return sortByName(arr).map(
|
|
105
|
+
return sortByName(arr).map(replaceNamedType);
|
|
105
106
|
}
|
|
106
107
|
|
|
107
|
-
function sortNamedType
|
|
108
|
-
if (
|
|
109
|
-
return type;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
let sortedType = cache[type.name];
|
|
113
|
-
if (!sortedType) {
|
|
114
|
-
sortedType = sortNamedTypeImpl(type);
|
|
115
|
-
cache[type.name] = sortedType;
|
|
116
|
-
}
|
|
117
|
-
return ((sortedType: any): T);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function sortNamedTypeImpl(type) {
|
|
121
|
-
if (isScalarType(type)) {
|
|
108
|
+
function sortNamedType(type) {
|
|
109
|
+
if (isScalarType(type) || isIntrospectionType(type)) {
|
|
122
110
|
return type;
|
|
123
111
|
} else if (isObjectType(type)) {
|
|
112
|
+
const config = type.toConfig();
|
|
124
113
|
return new GraphQLObjectType({
|
|
125
|
-
|
|
126
|
-
interfaces: () => sortTypes(
|
|
127
|
-
fields: () => sortFields(
|
|
128
|
-
isTypeOf: type.isTypeOf,
|
|
129
|
-
description: type.description,
|
|
130
|
-
astNode: type.astNode,
|
|
131
|
-
extensionASTNodes: type.extensionASTNodes,
|
|
114
|
+
...config,
|
|
115
|
+
interfaces: () => sortTypes(config.interfaces),
|
|
116
|
+
fields: () => sortFields(config.fields),
|
|
132
117
|
});
|
|
133
118
|
} else if (isInterfaceType(type)) {
|
|
119
|
+
const config = type.toConfig();
|
|
134
120
|
return new GraphQLInterfaceType({
|
|
135
|
-
|
|
136
|
-
fields: () => sortFields(
|
|
137
|
-
resolveType: type.resolveType,
|
|
138
|
-
description: type.description,
|
|
139
|
-
astNode: type.astNode,
|
|
140
|
-
extensionASTNodes: type.extensionASTNodes,
|
|
121
|
+
...config,
|
|
122
|
+
fields: () => sortFields(config.fields),
|
|
141
123
|
});
|
|
142
124
|
} else if (isUnionType(type)) {
|
|
125
|
+
const config = type.toConfig();
|
|
143
126
|
return new GraphQLUnionType({
|
|
144
|
-
|
|
145
|
-
types: () => sortTypes(
|
|
146
|
-
resolveType: type.resolveType,
|
|
147
|
-
description: type.description,
|
|
148
|
-
astNode: type.astNode,
|
|
127
|
+
...config,
|
|
128
|
+
types: () => sortTypes(config.types),
|
|
149
129
|
});
|
|
150
130
|
} else if (isEnumType(type)) {
|
|
131
|
+
const config = type.toConfig();
|
|
151
132
|
return new GraphQLEnumType({
|
|
152
|
-
|
|
153
|
-
values:
|
|
154
|
-
sortByName(type.getValues()),
|
|
155
|
-
val => val.name,
|
|
156
|
-
val => ({
|
|
157
|
-
value: val.value,
|
|
158
|
-
deprecationReason: val.deprecationReason,
|
|
159
|
-
description: val.description,
|
|
160
|
-
astNode: val.astNode,
|
|
161
|
-
}),
|
|
162
|
-
),
|
|
163
|
-
description: type.description,
|
|
164
|
-
astNode: type.astNode,
|
|
133
|
+
...config,
|
|
134
|
+
values: sortObjMap(config.values),
|
|
165
135
|
});
|
|
166
136
|
} else if (isInputObjectType(type)) {
|
|
137
|
+
const config = type.toConfig();
|
|
167
138
|
return new GraphQLInputObjectType({
|
|
168
|
-
|
|
169
|
-
fields: () => sortInputFields(
|
|
170
|
-
description: type.description,
|
|
171
|
-
astNode: type.astNode,
|
|
139
|
+
...config,
|
|
140
|
+
fields: () => sortInputFields(config.fields),
|
|
172
141
|
});
|
|
173
142
|
}
|
|
174
|
-
|
|
143
|
+
|
|
144
|
+
// Not reachable. All possible types have been considered.
|
|
145
|
+
/* istanbul ignore next */
|
|
146
|
+
throw new Error(`Unexpected type: "${inspect((type: empty))}".`);
|
|
175
147
|
}
|
|
176
148
|
}
|
|
177
149
|
|