graphql 14.0.2 → 14.2.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 +5 -5
- package/codecov.yml +14 -0
- package/error/GraphQLError.js +2 -2
- package/error/GraphQLError.js.flow +4 -4
- package/error/GraphQLError.mjs +2 -2
- package/error/formatError.js +2 -2
- package/error/formatError.js.flow +1 -1
- package/error/formatError.mjs +2 -2
- package/error/index.js.flow +1 -1
- package/error/index.mjs +2 -2
- package/error/locatedError.js +2 -2
- package/error/locatedError.js.flow +1 -1
- package/error/locatedError.mjs +2 -2
- package/error/printError.js +2 -2
- package/error/printError.js.flow +1 -1
- package/error/printError.mjs +2 -2
- package/error/syntaxError.js +2 -2
- package/error/syntaxError.js.flow +1 -1
- package/error/syntaxError.mjs +2 -2
- package/execution/execute.js +20 -11
- package/execution/execute.js.flow +41 -27
- package/execution/execute.mjs +19 -13
- package/execution/index.js +6 -0
- package/execution/index.js.flow +7 -2
- package/execution/index.mjs +3 -3
- package/execution/values.js +10 -10
- package/execution/values.js.flow +8 -8
- package/execution/values.mjs +9 -9
- package/graphql.js +8 -8
- package/graphql.js.flow +18 -4
- package/graphql.mjs +8 -8
- package/index.js +18 -0
- package/index.js.flow +4 -1
- package/index.mjs +4 -4
- package/jsutils/ObjMap.js.flow +1 -1
- package/jsutils/{MaybePromise.js → PromiseOrValue.js} +0 -0
- package/jsutils/{MaybePromise.js.flow → PromiseOrValue.js.flow} +2 -2
- package/jsutils/{MaybePromise.mjs → PromiseOrValue.mjs} +0 -0
- package/jsutils/dedent.js +2 -2
- package/jsutils/dedent.js.flow +1 -1
- package/jsutils/dedent.mjs +2 -2
- package/jsutils/defineToJSON.js +18 -7
- package/jsutils/defineToJSON.js.flow +15 -6
- package/jsutils/defineToJSON.mjs +15 -7
- package/jsutils/defineToStringTag.js +6 -6
- package/jsutils/defineToStringTag.js.flow +4 -4
- package/jsutils/defineToStringTag.mjs +5 -5
- package/jsutils/inspect.js +109 -23
- package/jsutils/inspect.js.flow +112 -14
- package/jsutils/inspect.mjs +108 -17
- package/jsutils/instanceOf.js +2 -2
- package/jsutils/instanceOf.js.flow +1 -1
- package/jsutils/instanceOf.mjs +2 -2
- package/jsutils/invariant.js +2 -2
- package/jsutils/invariant.js.flow +1 -1
- package/jsutils/invariant.mjs +2 -2
- 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 +2 -2
- package/jsutils/keyMap.js.flow +1 -1
- package/jsutils/keyMap.mjs +2 -2
- package/jsutils/keyValMap.js +2 -2
- package/jsutils/keyValMap.js.flow +1 -1
- package/jsutils/keyValMap.mjs +2 -2
- package/jsutils/mapValue.js +54 -0
- package/jsutils/mapValue.js.flow +27 -0
- package/jsutils/mapValue.mjs +44 -0
- package/jsutils/memoize3.js +2 -2
- package/jsutils/memoize3.js.flow +1 -1
- package/jsutils/memoize3.mjs +2 -2
- package/jsutils/nodejsCustomInspectSymbol.js +18 -0
- package/jsutils/nodejsCustomInspectSymbol.js.flow +15 -0
- package/jsutils/nodejsCustomInspectSymbol.mjs +10 -0
- package/jsutils/orList.js +18 -5
- package/jsutils/orList.js.flow +14 -8
- package/jsutils/orList.mjs +15 -5
- package/jsutils/promiseForObject.js +2 -2
- package/jsutils/promiseForObject.js.flow +1 -1
- 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.flow +1 -1
- package/language/{blockStringValue.mjs → blockString.js} +39 -3
- package/language/{blockStringValue.js.flow → blockString.js.flow} +31 -2
- package/language/{blockStringValue.js → blockString.mjs} +31 -10
- package/language/directiveLocation.js +2 -2
- package/language/directiveLocation.js.flow +1 -1
- package/language/directiveLocation.mjs +2 -2
- package/language/index.js.flow +1 -1
- package/language/index.mjs +2 -2
- package/language/kinds.js +2 -2
- package/language/kinds.js.flow +1 -1
- package/language/kinds.mjs +2 -2
- package/language/lexer.js +60 -46
- package/language/lexer.js.flow +71 -69
- package/language/lexer.mjs +58 -45
- package/language/location.js +2 -2
- package/language/location.js.flow +1 -1
- package/language/location.mjs +2 -2
- package/language/parser.js +84 -83
- package/language/parser.js.flow +85 -94
- package/language/parser.mjs +83 -83
- package/language/predicates.js +2 -2
- package/language/predicates.js.flow +1 -1
- package/language/predicates.mjs +2 -2
- package/language/printer.js +15 -17
- package/language/printer.js.flow +21 -20
- package/language/printer.mjs +14 -17
- package/language/source.js +8 -7
- package/language/source.js.flow +1 -1
- package/language/source.mjs +2 -10
- package/language/visitor.js +7 -6
- package/language/visitor.js.flow +3 -5
- package/language/visitor.mjs +7 -6
- package/package.json +5 -2
- package/polyfills/find.js +31 -0
- package/polyfills/find.js.flow +29 -0
- package/polyfills/find.mjs +23 -0
- package/polyfills/flatMap.js +38 -0
- package/polyfills/flatMap.js.flow +34 -0
- package/polyfills/flatMap.mjs +30 -0
- package/{jsutils → polyfills}/isFinite.js +2 -2
- package/{jsutils → polyfills}/isFinite.js.flow +1 -1
- package/{jsutils → polyfills}/isFinite.mjs +2 -2
- package/{jsutils → polyfills}/isInteger.js +2 -2
- package/{jsutils → polyfills}/isInteger.js.flow +1 -1
- package/{jsutils → polyfills}/isInteger.mjs +2 -2
- package/polyfills/objectEntries.js +26 -0
- package/polyfills/objectEntries.js.flow +19 -0
- package/polyfills/objectEntries.mjs +18 -0
- package/{jsutils → polyfills}/objectValues.js +2 -2
- package/{jsutils → polyfills}/objectValues.js.flow +2 -2
- package/{jsutils → polyfills}/objectValues.mjs +2 -2
- package/subscription/asyncIteratorReject.js.flow +1 -1
- package/subscription/asyncIteratorReject.mjs +2 -2
- package/subscription/index.js.flow +1 -1
- package/subscription/index.mjs +2 -2
- package/subscription/mapAsyncIterator.js.flow +5 -5
- package/subscription/mapAsyncIterator.mjs +2 -2
- package/subscription/subscribe.js +2 -2
- package/subscription/subscribe.js.flow +1 -1
- package/subscription/subscribe.mjs +2 -2
- package/type/definition.js +161 -138
- package/type/definition.js.flow +193 -57
- package/type/definition.mjs +158 -140
- package/type/directives.js +35 -29
- package/type/directives.js.flow +39 -21
- package/type/directives.mjs +34 -31
- package/type/index.js +12 -0
- package/type/index.js.flow +5 -1
- package/type/index.mjs +6 -4
- package/type/introspection.js +11 -7
- package/type/introspection.js.flow +11 -8
- package/type/introspection.mjs +11 -7
- package/type/scalars.js +45 -34
- package/type/scalars.js.flow +41 -27
- package/type/scalars.mjs +45 -27
- package/type/schema.js +134 -88
- package/type/schema.js.flow +77 -11
- package/type/schema.mjs +132 -88
- package/type/validate.js +152 -187
- package/type/validate.js.flow +12 -61
- package/type/validate.mjs +143 -188
- package/utilities/TypeInfo.js +10 -23
- package/utilities/TypeInfo.js.flow +2 -2
- package/utilities/TypeInfo.mjs +3 -25
- package/utilities/assertValidName.js +2 -2
- package/utilities/assertValidName.js.flow +1 -1
- package/utilities/assertValidName.mjs +2 -2
- package/utilities/astFromValue.js +7 -6
- package/utilities/astFromValue.js.flow +7 -6
- package/utilities/astFromValue.mjs +9 -8
- package/utilities/buildASTSchema.js +213 -197
- package/utilities/buildASTSchema.js.flow +163 -173
- package/utilities/buildASTSchema.mjs +203 -198
- package/utilities/buildClientSchema.js +39 -47
- package/utilities/buildClientSchema.js.flow +49 -58
- package/utilities/buildClientSchema.mjs +38 -46
- package/utilities/coerceValue.js +41 -21
- package/utilities/coerceValue.js.flow +44 -49
- package/utilities/coerceValue.mjs +42 -23
- package/utilities/concatAST.js +9 -13
- package/utilities/concatAST.js.flow +3 -9
- package/utilities/concatAST.mjs +6 -13
- package/utilities/extendSchema.js +256 -630
- package/utilities/extendSchema.js.flow +190 -426
- package/utilities/extendSchema.mjs +256 -631
- package/utilities/findBreakingChanges.js +8 -6
- package/utilities/findBreakingChanges.js.flow +4 -3
- package/utilities/findBreakingChanges.mjs +7 -6
- package/utilities/findDeprecatedUsages.js +4 -4
- package/utilities/findDeprecatedUsages.js.flow +3 -3
- package/utilities/findDeprecatedUsages.mjs +4 -4
- package/utilities/getOperationAST.js +2 -2
- package/utilities/getOperationAST.js.flow +1 -1
- package/utilities/getOperationAST.mjs +2 -2
- package/utilities/getOperationRootType.js +6 -6
- package/utilities/getOperationRootType.js.flow +9 -7
- package/utilities/getOperationRootType.mjs +6 -6
- package/utilities/index.js.flow +1 -1
- package/utilities/index.mjs +2 -2
- package/utilities/introspectionFromSchema.js +2 -2
- package/utilities/introspectionFromSchema.js.flow +1 -1
- package/utilities/introspectionFromSchema.mjs +2 -2
- package/utilities/introspectionQuery.js +2 -2
- package/utilities/introspectionQuery.js.flow +1 -1
- package/utilities/introspectionQuery.mjs +2 -2
- package/utilities/isValidJSValue.js +4 -2
- package/utilities/isValidJSValue.js.flow +2 -1
- package/utilities/isValidJSValue.mjs +4 -2
- package/utilities/isValidLiteralValue.js +2 -2
- package/utilities/isValidLiteralValue.js.flow +1 -1
- package/utilities/isValidLiteralValue.mjs +2 -2
- package/utilities/lexicographicSortSchema.js +86 -124
- package/utilities/lexicographicSortSchema.js.flow +68 -96
- package/utilities/lexicographicSortSchema.mjs +86 -124
- package/utilities/schemaPrinter.js +47 -73
- package/utilities/schemaPrinter.js.flow +62 -111
- package/utilities/schemaPrinter.mjs +46 -73
- package/utilities/separateOperations.js +11 -10
- package/utilities/separateOperations.js.flow +1 -1
- package/utilities/separateOperations.mjs +11 -10
- package/utilities/typeComparators.js +2 -2
- package/utilities/typeComparators.js.flow +1 -1
- package/utilities/typeComparators.mjs +2 -2
- package/utilities/typeFromAST.js +9 -4
- package/utilities/typeFromAST.js.flow +5 -2
- package/utilities/typeFromAST.mjs +6 -4
- package/utilities/valueFromAST.js +9 -6
- package/utilities/valueFromAST.js.flow +5 -3
- package/utilities/valueFromAST.mjs +7 -5
- package/utilities/valueFromASTUntyped.js +7 -4
- package/utilities/valueFromASTUntyped.js.flow +5 -2
- package/utilities/valueFromASTUntyped.mjs +6 -4
- package/validation/ValidationContext.js +57 -82
- package/validation/ValidationContext.js.flow +53 -50
- package/validation/ValidationContext.mjs +53 -78
- package/validation/index.js.flow +1 -1
- package/validation/index.mjs +2 -2
- package/validation/rules/ExecutableDefinitions.js +3 -3
- package/validation/rules/ExecutableDefinitions.js.flow +3 -3
- package/validation/rules/ExecutableDefinitions.mjs +3 -3
- package/validation/rules/FieldsOnCorrectType.js +3 -3
- package/validation/rules/FieldsOnCorrectType.js.flow +2 -2
- package/validation/rules/FieldsOnCorrectType.mjs +3 -3
- package/validation/rules/FragmentsOnCompositeTypes.js +4 -4
- package/validation/rules/FragmentsOnCompositeTypes.js.flow +3 -3
- package/validation/rules/FragmentsOnCompositeTypes.mjs +4 -4
- package/validation/rules/KnownArgumentNames.js.flow +1 -1
- package/validation/rules/KnownArgumentNames.mjs +2 -2
- package/validation/rules/KnownDirectives.js +4 -4
- package/validation/rules/KnownDirectives.js.flow +5 -4
- package/validation/rules/KnownDirectives.mjs +4 -4
- package/validation/rules/KnownFragmentNames.js +3 -3
- package/validation/rules/KnownFragmentNames.js.flow +2 -2
- package/validation/rules/KnownFragmentNames.mjs +3 -3
- package/validation/rules/KnownTypeNames.js +60 -22
- package/validation/rules/KnownTypeNames.js.flow +55 -21
- package/validation/rules/KnownTypeNames.mjs +57 -22
- package/validation/rules/LoneAnonymousOperation.js +3 -3
- package/validation/rules/LoneAnonymousOperation.js.flow +2 -2
- package/validation/rules/LoneAnonymousOperation.mjs +3 -3
- package/validation/rules/LoneSchemaDefinition.js +2 -2
- package/validation/rules/LoneSchemaDefinition.js.flow +1 -1
- package/validation/rules/LoneSchemaDefinition.mjs +2 -2
- package/validation/rules/NoFragmentCycles.js +2 -2
- package/validation/rules/NoFragmentCycles.js.flow +3 -3
- package/validation/rules/NoFragmentCycles.mjs +2 -2
- package/validation/rules/NoUndefinedVariables.js +2 -2
- package/validation/rules/NoUndefinedVariables.js.flow +1 -1
- package/validation/rules/NoUndefinedVariables.mjs +2 -2
- package/validation/rules/NoUnusedFragments.js +10 -7
- package/validation/rules/NoUnusedFragments.js.flow +4 -4
- package/validation/rules/NoUnusedFragments.mjs +10 -7
- package/validation/rules/NoUnusedVariables.js +7 -5
- package/validation/rules/NoUnusedVariables.js.flow +4 -3
- package/validation/rules/NoUnusedVariables.mjs +7 -5
- package/validation/rules/OverlappingFieldsCanBeMerged.js +58 -33
- package/validation/rules/OverlappingFieldsCanBeMerged.js.flow +4 -4
- package/validation/rules/OverlappingFieldsCanBeMerged.mjs +50 -34
- package/validation/rules/PossibleFragmentSpreads.js +4 -4
- package/validation/rules/PossibleFragmentSpreads.js.flow +3 -3
- package/validation/rules/PossibleFragmentSpreads.mjs +4 -4
- package/validation/rules/PossibleTypeExtensions.js +158 -0
- package/validation/rules/PossibleTypeExtensions.js.flow +160 -0
- package/validation/rules/PossibleTypeExtensions.mjs +146 -0
- package/validation/rules/ProvidedRequiredArguments.js +3 -3
- package/validation/rules/ProvidedRequiredArguments.js.flow +4 -4
- package/validation/rules/ProvidedRequiredArguments.mjs +5 -5
- package/validation/rules/ScalarLeafs.js +4 -4
- package/validation/rules/ScalarLeafs.js.flow +3 -3
- package/validation/rules/ScalarLeafs.mjs +4 -4
- package/validation/rules/SingleFieldSubscriptions.js +2 -2
- package/validation/rules/SingleFieldSubscriptions.js.flow +1 -1
- package/validation/rules/SingleFieldSubscriptions.mjs +2 -2
- package/validation/rules/UniqueArgumentNames.js +2 -2
- package/validation/rules/UniqueArgumentNames.js.flow +1 -1
- package/validation/rules/UniqueArgumentNames.mjs +2 -2
- package/validation/rules/UniqueDirectiveNames.js +55 -0
- package/validation/rules/UniqueDirectiveNames.js.flow +64 -0
- package/validation/rules/UniqueDirectiveNames.mjs +43 -0
- package/validation/rules/UniqueDirectivesPerLocation.js +2 -2
- package/validation/rules/UniqueDirectivesPerLocation.js.flow +1 -1
- package/validation/rules/UniqueDirectivesPerLocation.mjs +2 -2
- package/validation/rules/UniqueEnumValueNames.js +90 -0
- package/validation/rules/UniqueEnumValueNames.js.flow +85 -0
- package/validation/rules/UniqueEnumValueNames.mjs +77 -0
- package/validation/rules/UniqueFieldDefinitionNames.js +101 -0
- package/validation/rules/UniqueFieldDefinitionNames.js.flow +99 -0
- package/validation/rules/UniqueFieldDefinitionNames.mjs +88 -0
- package/validation/rules/UniqueFragmentNames.js +2 -2
- package/validation/rules/UniqueFragmentNames.js.flow +1 -1
- package/validation/rules/UniqueFragmentNames.mjs +2 -2
- package/validation/rules/UniqueInputFieldNames.js +2 -4
- package/validation/rules/UniqueInputFieldNames.js.flow +1 -2
- package/validation/rules/UniqueInputFieldNames.mjs +2 -4
- package/validation/rules/UniqueOperationNames.js +2 -2
- package/validation/rules/UniqueOperationNames.js.flow +1 -1
- package/validation/rules/UniqueOperationNames.mjs +2 -2
- package/validation/rules/UniqueOperationTypes.js +85 -0
- package/validation/rules/UniqueOperationTypes.js.flow +76 -0
- package/validation/rules/UniqueOperationTypes.mjs +73 -0
- package/validation/rules/UniqueTypeNames.js +62 -0
- package/validation/rules/UniqueTypeNames.js.flow +67 -0
- package/validation/rules/UniqueTypeNames.mjs +50 -0
- package/validation/rules/UniqueVariableNames.js +2 -2
- package/validation/rules/UniqueVariableNames.js.flow +1 -1
- package/validation/rules/UniqueVariableNames.mjs +2 -2
- package/validation/rules/ValuesOfCorrectType.js +30 -14
- package/validation/rules/ValuesOfCorrectType.js.flow +5 -6
- package/validation/rules/ValuesOfCorrectType.mjs +29 -14
- package/validation/rules/VariablesAreInputTypes.js +3 -3
- package/validation/rules/VariablesAreInputTypes.js.flow +2 -2
- package/validation/rules/VariablesAreInputTypes.mjs +3 -3
- package/validation/rules/VariablesInAllowedPosition.js +5 -5
- package/validation/rules/VariablesInAllowedPosition.js.flow +1 -1
- package/validation/rules/VariablesInAllowedPosition.mjs +5 -5
- package/validation/specifiedRules.js +15 -3
- package/validation/specifiedRules.js.flow +14 -1
- package/validation/specifiedRules.mjs +9 -3
- package/validation/validate.js +2 -2
- package/validation/validate.js.flow +1 -1
- package/validation/validate.mjs +2 -2
- package/jsutils/find.js +0 -22
- package/jsutils/find.js.flow +0 -19
- package/jsutils/find.mjs +0 -15
package/type/validate.mjs
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
5
3
|
*
|
|
6
4
|
* This source code is licensed under the MIT license found in the
|
|
7
5
|
* LICENSE file in the root directory of this source tree.
|
|
8
6
|
*
|
|
9
|
-
*
|
|
7
|
+
*
|
|
10
8
|
*/
|
|
9
|
+
import find from '../polyfills/find';
|
|
10
|
+
import flatMap from '../polyfills/flatMap';
|
|
11
|
+
import objectValues from '../polyfills/objectValues';
|
|
12
|
+
import objectEntries from '../polyfills/objectEntries';
|
|
11
13
|
import { isObjectType, isInterfaceType, isUnionType, isEnumType, isInputObjectType, isNamedType, isInputType, isOutputType, isRequiredArgument } from './definition';
|
|
12
14
|
import { isDirective } from './directives';
|
|
13
15
|
import { isIntrospectionType } from './introspection';
|
|
14
|
-
import {
|
|
16
|
+
import { assertSchema } from './schema';
|
|
15
17
|
import inspect from '../jsutils/inspect';
|
|
16
|
-
import find from '../jsutils/find';
|
|
17
|
-
import invariant from '../jsutils/invariant';
|
|
18
|
-
import objectValues from '../jsutils/objectValues';
|
|
19
18
|
import { GraphQLError } from '../error/GraphQLError';
|
|
20
19
|
import { isValidNameError } from '../utilities/assertValidName';
|
|
21
20
|
import { isEqualType, isTypeSubTypeOf } from '../utilities/typeComparators';
|
|
@@ -29,7 +28,7 @@ import { isEqualType, isTypeSubTypeOf } from '../utilities/typeComparators';
|
|
|
29
28
|
|
|
30
29
|
export function validateSchema(schema) {
|
|
31
30
|
// First check to ensure the provided value is in fact a GraphQLSchema.
|
|
32
|
-
|
|
31
|
+
assertSchema(schema); // If this Schema has already been validated, return the previous results.
|
|
33
32
|
|
|
34
33
|
if (schema.__validationErrors) {
|
|
35
34
|
return schema.__validationErrors;
|
|
@@ -65,10 +64,6 @@ var SchemaValidationContext =
|
|
|
65
64
|
/*#__PURE__*/
|
|
66
65
|
function () {
|
|
67
66
|
function SchemaValidationContext(schema) {
|
|
68
|
-
_defineProperty(this, "_errors", void 0);
|
|
69
|
-
|
|
70
|
-
_defineProperty(this, "schema", void 0);
|
|
71
|
-
|
|
72
67
|
this._errors = [];
|
|
73
68
|
this.schema = schema;
|
|
74
69
|
}
|
|
@@ -76,7 +71,7 @@ function () {
|
|
|
76
71
|
var _proto = SchemaValidationContext.prototype;
|
|
77
72
|
|
|
78
73
|
_proto.reportError = function reportError(message, nodes) {
|
|
79
|
-
var _nodes =
|
|
74
|
+
var _nodes = Array.isArray(nodes) ? nodes.filter(Boolean) : nodes;
|
|
80
75
|
|
|
81
76
|
this.addError(new GraphQLError(message, _nodes));
|
|
82
77
|
};
|
|
@@ -308,15 +303,7 @@ function validateFields(context, type) {
|
|
|
308
303
|
for (var _iterator5 = fields[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
|
|
309
304
|
var field = _step5.value;
|
|
310
305
|
// Ensure they are named correctly.
|
|
311
|
-
validateName(context, field); // Ensure
|
|
312
|
-
|
|
313
|
-
var fieldNodes = getAllFieldNodes(type, field.name);
|
|
314
|
-
|
|
315
|
-
if (fieldNodes.length > 1) {
|
|
316
|
-
context.reportError("Field ".concat(type.name, ".").concat(field.name, " can only be defined once."), fieldNodes);
|
|
317
|
-
continue;
|
|
318
|
-
} // Ensure the type is an output type
|
|
319
|
-
|
|
306
|
+
validateName(context, field); // Ensure the type is an output type
|
|
320
307
|
|
|
321
308
|
if (!isOutputType(field.type)) {
|
|
322
309
|
context.reportError("The type of ".concat(type.name, ".").concat(field.name, " must be Output Type ") + "but got: ".concat(inspect(field.type), "."), getFieldTypeNode(type, field.name));
|
|
@@ -419,104 +406,122 @@ function validateObjectImplementsInterface(context, object, iface) {
|
|
|
419
406
|
var objectFieldMap = object.getFields();
|
|
420
407
|
var ifaceFieldMap = iface.getFields(); // Assert each interface field is implemented.
|
|
421
408
|
|
|
422
|
-
var
|
|
409
|
+
var _iteratorNormalCompletion8 = true;
|
|
410
|
+
var _didIteratorError8 = false;
|
|
411
|
+
var _iteratorError8 = undefined;
|
|
412
|
+
|
|
413
|
+
try {
|
|
414
|
+
for (var _iterator8 = objectEntries(ifaceFieldMap)[Symbol.iterator](), _step8; !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) {
|
|
415
|
+
var _ref2 = _step8.value;
|
|
416
|
+
var fieldName = _ref2[0];
|
|
417
|
+
var ifaceField = _ref2[1];
|
|
418
|
+
var objectField = objectFieldMap[fieldName]; // Assert interface field exists on object.
|
|
419
|
+
|
|
420
|
+
if (!objectField) {
|
|
421
|
+
context.reportError("Interface field ".concat(iface.name, ".").concat(fieldName, " expected but ") + "".concat(object.name, " does not provide it."), [getFieldNode(iface, fieldName)].concat(getAllNodes(object)));
|
|
422
|
+
continue;
|
|
423
|
+
} // Assert interface field type is satisfied by object field type, by being
|
|
424
|
+
// a valid subtype. (covariant)
|
|
423
425
|
|
|
424
|
-
for (var _i = 0; _i < _arr.length; _i++) {
|
|
425
|
-
var fieldName = _arr[_i];
|
|
426
|
-
var objectField = objectFieldMap[fieldName];
|
|
427
|
-
var ifaceField = ifaceFieldMap[fieldName]; // Assert interface field exists on object.
|
|
428
426
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
} // Assert interface field type is satisfied by object field type, by being
|
|
433
|
-
// a valid subtype. (covariant)
|
|
427
|
+
if (!isTypeSubTypeOf(context.schema, objectField.type, ifaceField.type)) {
|
|
428
|
+
context.reportError("Interface field ".concat(iface.name, ".").concat(fieldName, " expects type ") + "".concat(inspect(ifaceField.type), " but ").concat(object.name, ".").concat(fieldName, " ") + "is type ".concat(inspect(objectField.type), "."), [getFieldTypeNode(iface, fieldName), getFieldTypeNode(object, fieldName)]);
|
|
429
|
+
} // Assert each interface field arg is implemented.
|
|
434
430
|
|
|
435
431
|
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
432
|
+
var _iteratorNormalCompletion9 = true;
|
|
433
|
+
var _didIteratorError9 = false;
|
|
434
|
+
var _iteratorError9 = undefined;
|
|
439
435
|
|
|
436
|
+
try {
|
|
437
|
+
var _loop = function _loop() {
|
|
438
|
+
var ifaceArg = _step9.value;
|
|
439
|
+
var argName = ifaceArg.name;
|
|
440
|
+
var objectArg = find(objectField.args, function (arg) {
|
|
441
|
+
return arg.name === argName;
|
|
442
|
+
}); // Assert interface field arg exists on object field.
|
|
440
443
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
+
if (!objectArg) {
|
|
445
|
+
context.reportError("Interface field argument ".concat(iface.name, ".").concat(fieldName, "(").concat(argName, ":) ") + "expected but ".concat(object.name, ".").concat(fieldName, " does not provide it."), [getFieldArgNode(iface, fieldName, argName), getFieldNode(object, fieldName)]);
|
|
446
|
+
return "continue";
|
|
447
|
+
} // Assert interface field arg type matches object field arg type.
|
|
448
|
+
// (invariant)
|
|
449
|
+
// TODO: change to contravariant?
|
|
444
450
|
|
|
445
|
-
try {
|
|
446
|
-
var _loop = function _loop() {
|
|
447
|
-
var ifaceArg = _step8.value;
|
|
448
|
-
var argName = ifaceArg.name;
|
|
449
|
-
var objectArg = find(objectField.args, function (arg) {
|
|
450
|
-
return arg.name === argName;
|
|
451
|
-
}); // Assert interface field arg exists on object field.
|
|
452
451
|
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
} // Assert interface field arg type matches object field arg type.
|
|
457
|
-
// (invariant)
|
|
458
|
-
// TODO: change to contravariant?
|
|
452
|
+
if (!isEqualType(ifaceArg.type, objectArg.type)) {
|
|
453
|
+
context.reportError("Interface field argument ".concat(iface.name, ".").concat(fieldName, "(").concat(argName, ":) ") + "expects type ".concat(inspect(ifaceArg.type), " but ") + "".concat(object.name, ".").concat(fieldName, "(").concat(argName, ":) is type ") + "".concat(inspect(objectArg.type), "."), [getFieldArgTypeNode(iface, fieldName, argName), getFieldArgTypeNode(object, fieldName, argName)]);
|
|
454
|
+
} // TODO: validate default values?
|
|
459
455
|
|
|
456
|
+
};
|
|
460
457
|
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
} // TODO: validate default values?
|
|
458
|
+
for (var _iterator9 = ifaceField.args[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) {
|
|
459
|
+
var _ret = _loop();
|
|
464
460
|
|
|
465
|
-
|
|
461
|
+
if (_ret === "continue") continue;
|
|
462
|
+
} // Assert additional arguments must not be required.
|
|
466
463
|
|
|
467
|
-
|
|
468
|
-
|
|
464
|
+
} catch (err) {
|
|
465
|
+
_didIteratorError9 = true;
|
|
466
|
+
_iteratorError9 = err;
|
|
467
|
+
} finally {
|
|
468
|
+
try {
|
|
469
|
+
if (!_iteratorNormalCompletion9 && _iterator9.return != null) {
|
|
470
|
+
_iterator9.return();
|
|
471
|
+
}
|
|
472
|
+
} finally {
|
|
473
|
+
if (_didIteratorError9) {
|
|
474
|
+
throw _iteratorError9;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
}
|
|
469
478
|
|
|
470
|
-
|
|
471
|
-
|
|
479
|
+
var _iteratorNormalCompletion10 = true;
|
|
480
|
+
var _didIteratorError10 = false;
|
|
481
|
+
var _iteratorError10 = undefined;
|
|
472
482
|
|
|
473
|
-
} catch (err) {
|
|
474
|
-
_didIteratorError8 = true;
|
|
475
|
-
_iteratorError8 = err;
|
|
476
|
-
} finally {
|
|
477
483
|
try {
|
|
478
|
-
|
|
479
|
-
|
|
484
|
+
var _loop2 = function _loop2() {
|
|
485
|
+
var objectArg = _step10.value;
|
|
486
|
+
var argName = objectArg.name;
|
|
487
|
+
var ifaceArg = find(ifaceField.args, function (arg) {
|
|
488
|
+
return arg.name === argName;
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
if (!ifaceArg && isRequiredArgument(objectArg)) {
|
|
492
|
+
context.reportError("Object field ".concat(object.name, ".").concat(fieldName, " includes required ") + "argument ".concat(argName, " that is missing from the Interface field ") + "".concat(iface.name, ".").concat(fieldName, "."), [getFieldArgNode(object, fieldName, argName), getFieldNode(iface, fieldName)]);
|
|
493
|
+
}
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
for (var _iterator10 = objectField.args[Symbol.iterator](), _step10; !(_iteratorNormalCompletion10 = (_step10 = _iterator10.next()).done); _iteratorNormalCompletion10 = true) {
|
|
497
|
+
_loop2();
|
|
480
498
|
}
|
|
499
|
+
} catch (err) {
|
|
500
|
+
_didIteratorError10 = true;
|
|
501
|
+
_iteratorError10 = err;
|
|
481
502
|
} finally {
|
|
482
|
-
|
|
483
|
-
|
|
503
|
+
try {
|
|
504
|
+
if (!_iteratorNormalCompletion10 && _iterator10.return != null) {
|
|
505
|
+
_iterator10.return();
|
|
506
|
+
}
|
|
507
|
+
} finally {
|
|
508
|
+
if (_didIteratorError10) {
|
|
509
|
+
throw _iteratorError10;
|
|
510
|
+
}
|
|
484
511
|
}
|
|
485
512
|
}
|
|
486
513
|
}
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
514
|
+
} catch (err) {
|
|
515
|
+
_didIteratorError8 = true;
|
|
516
|
+
_iteratorError8 = err;
|
|
517
|
+
} finally {
|
|
492
518
|
try {
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
var argName = objectArg.name;
|
|
496
|
-
var ifaceArg = find(ifaceField.args, function (arg) {
|
|
497
|
-
return arg.name === argName;
|
|
498
|
-
});
|
|
499
|
-
|
|
500
|
-
if (!ifaceArg && isRequiredArgument(objectArg)) {
|
|
501
|
-
context.reportError("Object field ".concat(object.name, ".").concat(fieldName, " includes required ") + "argument ".concat(argName, " that is missing from the Interface field ") + "".concat(iface.name, ".").concat(fieldName, "."), [getFieldArgNode(object, fieldName, argName), getFieldNode(iface, fieldName)]);
|
|
502
|
-
}
|
|
503
|
-
};
|
|
504
|
-
|
|
505
|
-
for (var _iterator9 = objectField.args[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) {
|
|
506
|
-
_loop2();
|
|
519
|
+
if (!_iteratorNormalCompletion8 && _iterator8.return != null) {
|
|
520
|
+
_iterator8.return();
|
|
507
521
|
}
|
|
508
|
-
} catch (err) {
|
|
509
|
-
_didIteratorError9 = true;
|
|
510
|
-
_iteratorError9 = err;
|
|
511
522
|
} finally {
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
_iterator9.return();
|
|
515
|
-
}
|
|
516
|
-
} finally {
|
|
517
|
-
if (_didIteratorError9) {
|
|
518
|
-
throw _iteratorError9;
|
|
519
|
-
}
|
|
523
|
+
if (_didIteratorError8) {
|
|
524
|
+
throw _iteratorError8;
|
|
520
525
|
}
|
|
521
526
|
}
|
|
522
527
|
}
|
|
@@ -530,13 +535,13 @@ function validateUnionMembers(context, union) {
|
|
|
530
535
|
}
|
|
531
536
|
|
|
532
537
|
var includedTypeNames = Object.create(null);
|
|
533
|
-
var
|
|
534
|
-
var
|
|
535
|
-
var
|
|
538
|
+
var _iteratorNormalCompletion11 = true;
|
|
539
|
+
var _didIteratorError11 = false;
|
|
540
|
+
var _iteratorError11 = undefined;
|
|
536
541
|
|
|
537
542
|
try {
|
|
538
|
-
for (var
|
|
539
|
-
var memberType =
|
|
543
|
+
for (var _iterator11 = memberTypes[Symbol.iterator](), _step11; !(_iteratorNormalCompletion11 = (_step11 = _iterator11.next()).done); _iteratorNormalCompletion11 = true) {
|
|
544
|
+
var memberType = _step11.value;
|
|
540
545
|
|
|
541
546
|
if (includedTypeNames[memberType.name]) {
|
|
542
547
|
context.reportError("Union type ".concat(union.name, " can only include type ") + "".concat(memberType.name, " once."), getUnionMemberTypeNodes(union, memberType.name));
|
|
@@ -550,16 +555,16 @@ function validateUnionMembers(context, union) {
|
|
|
550
555
|
}
|
|
551
556
|
}
|
|
552
557
|
} catch (err) {
|
|
553
|
-
|
|
554
|
-
|
|
558
|
+
_didIteratorError11 = true;
|
|
559
|
+
_iteratorError11 = err;
|
|
555
560
|
} finally {
|
|
556
561
|
try {
|
|
557
|
-
if (!
|
|
558
|
-
|
|
562
|
+
if (!_iteratorNormalCompletion11 && _iterator11.return != null) {
|
|
563
|
+
_iterator11.return();
|
|
559
564
|
}
|
|
560
565
|
} finally {
|
|
561
|
-
if (
|
|
562
|
-
throw
|
|
566
|
+
if (_didIteratorError11) {
|
|
567
|
+
throw _iteratorError11;
|
|
563
568
|
}
|
|
564
569
|
}
|
|
565
570
|
}
|
|
@@ -572,21 +577,14 @@ function validateEnumValues(context, enumType) {
|
|
|
572
577
|
context.reportError("Enum type ".concat(enumType.name, " must define one or more values."), getAllNodes(enumType));
|
|
573
578
|
}
|
|
574
579
|
|
|
575
|
-
var
|
|
576
|
-
var
|
|
577
|
-
var
|
|
580
|
+
var _iteratorNormalCompletion12 = true;
|
|
581
|
+
var _didIteratorError12 = false;
|
|
582
|
+
var _iteratorError12 = undefined;
|
|
578
583
|
|
|
579
584
|
try {
|
|
580
|
-
for (var
|
|
581
|
-
var enumValue =
|
|
582
|
-
var valueName = enumValue.name; // Ensure
|
|
583
|
-
|
|
584
|
-
var allNodes = getEnumValueNodes(enumType, valueName);
|
|
585
|
-
|
|
586
|
-
if (allNodes && allNodes.length > 1) {
|
|
587
|
-
context.reportError("Enum type ".concat(enumType.name, " can include value ").concat(valueName, " only once."), allNodes);
|
|
588
|
-
} // Ensure valid name.
|
|
589
|
-
|
|
585
|
+
for (var _iterator12 = enumValues[Symbol.iterator](), _step12; !(_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done); _iteratorNormalCompletion12 = true) {
|
|
586
|
+
var enumValue = _step12.value;
|
|
587
|
+
var valueName = enumValue.name; // Ensure valid name.
|
|
590
588
|
|
|
591
589
|
validateName(context, enumValue);
|
|
592
590
|
|
|
@@ -595,16 +593,16 @@ function validateEnumValues(context, enumType) {
|
|
|
595
593
|
}
|
|
596
594
|
}
|
|
597
595
|
} catch (err) {
|
|
598
|
-
|
|
599
|
-
|
|
596
|
+
_didIteratorError12 = true;
|
|
597
|
+
_iteratorError12 = err;
|
|
600
598
|
} finally {
|
|
601
599
|
try {
|
|
602
|
-
if (!
|
|
603
|
-
|
|
600
|
+
if (!_iteratorNormalCompletion12 && _iterator12.return != null) {
|
|
601
|
+
_iterator12.return();
|
|
604
602
|
}
|
|
605
603
|
} finally {
|
|
606
|
-
if (
|
|
607
|
-
throw
|
|
604
|
+
if (_didIteratorError12) {
|
|
605
|
+
throw _iteratorError12;
|
|
608
606
|
}
|
|
609
607
|
}
|
|
610
608
|
}
|
|
@@ -618,32 +616,31 @@ function validateInputFields(context, inputObj) {
|
|
|
618
616
|
} // Ensure the arguments are valid
|
|
619
617
|
|
|
620
618
|
|
|
621
|
-
var
|
|
622
|
-
var
|
|
623
|
-
var
|
|
619
|
+
var _iteratorNormalCompletion13 = true;
|
|
620
|
+
var _didIteratorError13 = false;
|
|
621
|
+
var _iteratorError13 = undefined;
|
|
624
622
|
|
|
625
623
|
try {
|
|
626
|
-
for (var
|
|
627
|
-
var field =
|
|
624
|
+
for (var _iterator13 = fields[Symbol.iterator](), _step13; !(_iteratorNormalCompletion13 = (_step13 = _iterator13.next()).done); _iteratorNormalCompletion13 = true) {
|
|
625
|
+
var field = _step13.value;
|
|
628
626
|
// Ensure they are named correctly.
|
|
629
|
-
validateName(context, field); //
|
|
630
|
-
// Ensure the type is an input type
|
|
627
|
+
validateName(context, field); // Ensure the type is an input type
|
|
631
628
|
|
|
632
629
|
if (!isInputType(field.type)) {
|
|
633
630
|
context.reportError("The type of ".concat(inputObj.name, ".").concat(field.name, " must be Input Type ") + "but got: ".concat(inspect(field.type), "."), field.astNode && field.astNode.type);
|
|
634
631
|
}
|
|
635
632
|
}
|
|
636
633
|
} catch (err) {
|
|
637
|
-
|
|
638
|
-
|
|
634
|
+
_didIteratorError13 = true;
|
|
635
|
+
_iteratorError13 = err;
|
|
639
636
|
} finally {
|
|
640
637
|
try {
|
|
641
|
-
if (!
|
|
642
|
-
|
|
638
|
+
if (!_iteratorNormalCompletion13 && _iterator13.return != null) {
|
|
639
|
+
_iterator13.return();
|
|
643
640
|
}
|
|
644
641
|
} finally {
|
|
645
|
-
if (
|
|
646
|
-
throw
|
|
642
|
+
if (_didIteratorError13) {
|
|
643
|
+
throw _iteratorError13;
|
|
647
644
|
}
|
|
648
645
|
}
|
|
649
646
|
}
|
|
@@ -656,39 +653,9 @@ function getAllNodes(object) {
|
|
|
656
653
|
}
|
|
657
654
|
|
|
658
655
|
function getAllSubNodes(object, getter) {
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
var _iteratorError13 = undefined;
|
|
663
|
-
|
|
664
|
-
try {
|
|
665
|
-
for (var _iterator13 = getAllNodes(object)[Symbol.iterator](), _step13; !(_iteratorNormalCompletion13 = (_step13 = _iterator13.next()).done); _iteratorNormalCompletion13 = true) {
|
|
666
|
-
var astNode = _step13.value;
|
|
667
|
-
|
|
668
|
-
if (astNode) {
|
|
669
|
-
var subNodes = getter(astNode);
|
|
670
|
-
|
|
671
|
-
if (subNodes) {
|
|
672
|
-
result = result.concat(subNodes);
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
|
-
} catch (err) {
|
|
677
|
-
_didIteratorError13 = true;
|
|
678
|
-
_iteratorError13 = err;
|
|
679
|
-
} finally {
|
|
680
|
-
try {
|
|
681
|
-
if (!_iteratorNormalCompletion13 && _iterator13.return != null) {
|
|
682
|
-
_iterator13.return();
|
|
683
|
-
}
|
|
684
|
-
} finally {
|
|
685
|
-
if (_didIteratorError13) {
|
|
686
|
-
throw _iteratorError13;
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
return result;
|
|
656
|
+
return flatMap(getAllNodes(object), function (item) {
|
|
657
|
+
return getter(item) || [];
|
|
658
|
+
});
|
|
692
659
|
}
|
|
693
660
|
|
|
694
661
|
function getImplementsInterfaceNode(type, iface) {
|
|
@@ -704,13 +671,9 @@ function getAllImplementsInterfaceNodes(type, iface) {
|
|
|
704
671
|
}
|
|
705
672
|
|
|
706
673
|
function getFieldNode(type, fieldName) {
|
|
707
|
-
return
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
function getAllFieldNodes(type, fieldName) {
|
|
711
|
-
return getAllSubNodes(type, function (typeNode) {
|
|
674
|
+
return find(getAllSubNodes(type, function (typeNode) {
|
|
712
675
|
return typeNode.fields;
|
|
713
|
-
})
|
|
676
|
+
}), function (fieldNode) {
|
|
714
677
|
return fieldNode.name.value === fieldName;
|
|
715
678
|
});
|
|
716
679
|
}
|
|
@@ -784,12 +747,4 @@ function getUnionMemberTypeNodes(union, typeName) {
|
|
|
784
747
|
}).filter(function (typeNode) {
|
|
785
748
|
return typeNode.name.value === typeName;
|
|
786
749
|
});
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
function getEnumValueNodes(enumType, valueName) {
|
|
790
|
-
return getAllSubNodes(enumType, function (enumNode) {
|
|
791
|
-
return enumNode.values;
|
|
792
|
-
}).filter(function (valueNode) {
|
|
793
|
-
return valueNode.name.value === valueName;
|
|
794
|
-
});
|
|
795
750
|
}
|
package/utilities/TypeInfo.js
CHANGED
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.TypeInfo = void 0;
|
|
7
7
|
|
|
8
|
+
var _find = _interopRequireDefault(require("../polyfills/find"));
|
|
9
|
+
|
|
8
10
|
var _kinds = require("../language/kinds");
|
|
9
11
|
|
|
10
12
|
var _definition = require("../type/definition");
|
|
@@ -13,11 +15,16 @@ var _introspection = require("../type/introspection");
|
|
|
13
15
|
|
|
14
16
|
var _typeFromAST = require("./typeFromAST");
|
|
15
17
|
|
|
16
|
-
var _find = _interopRequireDefault(require("../jsutils/find"));
|
|
17
|
-
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
22
|
+
*
|
|
23
|
+
* This source code is licensed under the MIT license found in the
|
|
24
|
+
* LICENSE file in the root directory of this source tree.
|
|
25
|
+
*
|
|
26
|
+
*
|
|
27
|
+
*/
|
|
21
28
|
|
|
22
29
|
/**
|
|
23
30
|
* TypeInfo is a utility class which, given a GraphQL schema, can keep track
|
|
@@ -31,26 +38,6 @@ function () {
|
|
|
31
38
|
// to support non-spec-compliant codebases. You should never need to use it.
|
|
32
39
|
getFieldDefFn, // Initial type may be provided in rare cases to facilitate traversals
|
|
33
40
|
initialType) {
|
|
34
|
-
_defineProperty(this, "_schema", void 0);
|
|
35
|
-
|
|
36
|
-
_defineProperty(this, "_typeStack", void 0);
|
|
37
|
-
|
|
38
|
-
_defineProperty(this, "_parentTypeStack", void 0);
|
|
39
|
-
|
|
40
|
-
_defineProperty(this, "_inputTypeStack", void 0);
|
|
41
|
-
|
|
42
|
-
_defineProperty(this, "_fieldDefStack", void 0);
|
|
43
|
-
|
|
44
|
-
_defineProperty(this, "_defaultValueStack", void 0);
|
|
45
|
-
|
|
46
|
-
_defineProperty(this, "_directive", void 0);
|
|
47
|
-
|
|
48
|
-
_defineProperty(this, "_argument", void 0);
|
|
49
|
-
|
|
50
|
-
_defineProperty(this, "_enumValue", void 0);
|
|
51
|
-
|
|
52
|
-
_defineProperty(this, "_getFieldDef", void 0);
|
|
53
|
-
|
|
54
41
|
this._schema = schema;
|
|
55
42
|
this._typeStack = [];
|
|
56
43
|
this._parentTypeStack = [];
|
|
@@ -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.
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* @flow strict
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
import find from '../polyfills/find';
|
|
10
11
|
import { Kind } from '../language/kinds';
|
|
11
12
|
import {
|
|
12
13
|
isObjectType,
|
|
@@ -39,7 +40,6 @@ import {
|
|
|
39
40
|
import type { GraphQLSchema } from '../type/schema';
|
|
40
41
|
import type { ASTNode, FieldNode } from '../language/ast';
|
|
41
42
|
import { typeFromAST } from './typeFromAST';
|
|
42
|
-
import find from '../jsutils/find';
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
45
|
* TypeInfo is a utility class which, given a GraphQL schema, can keep track
|
package/utilities/TypeInfo.mjs
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
5
3
|
*
|
|
6
4
|
* This source code is licensed under the MIT license found in the
|
|
7
5
|
* LICENSE file in the root directory of this source tree.
|
|
8
6
|
*
|
|
9
|
-
*
|
|
7
|
+
*
|
|
10
8
|
*/
|
|
9
|
+
import find from '../polyfills/find';
|
|
11
10
|
import { Kind } from '../language/kinds';
|
|
12
11
|
import { isObjectType, isInterfaceType, isEnumType, isInputObjectType, isListType, isCompositeType, isInputType, isOutputType, getNullableType, getNamedType } from '../type/definition';
|
|
13
12
|
import { SchemaMetaFieldDef, TypeMetaFieldDef, TypeNameMetaFieldDef } from '../type/introspection';
|
|
14
13
|
import { typeFromAST } from './typeFromAST';
|
|
15
|
-
import find from '../jsutils/find';
|
|
16
14
|
/**
|
|
17
15
|
* TypeInfo is a utility class which, given a GraphQL schema, can keep track
|
|
18
16
|
* of the current field and type definitions at any point in a GraphQL document
|
|
@@ -26,26 +24,6 @@ function () {
|
|
|
26
24
|
// to support non-spec-compliant codebases. You should never need to use it.
|
|
27
25
|
getFieldDefFn, // Initial type may be provided in rare cases to facilitate traversals
|
|
28
26
|
initialType) {
|
|
29
|
-
_defineProperty(this, "_schema", void 0);
|
|
30
|
-
|
|
31
|
-
_defineProperty(this, "_typeStack", void 0);
|
|
32
|
-
|
|
33
|
-
_defineProperty(this, "_parentTypeStack", void 0);
|
|
34
|
-
|
|
35
|
-
_defineProperty(this, "_inputTypeStack", void 0);
|
|
36
|
-
|
|
37
|
-
_defineProperty(this, "_fieldDefStack", void 0);
|
|
38
|
-
|
|
39
|
-
_defineProperty(this, "_defaultValueStack", void 0);
|
|
40
|
-
|
|
41
|
-
_defineProperty(this, "_directive", void 0);
|
|
42
|
-
|
|
43
|
-
_defineProperty(this, "_argument", void 0);
|
|
44
|
-
|
|
45
|
-
_defineProperty(this, "_enumValue", void 0);
|
|
46
|
-
|
|
47
|
-
_defineProperty(this, "_getFieldDef", void 0);
|
|
48
|
-
|
|
49
27
|
this._schema = schema;
|
|
50
28
|
this._typeStack = [];
|
|
51
29
|
this._parentTypeStack = [];
|
|
@@ -13,12 +13,12 @@ var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
|
|
|
13
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* Copyright (c)
|
|
16
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
17
17
|
*
|
|
18
18
|
* This source code is licensed under the MIT license found in the
|
|
19
19
|
* LICENSE file in the root directory of this source tree.
|
|
20
20
|
*
|
|
21
|
-
*
|
|
21
|
+
*
|
|
22
22
|
*/
|
|
23
23
|
var NAME_RX = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
24
24
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
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.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
*
|
|
8
8
|
*/
|
|
9
9
|
import { GraphQLError } from '../error/GraphQLError';
|
|
10
10
|
import invariant from '../jsutils/invariant';
|