graphql 14.4.2 → 14.5.3
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/README.md +5 -10
- package/error/GraphQLError.d.ts +87 -0
- package/error/GraphQLError.js +7 -45
- package/error/GraphQLError.js.flow +1 -0
- package/error/GraphQLError.mjs +7 -45
- package/error/formatError.d.ts +39 -0
- package/error/formatError.js +5 -2
- package/error/formatError.js.flow +27 -3
- package/error/formatError.mjs +5 -2
- package/error/index.d.ts +4 -0
- package/error/locatedError.d.ts +13 -0
- package/error/locatedError.js.flow +2 -1
- package/error/locatedError.mjs +1 -1
- package/error/syntaxError.d.ts +12 -0
- package/error/syntaxError.js.flow +1 -0
- package/execution/execute.d.ts +190 -0
- package/execution/execute.js +55 -89
- package/execution/execute.js.flow +95 -133
- package/execution/execute.mjs +75 -80
- package/execution/index.d.ts +11 -0
- package/execution/index.js +8 -6
- package/execution/index.js.flow +3 -6
- package/execution/index.mjs +2 -1
- package/execution/values.d.ts +68 -0
- package/execution/values.js +119 -128
- package/execution/values.js.flow +150 -127
- package/execution/values.mjs +117 -125
- package/graphql.d.ts +88 -0
- package/graphql.js +5 -5
- package/graphql.js.flow +9 -5
- package/graphql.mjs +41 -1
- package/index.d.ts +446 -0
- package/index.js +6 -0
- package/index.js.flow +3 -1
- package/index.mjs +2 -1
- package/jsutils/ObjMap.js.flow +6 -0
- package/jsutils/Path.d.ts +14 -0
- package/jsutils/Path.js +33 -0
- package/jsutils/Path.js.flow +26 -0
- package/jsutils/Path.mjs +24 -0
- package/jsutils/PromiseOrValue.d.ts +1 -0
- package/jsutils/dedent.js +6 -24
- package/jsutils/dedent.mjs +6 -24
- package/jsutils/defineToStringTag.js.flow +1 -1
- package/jsutils/devAssert.js +14 -0
- package/jsutils/devAssert.js.flow +8 -0
- package/jsutils/devAssert.mjs +7 -0
- package/jsutils/inspect.js +1 -1
- package/jsutils/inspect.js.flow +1 -1
- package/jsutils/inspect.mjs +1 -1
- package/jsutils/invariant.js +1 -2
- package/jsutils/invariant.js.flow +2 -3
- package/jsutils/invariant.mjs +1 -2
- package/jsutils/mapValue.js +6 -24
- package/jsutils/mapValue.js.flow +2 -1
- package/jsutils/mapValue.mjs +6 -24
- package/jsutils/printPathArray.js +15 -0
- package/jsutils/printPathArray.js.flow +14 -0
- package/jsutils/printPathArray.mjs +8 -0
- package/jsutils/suggestionList.js +14 -34
- package/jsutils/suggestionList.js.flow +4 -6
- package/jsutils/suggestionList.mjs +14 -34
- package/jsutils/toObjMap.js +28 -0
- package/jsutils/toObjMap.js.flow +26 -0
- package/jsutils/toObjMap.mjs +18 -0
- package/language/ast.d.ts +573 -0
- package/language/blockString.d.ts +21 -0
- package/language/directiveLocation.d.ts +35 -0
- package/language/index.d.ts +96 -0
- package/language/kinds.d.ts +77 -0
- package/language/lexer.d.ts +60 -0
- package/language/lexer.js +2 -12
- package/language/lexer.js.flow +6 -12
- package/language/lexer.mjs +1 -9
- package/language/location.d.ts +15 -0
- package/language/parser.d.ts +89 -0
- package/language/parser.js +1329 -1302
- package/language/parser.js.flow +1289 -1298
- package/language/parser.mjs +1326 -1297
- package/language/predicates.d.ts +36 -0
- package/language/predicates.js.flow +1 -1
- package/language/printLocation.d.ts +16 -0
- package/language/printLocation.js.flow +1 -1
- package/language/printer.d.ts +7 -0
- package/language/printer.js.flow +1 -1
- package/language/source.d.ts +19 -0
- package/language/source.js +3 -3
- package/language/source.js.flow +3 -3
- package/language/source.mjs +3 -3
- package/language/tokenKind.d.ts +35 -0
- package/language/visitor.d.ts +264 -0
- package/language/visitor.js +2 -2
- package/language/visitor.js.flow +3 -1
- package/language/visitor.mjs +2 -2
- package/package.json +1 -1
- package/polyfills/find.js +2 -2
- package/polyfills/find.js.flow +1 -2
- package/polyfills/find.mjs +2 -2
- package/polyfills/flatMap.js +3 -3
- package/polyfills/flatMap.js.flow +2 -3
- package/polyfills/flatMap.mjs +3 -3
- package/subscription/asyncIteratorReject.d.ts +6 -0
- package/subscription/index.d.ts +5 -0
- package/subscription/mapAsyncIterator.d.ts +9 -0
- package/subscription/mapAsyncIterator.js.flow +1 -0
- package/subscription/subscribe.d.ts +86 -0
- package/subscription/subscribe.js +29 -10
- package/subscription/subscribe.js.flow +45 -24
- package/subscription/subscribe.mjs +27 -9
- package/tsutils/Maybe.d.ts +4 -0
- package/type/definition.d.ts +805 -0
- package/type/definition.js +154 -70
- package/type/definition.js.flow +217 -160
- package/type/definition.mjs +149 -66
- package/type/directives.d.ts +72 -0
- package/type/directives.js +20 -12
- package/type/directives.js.flow +34 -19
- package/type/directives.mjs +17 -10
- package/type/index.d.ts +155 -0
- package/type/index.js.flow +2 -2
- package/type/introspection.d.ts +40 -0
- package/type/introspection.js +24 -10
- package/type/introspection.js.flow +29 -8
- package/type/introspection.mjs +23 -10
- package/type/scalars.d.ts +11 -0
- package/type/scalars.js +2 -2
- package/type/scalars.js.flow +4 -1
- package/type/scalars.mjs +2 -2
- package/type/schema.d.ts +108 -0
- package/type/schema.js +74 -151
- package/type/schema.js.flow +75 -73
- package/type/schema.mjs +75 -149
- package/type/validate.d.ts +19 -0
- package/type/validate.js +227 -486
- package/type/validate.js.flow +13 -8
- package/type/validate.mjs +218 -477
- package/utilities/TypeInfo.d.ts +49 -0
- package/utilities/TypeInfo.js.flow +9 -6
- package/utilities/assertValidName.d.ts +15 -0
- package/utilities/assertValidName.js +3 -3
- package/utilities/assertValidName.js.flow +3 -2
- package/utilities/assertValidName.mjs +2 -2
- package/utilities/astFromValue.d.ts +25 -0
- package/utilities/astFromValue.js +22 -38
- package/utilities/astFromValue.js.flow +7 -4
- package/utilities/astFromValue.mjs +19 -36
- package/utilities/buildASTSchema.d.ts +114 -0
- package/utilities/buildASTSchema.js +37 -68
- package/utilities/buildASTSchema.js.flow +32 -30
- package/utilities/buildASTSchema.mjs +32 -64
- package/utilities/buildClientSchema.d.ts +21 -0
- package/utilities/buildClientSchema.js +23 -15
- package/utilities/buildClientSchema.js.flow +17 -16
- package/utilities/buildClientSchema.mjs +20 -12
- package/utilities/coerceInputValue.d.ts +17 -0
- package/utilities/coerceInputValue.js +161 -0
- package/utilities/coerceInputValue.js.flow +214 -0
- package/utilities/coerceInputValue.mjs +142 -0
- package/utilities/coerceValue.d.ts +23 -0
- package/utilities/coerceValue.js +21 -199
- package/utilities/coerceValue.js.flow +31 -223
- package/utilities/coerceValue.mjs +20 -195
- package/utilities/concatAST.d.ts +8 -0
- package/utilities/concatAST.js.flow +1 -0
- package/utilities/extendSchema.d.ts +45 -0
- package/utilities/extendSchema.js +64 -131
- package/utilities/extendSchema.js.flow +27 -24
- package/utilities/extendSchema.mjs +61 -129
- package/utilities/findBreakingChanges.d.ts +64 -0
- package/utilities/findBreakingChanges.js +194 -619
- package/utilities/findBreakingChanges.js.flow +8 -5
- package/utilities/findBreakingChanges.mjs +194 -619
- package/utilities/findDeprecatedUsages.d.ts +13 -0
- package/utilities/findDeprecatedUsages.js.flow +4 -1
- package/utilities/getOperationAST.d.ts +12 -0
- package/utilities/getOperationAST.js +13 -31
- package/utilities/getOperationAST.mjs +13 -31
- package/utilities/getOperationRootType.d.ts +14 -0
- package/utilities/getOperationRootType.js.flow +2 -0
- package/utilities/index.d.ts +127 -0
- package/utilities/index.js +8 -0
- package/utilities/index.js.flow +4 -1
- package/utilities/index.mjs +3 -1
- package/utilities/introspectionFromSchema.d.ts +16 -0
- package/utilities/introspectionFromSchema.js +5 -3
- package/utilities/introspectionFromSchema.js.flow +4 -2
- package/utilities/introspectionFromSchema.mjs +4 -2
- package/utilities/introspectionQuery.d.ts +177 -0
- package/utilities/isValidJSValue.d.ts +8 -0
- package/utilities/isValidJSValue.js +1 -1
- package/utilities/isValidJSValue.js.flow +3 -2
- package/utilities/isValidJSValue.mjs +2 -2
- package/utilities/isValidLiteralValue.d.ts +15 -0
- package/utilities/isValidLiteralValue.js +4 -4
- package/utilities/isValidLiteralValue.js.flow +8 -4
- package/utilities/isValidLiteralValue.mjs +2 -2
- package/utilities/lexicographicSortSchema.d.ts +6 -0
- package/utilities/lexicographicSortSchema.js +11 -8
- package/utilities/lexicographicSortSchema.js.flow +5 -3
- package/utilities/lexicographicSortSchema.mjs +9 -7
- package/utilities/schemaPrinter.d.ts +30 -0
- package/utilities/schemaPrinter.js +15 -32
- package/utilities/schemaPrinter.js.flow +14 -10
- package/utilities/schemaPrinter.mjs +14 -32
- package/utilities/separateOperations.d.ts +11 -0
- package/utilities/separateOperations.js +6 -6
- package/utilities/separateOperations.js.flow +2 -1
- package/utilities/separateOperations.mjs +6 -6
- package/utilities/stripIgnoredCharacters.d.ts +55 -0
- package/utilities/stripIgnoredCharacters.js.flow +1 -0
- package/utilities/typeComparators.d.ts +32 -0
- package/utilities/typeComparators.js.flow +1 -1
- package/utilities/typeComparators.mjs +1 -1
- package/utilities/typeFromAST.d.ts +29 -0
- package/utilities/typeFromAST.js +5 -3
- package/utilities/typeFromAST.js.flow +5 -3
- package/utilities/typeFromAST.mjs +14 -3
- package/utilities/valueFromAST.d.ts +29 -0
- package/utilities/valueFromAST.js +40 -74
- package/utilities/valueFromAST.js.flow +7 -4
- package/utilities/valueFromAST.mjs +39 -74
- package/utilities/valueFromASTUntyped.d.ts +23 -0
- package/utilities/valueFromASTUntyped.js +4 -3
- package/utilities/valueFromASTUntyped.js.flow +3 -2
- package/utilities/valueFromASTUntyped.mjs +3 -3
- package/validation/ValidationContext.d.ts +96 -0
- package/validation/ValidationContext.js +38 -86
- package/validation/ValidationContext.js.flow +22 -7
- package/validation/ValidationContext.mjs +37 -85
- package/validation/index.d.ts +126 -0
- package/validation/rules/ExecutableDefinitions.d.ts +14 -0
- package/validation/rules/ExecutableDefinitions.js +4 -23
- package/validation/rules/ExecutableDefinitions.js.flow +4 -2
- package/validation/rules/ExecutableDefinitions.mjs +4 -23
- package/validation/rules/FieldsOnCorrectType.d.ts +17 -0
- package/validation/rules/FieldsOnCorrectType.js +21 -57
- package/validation/rules/FieldsOnCorrectType.js.flow +7 -3
- package/validation/rules/FieldsOnCorrectType.mjs +21 -57
- package/validation/rules/FragmentsOnCompositeTypes.d.ts +20 -0
- package/validation/rules/FragmentsOnCompositeTypes.js.flow +5 -1
- package/validation/rules/KnownArgumentNames.d.ts +28 -0
- package/validation/rules/KnownArgumentNames.js +26 -79
- package/validation/rules/KnownArgumentNames.js.flow +10 -6
- package/validation/rules/KnownArgumentNames.mjs +22 -75
- package/validation/rules/KnownDirectives.d.ts +19 -0
- package/validation/rules/KnownDirectives.js +12 -48
- package/validation/rules/KnownDirectives.js.flow +8 -5
- package/validation/rules/KnownDirectives.mjs +12 -48
- package/validation/rules/KnownFragmentNames.d.ts +12 -0
- package/validation/rules/KnownFragmentNames.js.flow +2 -1
- package/validation/rules/KnownTypeNames.d.ts +15 -0
- package/validation/rules/KnownTypeNames.js +6 -24
- package/validation/rules/KnownTypeNames.js.flow +10 -6
- package/validation/rules/KnownTypeNames.mjs +6 -24
- package/validation/rules/LoneAnonymousOperation.d.ts +14 -0
- package/validation/rules/LoneAnonymousOperation.js.flow +3 -1
- package/validation/rules/LoneSchemaDefinition.d.ts +13 -0
- package/validation/rules/LoneSchemaDefinition.js.flow +2 -1
- package/validation/rules/NoFragmentCycles.d.ts +9 -0
- package/validation/rules/NoFragmentCycles.js +17 -35
- package/validation/rules/NoFragmentCycles.js.flow +4 -2
- package/validation/rules/NoFragmentCycles.mjs +17 -35
- package/validation/rules/NoUndefinedVariables.d.ts +16 -0
- package/validation/rules/NoUndefinedVariables.js +6 -24
- package/validation/rules/NoUndefinedVariables.js.flow +2 -1
- package/validation/rules/NoUndefinedVariables.mjs +6 -24
- package/validation/rules/NoUnusedFragments.d.ts +12 -0
- package/validation/rules/NoUnusedFragments.js +7 -25
- package/validation/rules/NoUnusedFragments.js.flow +2 -1
- package/validation/rules/NoUnusedFragments.mjs +7 -25
- package/validation/rules/NoUnusedVariables.d.ts +16 -0
- package/validation/rules/NoUnusedVariables.js +6 -24
- package/validation/rules/NoUnusedVariables.js.flow +2 -1
- package/validation/rules/NoUnusedVariables.mjs +6 -24
- package/validation/rules/OverlappingFieldsCanBeMerged.d.ts +24 -0
- package/validation/rules/OverlappingFieldsCanBeMerged.js +27 -46
- package/validation/rules/OverlappingFieldsCanBeMerged.js.flow +17 -8
- package/validation/rules/OverlappingFieldsCanBeMerged.mjs +25 -44
- package/validation/rules/PossibleFragmentSpreads.d.ts +22 -0
- package/validation/rules/PossibleFragmentSpreads.js +2 -2
- package/validation/rules/PossibleFragmentSpreads.js.flow +8 -3
- package/validation/rules/PossibleFragmentSpreads.mjs +2 -2
- package/validation/rules/PossibleTypeExtensions.d.ts +21 -0
- package/validation/rules/PossibleTypeExtensions.js +4 -22
- package/validation/rules/PossibleTypeExtensions.js.flow +6 -2
- package/validation/rules/PossibleTypeExtensions.mjs +4 -22
- package/validation/rules/ProvidedRequiredArguments.d.ts +29 -0
- package/validation/rules/ProvidedRequiredArguments.js +27 -79
- package/validation/rules/ProvidedRequiredArguments.js.flow +12 -8
- package/validation/rules/ProvidedRequiredArguments.mjs +25 -77
- package/validation/rules/ScalarLeafs.d.ts +20 -0
- package/validation/rules/ScalarLeafs.js.flow +6 -2
- package/validation/rules/SingleFieldSubscriptions.d.ts +14 -0
- package/validation/rules/SingleFieldSubscriptions.js.flow +4 -2
- package/validation/rules/UniqueArgumentNames.d.ts +12 -0
- package/validation/rules/UniqueArgumentNames.js.flow +2 -1
- package/validation/rules/UniqueDirectiveNames.d.ts +13 -0
- package/validation/rules/UniqueDirectiveNames.js.flow +2 -1
- package/validation/rules/UniqueDirectivesPerLocation.d.ts +14 -0
- package/validation/rules/UniqueDirectivesPerLocation.js +15 -69
- package/validation/rules/UniqueDirectivesPerLocation.js.flow +7 -4
- package/validation/rules/UniqueDirectivesPerLocation.mjs +15 -69
- package/validation/rules/UniqueEnumValueNames.d.ts +19 -0
- package/validation/rules/UniqueEnumValueNames.js +10 -28
- package/validation/rules/UniqueEnumValueNames.js.flow +2 -1
- package/validation/rules/UniqueEnumValueNames.mjs +10 -28
- package/validation/rules/UniqueFieldDefinitionNames.d.ts +21 -0
- package/validation/rules/UniqueFieldDefinitionNames.js +9 -27
- package/validation/rules/UniqueFieldDefinitionNames.js.flow +2 -1
- package/validation/rules/UniqueFieldDefinitionNames.mjs +9 -27
- package/validation/rules/UniqueFragmentNames.d.ts +11 -0
- package/validation/rules/UniqueFragmentNames.js.flow +2 -1
- package/validation/rules/UniqueInputFieldNames.d.ts +14 -0
- package/validation/rules/UniqueInputFieldNames.js.flow +2 -1
- package/validation/rules/UniqueOperationNames.d.ts +11 -0
- package/validation/rules/UniqueOperationNames.js.flow +2 -1
- package/validation/rules/UniqueOperationTypes.d.ts +13 -0
- package/validation/rules/UniqueOperationTypes.js +11 -30
- package/validation/rules/UniqueOperationTypes.js.flow +2 -1
- package/validation/rules/UniqueOperationTypes.mjs +10 -29
- package/validation/rules/UniqueTypeNames.d.ts +13 -0
- package/validation/rules/UniqueTypeNames.js.flow +3 -1
- package/validation/rules/UniqueVariableNames.d.ts +11 -0
- package/validation/rules/UniqueVariableNames.js.flow +4 -2
- package/validation/rules/ValuesOfCorrectType.d.ts +34 -0
- package/validation/rules/ValuesOfCorrectType.js +16 -34
- package/validation/rules/ValuesOfCorrectType.js.flow +11 -6
- package/validation/rules/ValuesOfCorrectType.mjs +12 -30
- package/validation/rules/VariablesAreInputTypes.d.ts +15 -0
- package/validation/rules/VariablesAreInputTypes.js.flow +6 -2
- package/validation/rules/VariablesInAllowedPosition.d.ts +15 -0
- package/validation/rules/VariablesInAllowedPosition.js +22 -40
- package/validation/rules/VariablesInAllowedPosition.js.flow +8 -3
- package/validation/rules/VariablesInAllowedPosition.mjs +18 -36
- package/validation/specifiedRules.d.ts +98 -0
- package/validation/validate.d.ts +56 -0
- package/validation/validate.js +35 -7
- package/validation/validate.js.flow +51 -9
- package/validation/validate.mjs +30 -7
- package/version.d.ts +14 -0
- package/version.js +3 -3
- package/version.js.flow +3 -3
- package/version.mjs +3 -3
package/type/validate.mjs
CHANGED
|
@@ -2,14 +2,14 @@ import find from '../polyfills/find';
|
|
|
2
2
|
import flatMap from '../polyfills/flatMap';
|
|
3
3
|
import objectValues from '../polyfills/objectValues';
|
|
4
4
|
import objectEntries from '../polyfills/objectEntries';
|
|
5
|
-
import { isObjectType, isInterfaceType, isUnionType, isEnumType, isInputObjectType, isNamedType, isNonNullType, isInputType, isOutputType, isRequiredArgument } from './definition';
|
|
6
|
-
import { isDirective } from './directives';
|
|
7
|
-
import { isIntrospectionType } from './introspection';
|
|
8
|
-
import { assertSchema } from './schema';
|
|
9
5
|
import inspect from '../jsutils/inspect';
|
|
10
6
|
import { GraphQLError } from '../error/GraphQLError';
|
|
11
7
|
import { isValidNameError } from '../utilities/assertValidName';
|
|
12
8
|
import { isEqualType, isTypeSubTypeOf } from '../utilities/typeComparators';
|
|
9
|
+
import { isDirective } from './directives';
|
|
10
|
+
import { isIntrospectionType } from './introspection';
|
|
11
|
+
import { assertSchema } from './schema';
|
|
12
|
+
import { isObjectType, isInterfaceType, isUnionType, isEnumType, isInputObjectType, isNamedType, isNonNullType, isInputType, isOutputType, isRequiredArgument } from './definition';
|
|
13
13
|
/**
|
|
14
14
|
* Implements the "Type Validation" sub-sections of the specification's
|
|
15
15
|
* "Type System" section.
|
|
@@ -106,30 +106,12 @@ function getOperationTypeNode(schema, type, operation) {
|
|
|
106
106
|
var operationNodes = getAllSubNodes(schema, function (node) {
|
|
107
107
|
return node.operationTypes;
|
|
108
108
|
});
|
|
109
|
-
var _iteratorNormalCompletion = true;
|
|
110
|
-
var _didIteratorError = false;
|
|
111
|
-
var _iteratorError = undefined;
|
|
112
109
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
var node = _step.value;
|
|
110
|
+
for (var _i2 = 0; _i2 < operationNodes.length; _i2++) {
|
|
111
|
+
var node = operationNodes[_i2];
|
|
116
112
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
} catch (err) {
|
|
122
|
-
_didIteratorError = true;
|
|
123
|
-
_iteratorError = err;
|
|
124
|
-
} finally {
|
|
125
|
-
try {
|
|
126
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
127
|
-
_iterator.return();
|
|
128
|
-
}
|
|
129
|
-
} finally {
|
|
130
|
-
if (_didIteratorError) {
|
|
131
|
-
throw _iteratorError;
|
|
132
|
-
}
|
|
113
|
+
if (node.operation === operation) {
|
|
114
|
+
return node.type;
|
|
133
115
|
}
|
|
134
116
|
}
|
|
135
117
|
|
|
@@ -137,86 +119,49 @@ function getOperationTypeNode(schema, type, operation) {
|
|
|
137
119
|
}
|
|
138
120
|
|
|
139
121
|
function validateDirectives(context) {
|
|
140
|
-
var
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
var
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
if (argNames[argName]) {
|
|
171
|
-
context.reportError("Argument @".concat(directive.name, "(").concat(argName, ":) can only be defined once."), directive.astNode && directive.args.filter(function (_ref) {
|
|
172
|
-
var name = _ref.name;
|
|
173
|
-
return name === argName;
|
|
174
|
-
}).map(function (_ref2) {
|
|
175
|
-
var astNode = _ref2.astNode;
|
|
176
|
-
return astNode;
|
|
177
|
-
}));
|
|
178
|
-
return "continue";
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
argNames[argName] = true; // Ensure the type is an input type.
|
|
182
|
-
|
|
183
|
-
if (!isInputType(arg.type)) {
|
|
184
|
-
context.reportError("The type of @".concat(directive.name, "(").concat(argName, ":) must be Input Type ") + "but got: ".concat(inspect(arg.type), "."), arg.astNode);
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
for (var _iterator3 = directive.args[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
|
189
|
-
var _ret = _loop();
|
|
190
|
-
|
|
191
|
-
if (_ret === "continue") continue;
|
|
192
|
-
}
|
|
193
|
-
} catch (err) {
|
|
194
|
-
_didIteratorError3 = true;
|
|
195
|
-
_iteratorError3 = err;
|
|
196
|
-
} finally {
|
|
197
|
-
try {
|
|
198
|
-
if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
|
|
199
|
-
_iterator3.return();
|
|
200
|
-
}
|
|
201
|
-
} finally {
|
|
202
|
-
if (_didIteratorError3) {
|
|
203
|
-
throw _iteratorError3;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
} catch (err) {
|
|
209
|
-
_didIteratorError2 = true;
|
|
210
|
-
_iteratorError2 = err;
|
|
211
|
-
} finally {
|
|
212
|
-
try {
|
|
213
|
-
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
214
|
-
_iterator2.return();
|
|
122
|
+
for (var _i4 = 0, _context$schema$getDi2 = context.schema.getDirectives(); _i4 < _context$schema$getDi2.length; _i4++) {
|
|
123
|
+
var directive = _context$schema$getDi2[_i4];
|
|
124
|
+
|
|
125
|
+
// Ensure all directives are in fact GraphQL directives.
|
|
126
|
+
if (!isDirective(directive)) {
|
|
127
|
+
context.reportError("Expected directive but got: ".concat(inspect(directive), "."), directive && directive.astNode);
|
|
128
|
+
continue;
|
|
129
|
+
} // Ensure they are named correctly.
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
validateName(context, directive); // TODO: Ensure proper locations.
|
|
133
|
+
// Ensure the arguments are valid.
|
|
134
|
+
|
|
135
|
+
var argNames = Object.create(null);
|
|
136
|
+
|
|
137
|
+
var _loop = function _loop(_i6, _directive$args2) {
|
|
138
|
+
var arg = _directive$args2[_i6];
|
|
139
|
+
var argName = arg.name; // Ensure they are named correctly.
|
|
140
|
+
|
|
141
|
+
validateName(context, arg); // Ensure they are unique per directive.
|
|
142
|
+
|
|
143
|
+
if (argNames[argName]) {
|
|
144
|
+
context.reportError("Argument @".concat(directive.name, "(").concat(argName, ":) can only be defined once."), directive.astNode && directive.args.filter(function (_ref) {
|
|
145
|
+
var name = _ref.name;
|
|
146
|
+
return name === argName;
|
|
147
|
+
}).map(function (_ref2) {
|
|
148
|
+
var astNode = _ref2.astNode;
|
|
149
|
+
return astNode;
|
|
150
|
+
}));
|
|
151
|
+
return "continue";
|
|
215
152
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
153
|
+
|
|
154
|
+
argNames[argName] = true; // Ensure the type is an input type.
|
|
155
|
+
|
|
156
|
+
if (!isInputType(arg.type)) {
|
|
157
|
+
context.reportError("The type of @".concat(directive.name, "(").concat(argName, ":) must be Input Type ") + "but got: ".concat(inspect(arg.type), "."), arg.astNode);
|
|
219
158
|
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
for (var _i6 = 0, _directive$args2 = directive.args; _i6 < _directive$args2.length; _i6++) {
|
|
162
|
+
var _ret = _loop(_i6, _directive$args2);
|
|
163
|
+
|
|
164
|
+
if (_ret === "continue") continue;
|
|
220
165
|
}
|
|
221
166
|
}
|
|
222
167
|
}
|
|
@@ -239,58 +184,40 @@ function validateName(context, node) {
|
|
|
239
184
|
function validateTypes(context) {
|
|
240
185
|
var validateInputObjectCircularRefs = createInputObjectCircularRefsValidator(context);
|
|
241
186
|
var typeMap = context.schema.getTypeMap();
|
|
242
|
-
var _iteratorNormalCompletion4 = true;
|
|
243
|
-
var _didIteratorError4 = false;
|
|
244
|
-
var _iteratorError4 = undefined;
|
|
245
|
-
|
|
246
|
-
try {
|
|
247
|
-
for (var _iterator4 = objectValues(typeMap)[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
|
|
248
|
-
var type = _step4.value;
|
|
249
187
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
context.reportError("Expected GraphQL named type but got: ".concat(inspect(type), "."), type && type.astNode);
|
|
253
|
-
continue;
|
|
254
|
-
} // Ensure it is named correctly (excluding introspection types).
|
|
188
|
+
for (var _i8 = 0, _objectValues2 = objectValues(typeMap); _i8 < _objectValues2.length; _i8++) {
|
|
189
|
+
var type = _objectValues2[_i8];
|
|
255
190
|
|
|
191
|
+
// Ensure all provided types are in fact GraphQL type.
|
|
192
|
+
if (!isNamedType(type)) {
|
|
193
|
+
context.reportError("Expected GraphQL named type but got: ".concat(inspect(type), "."), type && type.astNode);
|
|
194
|
+
continue;
|
|
195
|
+
} // Ensure it is named correctly (excluding introspection types).
|
|
256
196
|
|
|
257
|
-
if (!isIntrospectionType(type)) {
|
|
258
|
-
validateName(context, type);
|
|
259
|
-
}
|
|
260
197
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
validateFields(context, type); // Ensure objects implement the interfaces they claim to.
|
|
264
|
-
|
|
265
|
-
validateObjectInterfaces(context, type);
|
|
266
|
-
} else if (isInterfaceType(type)) {
|
|
267
|
-
// Ensure fields are valid.
|
|
268
|
-
validateFields(context, type);
|
|
269
|
-
} else if (isUnionType(type)) {
|
|
270
|
-
// Ensure Unions include valid member types.
|
|
271
|
-
validateUnionMembers(context, type);
|
|
272
|
-
} else if (isEnumType(type)) {
|
|
273
|
-
// Ensure Enums have valid values.
|
|
274
|
-
validateEnumValues(context, type);
|
|
275
|
-
} else if (isInputObjectType(type)) {
|
|
276
|
-
// Ensure Input Object fields are valid.
|
|
277
|
-
validateInputFields(context, type); // Ensure Input Objects do not contain non-nullable circular references
|
|
278
|
-
|
|
279
|
-
validateInputObjectCircularRefs(type);
|
|
280
|
-
}
|
|
198
|
+
if (!isIntrospectionType(type)) {
|
|
199
|
+
validateName(context, type);
|
|
281
200
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
201
|
+
|
|
202
|
+
if (isObjectType(type)) {
|
|
203
|
+
// Ensure fields are valid
|
|
204
|
+
validateFields(context, type); // Ensure objects implement the interfaces they claim to.
|
|
205
|
+
|
|
206
|
+
validateObjectInterfaces(context, type);
|
|
207
|
+
} else if (isInterfaceType(type)) {
|
|
208
|
+
// Ensure fields are valid.
|
|
209
|
+
validateFields(context, type);
|
|
210
|
+
} else if (isUnionType(type)) {
|
|
211
|
+
// Ensure Unions include valid member types.
|
|
212
|
+
validateUnionMembers(context, type);
|
|
213
|
+
} else if (isEnumType(type)) {
|
|
214
|
+
// Ensure Enums have valid values.
|
|
215
|
+
validateEnumValues(context, type);
|
|
216
|
+
} else if (isInputObjectType(type)) {
|
|
217
|
+
// Ensure Input Object fields are valid.
|
|
218
|
+
validateInputFields(context, type); // Ensure Input Objects do not contain non-nullable circular references
|
|
219
|
+
|
|
220
|
+
validateInputObjectCircularRefs(type);
|
|
294
221
|
}
|
|
295
222
|
}
|
|
296
223
|
}
|
|
@@ -302,120 +229,65 @@ function validateFields(context, type) {
|
|
|
302
229
|
context.reportError("Type ".concat(type.name, " must define one or more fields."), getAllNodes(type));
|
|
303
230
|
}
|
|
304
231
|
|
|
305
|
-
var
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
try {
|
|
310
|
-
for (var _iterator5 = fields[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
|
|
311
|
-
var field = _step5.value;
|
|
312
|
-
// Ensure they are named correctly.
|
|
313
|
-
validateName(context, field); // Ensure the type is an output type
|
|
314
|
-
|
|
315
|
-
if (!isOutputType(field.type)) {
|
|
316
|
-
context.reportError("The type of ".concat(type.name, ".").concat(field.name, " must be Output Type ") + "but got: ".concat(inspect(field.type), "."), field.astNode && field.astNode.type);
|
|
317
|
-
} // Ensure the arguments are valid
|
|
232
|
+
for (var _i10 = 0; _i10 < fields.length; _i10++) {
|
|
233
|
+
var field = fields[_i10];
|
|
234
|
+
// Ensure they are named correctly.
|
|
235
|
+
validateName(context, field); // Ensure the type is an output type
|
|
318
236
|
|
|
237
|
+
if (!isOutputType(field.type)) {
|
|
238
|
+
context.reportError("The type of ".concat(type.name, ".").concat(field.name, " must be Output Type ") + "but got: ".concat(inspect(field.type), "."), field.astNode && field.astNode.type);
|
|
239
|
+
} // Ensure the arguments are valid
|
|
319
240
|
|
|
320
|
-
var argNames = Object.create(null);
|
|
321
|
-
var _iteratorNormalCompletion6 = true;
|
|
322
|
-
var _didIteratorError6 = false;
|
|
323
|
-
var _iteratorError6 = undefined;
|
|
324
241
|
|
|
325
|
-
|
|
326
|
-
var _loop2 = function _loop2() {
|
|
327
|
-
var arg = _step6.value;
|
|
328
|
-
var argName = arg.name; // Ensure they are named correctly.
|
|
242
|
+
var argNames = Object.create(null);
|
|
329
243
|
|
|
330
|
-
|
|
244
|
+
var _loop2 = function _loop2(_i12, _field$args2) {
|
|
245
|
+
var arg = _field$args2[_i12];
|
|
246
|
+
var argName = arg.name; // Ensure they are named correctly.
|
|
331
247
|
|
|
332
|
-
|
|
333
|
-
context.reportError("Field argument ".concat(type.name, ".").concat(field.name, "(").concat(argName, ":) can only be defined once."), field.args.filter(function (_ref3) {
|
|
334
|
-
var name = _ref3.name;
|
|
335
|
-
return name === argName;
|
|
336
|
-
}).map(function (_ref4) {
|
|
337
|
-
var astNode = _ref4.astNode;
|
|
338
|
-
return astNode;
|
|
339
|
-
}));
|
|
340
|
-
}
|
|
248
|
+
validateName(context, arg); // Ensure they are unique per field.
|
|
341
249
|
|
|
342
|
-
|
|
250
|
+
if (argNames[argName]) {
|
|
251
|
+
context.reportError("Field argument ".concat(type.name, ".").concat(field.name, "(").concat(argName, ":) can only be defined once."), field.args.filter(function (_ref3) {
|
|
252
|
+
var name = _ref3.name;
|
|
253
|
+
return name === argName;
|
|
254
|
+
}).map(function (_ref4) {
|
|
255
|
+
var astNode = _ref4.astNode;
|
|
256
|
+
return astNode;
|
|
257
|
+
}));
|
|
258
|
+
}
|
|
343
259
|
|
|
344
|
-
|
|
345
|
-
context.reportError("The type of ".concat(type.name, ".").concat(field.name, "(").concat(argName, ":) must be Input ") + "Type but got: ".concat(inspect(arg.type), "."), arg.astNode && arg.astNode.type);
|
|
346
|
-
}
|
|
347
|
-
};
|
|
260
|
+
argNames[argName] = true; // Ensure the type is an input type
|
|
348
261
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
}
|
|
352
|
-
} catch (err) {
|
|
353
|
-
_didIteratorError6 = true;
|
|
354
|
-
_iteratorError6 = err;
|
|
355
|
-
} finally {
|
|
356
|
-
try {
|
|
357
|
-
if (!_iteratorNormalCompletion6 && _iterator6.return != null) {
|
|
358
|
-
_iterator6.return();
|
|
359
|
-
}
|
|
360
|
-
} finally {
|
|
361
|
-
if (_didIteratorError6) {
|
|
362
|
-
throw _iteratorError6;
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
} catch (err) {
|
|
368
|
-
_didIteratorError5 = true;
|
|
369
|
-
_iteratorError5 = err;
|
|
370
|
-
} finally {
|
|
371
|
-
try {
|
|
372
|
-
if (!_iteratorNormalCompletion5 && _iterator5.return != null) {
|
|
373
|
-
_iterator5.return();
|
|
374
|
-
}
|
|
375
|
-
} finally {
|
|
376
|
-
if (_didIteratorError5) {
|
|
377
|
-
throw _iteratorError5;
|
|
262
|
+
if (!isInputType(arg.type)) {
|
|
263
|
+
context.reportError("The type of ".concat(type.name, ".").concat(field.name, "(").concat(argName, ":) must be Input ") + "Type but got: ".concat(inspect(arg.type), "."), arg.astNode && arg.astNode.type);
|
|
378
264
|
}
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
for (var _i12 = 0, _field$args2 = field.args; _i12 < _field$args2.length; _i12++) {
|
|
268
|
+
_loop2(_i12, _field$args2);
|
|
379
269
|
}
|
|
380
270
|
}
|
|
381
271
|
}
|
|
382
272
|
|
|
383
273
|
function validateObjectInterfaces(context, object) {
|
|
384
274
|
var implementedTypeNames = Object.create(null);
|
|
385
|
-
var _iteratorNormalCompletion7 = true;
|
|
386
|
-
var _didIteratorError7 = false;
|
|
387
|
-
var _iteratorError7 = undefined;
|
|
388
|
-
|
|
389
|
-
try {
|
|
390
|
-
for (var _iterator7 = object.getInterfaces()[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) {
|
|
391
|
-
var iface = _step7.value;
|
|
392
275
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
continue;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
if (implementedTypeNames[iface.name]) {
|
|
399
|
-
context.reportError("Type ".concat(object.name, " can only implement ").concat(iface.name, " once."), getAllImplementsInterfaceNodes(object, iface));
|
|
400
|
-
continue;
|
|
401
|
-
}
|
|
276
|
+
for (var _i14 = 0, _object$getInterfaces2 = object.getInterfaces(); _i14 < _object$getInterfaces2.length; _i14++) {
|
|
277
|
+
var iface = _object$getInterfaces2[_i14];
|
|
402
278
|
|
|
403
|
-
|
|
404
|
-
|
|
279
|
+
if (!isInterfaceType(iface)) {
|
|
280
|
+
context.reportError("Type ".concat(inspect(object), " must only implement Interface types, ") + "it cannot implement ".concat(inspect(iface), "."), getAllImplementsInterfaceNodes(object, iface));
|
|
281
|
+
continue;
|
|
405
282
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
try {
|
|
411
|
-
if (!_iteratorNormalCompletion7 && _iterator7.return != null) {
|
|
412
|
-
_iterator7.return();
|
|
413
|
-
}
|
|
414
|
-
} finally {
|
|
415
|
-
if (_didIteratorError7) {
|
|
416
|
-
throw _iteratorError7;
|
|
417
|
-
}
|
|
283
|
+
|
|
284
|
+
if (implementedTypeNames[iface.name]) {
|
|
285
|
+
context.reportError("Type ".concat(object.name, " can only implement ").concat(iface.name, " once."), getAllImplementsInterfaceNodes(object, iface));
|
|
286
|
+
continue;
|
|
418
287
|
}
|
|
288
|
+
|
|
289
|
+
implementedTypeNames[iface.name] = true;
|
|
290
|
+
validateObjectImplementsInterface(context, object, iface);
|
|
419
291
|
}
|
|
420
292
|
}
|
|
421
293
|
|
|
@@ -423,123 +295,66 @@ function validateObjectImplementsInterface(context, object, iface) {
|
|
|
423
295
|
var objectFieldMap = object.getFields();
|
|
424
296
|
var ifaceFieldMap = iface.getFields(); // Assert each interface field is implemented.
|
|
425
297
|
|
|
426
|
-
var
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
for (var _iterator8 = objectEntries(ifaceFieldMap)[Symbol.iterator](), _step8; !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) {
|
|
432
|
-
var _ref6 = _step8.value;
|
|
433
|
-
var fieldName = _ref6[0];
|
|
434
|
-
var ifaceField = _ref6[1];
|
|
435
|
-
var objectField = objectFieldMap[fieldName]; // Assert interface field exists on object.
|
|
436
|
-
|
|
437
|
-
if (!objectField) {
|
|
438
|
-
context.reportError("Interface field ".concat(iface.name, ".").concat(fieldName, " expected but ").concat(object.name, " does not provide it."), [ifaceField.astNode].concat(getAllNodes(object)));
|
|
439
|
-
continue;
|
|
440
|
-
} // Assert interface field type is satisfied by object field type, by being
|
|
441
|
-
// a valid subtype. (covariant)
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
if (!isTypeSubTypeOf(context.schema, objectField.type, ifaceField.type)) {
|
|
445
|
-
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), "."), [ifaceField.astNode && ifaceField.astNode.type, objectField.astNode && objectField.astNode.type]);
|
|
446
|
-
} // Assert each interface field arg is implemented.
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
var _iteratorNormalCompletion9 = true;
|
|
450
|
-
var _didIteratorError9 = false;
|
|
451
|
-
var _iteratorError9 = undefined;
|
|
452
|
-
|
|
453
|
-
try {
|
|
454
|
-
var _loop3 = function _loop3() {
|
|
455
|
-
var ifaceArg = _step9.value;
|
|
456
|
-
var argName = ifaceArg.name;
|
|
457
|
-
var objectArg = find(objectField.args, function (arg) {
|
|
458
|
-
return arg.name === argName;
|
|
459
|
-
}); // Assert interface field arg exists on object field.
|
|
460
|
-
|
|
461
|
-
if (!objectArg) {
|
|
462
|
-
context.reportError("Interface field argument ".concat(iface.name, ".").concat(fieldName, "(").concat(argName, ":) expected but ").concat(object.name, ".").concat(fieldName, " does not provide it."), [ifaceArg.astNode, objectField.astNode]);
|
|
463
|
-
return "continue";
|
|
464
|
-
} // Assert interface field arg type matches object field arg type.
|
|
465
|
-
// (invariant)
|
|
466
|
-
// TODO: change to contravariant?
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
if (!isEqualType(ifaceArg.type, objectArg.type)) {
|
|
470
|
-
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), "."), [ifaceArg.astNode && ifaceArg.astNode.type, objectArg.astNode && objectArg.astNode.type]);
|
|
471
|
-
} // TODO: validate default values?
|
|
472
|
-
|
|
473
|
-
};
|
|
474
|
-
|
|
475
|
-
for (var _iterator9 = ifaceField.args[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) {
|
|
476
|
-
var _ret2 = _loop3();
|
|
477
|
-
|
|
478
|
-
if (_ret2 === "continue") continue;
|
|
479
|
-
} // Assert additional arguments must not be required.
|
|
480
|
-
|
|
481
|
-
} catch (err) {
|
|
482
|
-
_didIteratorError9 = true;
|
|
483
|
-
_iteratorError9 = err;
|
|
484
|
-
} finally {
|
|
485
|
-
try {
|
|
486
|
-
if (!_iteratorNormalCompletion9 && _iterator9.return != null) {
|
|
487
|
-
_iterator9.return();
|
|
488
|
-
}
|
|
489
|
-
} finally {
|
|
490
|
-
if (_didIteratorError9) {
|
|
491
|
-
throw _iteratorError9;
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
}
|
|
298
|
+
for (var _i16 = 0, _objectEntries2 = objectEntries(ifaceFieldMap); _i16 < _objectEntries2.length; _i16++) {
|
|
299
|
+
var _ref6 = _objectEntries2[_i16];
|
|
300
|
+
var fieldName = _ref6[0];
|
|
301
|
+
var ifaceField = _ref6[1];
|
|
302
|
+
var objectField = objectFieldMap[fieldName]; // Assert interface field exists on object.
|
|
495
303
|
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
304
|
+
if (!objectField) {
|
|
305
|
+
context.reportError("Interface field ".concat(iface.name, ".").concat(fieldName, " expected but ").concat(object.name, " does not provide it."), [ifaceField.astNode].concat(getAllNodes(object)));
|
|
306
|
+
continue;
|
|
307
|
+
} // Assert interface field type is satisfied by object field type, by being
|
|
308
|
+
// a valid subtype. (covariant)
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
if (!isTypeSubTypeOf(context.schema, objectField.type, ifaceField.type)) {
|
|
312
|
+
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), "."), [ifaceField.astNode && ifaceField.astNode.type, objectField.astNode && objectField.astNode.type]);
|
|
313
|
+
} // Assert each interface field arg is implemented.
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
var _loop3 = function _loop3(_i18, _ifaceField$args2) {
|
|
317
|
+
var ifaceArg = _ifaceField$args2[_i18];
|
|
318
|
+
var argName = ifaceArg.name;
|
|
319
|
+
var objectArg = find(objectField.args, function (arg) {
|
|
320
|
+
return arg.name === argName;
|
|
321
|
+
}); // Assert interface field arg exists on object field.
|
|
322
|
+
|
|
323
|
+
if (!objectArg) {
|
|
324
|
+
context.reportError("Interface field argument ".concat(iface.name, ".").concat(fieldName, "(").concat(argName, ":) expected but ").concat(object.name, ".").concat(fieldName, " does not provide it."), [ifaceArg.astNode, objectField.astNode]);
|
|
325
|
+
return "continue";
|
|
326
|
+
} // Assert interface field arg type matches object field arg type.
|
|
327
|
+
// (invariant)
|
|
328
|
+
// TODO: change to contravariant?
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
if (!isEqualType(ifaceArg.type, objectArg.type)) {
|
|
332
|
+
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), "."), [ifaceArg.astNode && ifaceArg.astNode.type, objectArg.astNode && objectArg.astNode.type]);
|
|
333
|
+
} // TODO: validate default values?
|
|
334
|
+
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
for (var _i18 = 0, _ifaceField$args2 = ifaceField.args; _i18 < _ifaceField$args2.length; _i18++) {
|
|
338
|
+
var _ret2 = _loop3(_i18, _ifaceField$args2);
|
|
339
|
+
|
|
340
|
+
if (_ret2 === "continue") continue;
|
|
341
|
+
} // Assert additional arguments must not be required.
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
var _loop4 = function _loop4(_i20, _objectField$args2) {
|
|
345
|
+
var objectArg = _objectField$args2[_i20];
|
|
346
|
+
var argName = objectArg.name;
|
|
347
|
+
var ifaceArg = find(ifaceField.args, function (arg) {
|
|
348
|
+
return arg.name === argName;
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
if (!ifaceArg && isRequiredArgument(objectArg)) {
|
|
352
|
+
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, "."), [objectArg.astNode, ifaceField.astNode]);
|
|
542
353
|
}
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
for (var _i20 = 0, _objectField$args2 = objectField.args; _i20 < _objectField$args2.length; _i20++) {
|
|
357
|
+
_loop4(_i20, _objectField$args2);
|
|
543
358
|
}
|
|
544
359
|
}
|
|
545
360
|
}
|
|
@@ -552,37 +367,19 @@ function validateUnionMembers(context, union) {
|
|
|
552
367
|
}
|
|
553
368
|
|
|
554
369
|
var includedTypeNames = Object.create(null);
|
|
555
|
-
var _iteratorNormalCompletion11 = true;
|
|
556
|
-
var _didIteratorError11 = false;
|
|
557
|
-
var _iteratorError11 = undefined;
|
|
558
370
|
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
var memberType = _step11.value;
|
|
371
|
+
for (var _i22 = 0; _i22 < memberTypes.length; _i22++) {
|
|
372
|
+
var memberType = memberTypes[_i22];
|
|
562
373
|
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
374
|
+
if (includedTypeNames[memberType.name]) {
|
|
375
|
+
context.reportError("Union type ".concat(union.name, " can only include type ").concat(memberType.name, " once."), getUnionMemberTypeNodes(union, memberType.name));
|
|
376
|
+
continue;
|
|
377
|
+
}
|
|
567
378
|
|
|
568
|
-
|
|
379
|
+
includedTypeNames[memberType.name] = true;
|
|
569
380
|
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
} catch (err) {
|
|
575
|
-
_didIteratorError11 = true;
|
|
576
|
-
_iteratorError11 = err;
|
|
577
|
-
} finally {
|
|
578
|
-
try {
|
|
579
|
-
if (!_iteratorNormalCompletion11 && _iterator11.return != null) {
|
|
580
|
-
_iterator11.return();
|
|
581
|
-
}
|
|
582
|
-
} finally {
|
|
583
|
-
if (_didIteratorError11) {
|
|
584
|
-
throw _iteratorError11;
|
|
585
|
-
}
|
|
381
|
+
if (!isObjectType(memberType)) {
|
|
382
|
+
context.reportError("Union type ".concat(union.name, " can only include Object types, ") + "it cannot include ".concat(inspect(memberType), "."), getUnionMemberTypeNodes(union, String(memberType)));
|
|
586
383
|
}
|
|
587
384
|
}
|
|
588
385
|
}
|
|
@@ -594,33 +391,14 @@ function validateEnumValues(context, enumType) {
|
|
|
594
391
|
context.reportError("Enum type ".concat(enumType.name, " must define one or more values."), getAllNodes(enumType));
|
|
595
392
|
}
|
|
596
393
|
|
|
597
|
-
var
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
try {
|
|
602
|
-
for (var _iterator12 = enumValues[Symbol.iterator](), _step12; !(_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done); _iteratorNormalCompletion12 = true) {
|
|
603
|
-
var enumValue = _step12.value;
|
|
604
|
-
var valueName = enumValue.name; // Ensure valid name.
|
|
394
|
+
for (var _i24 = 0; _i24 < enumValues.length; _i24++) {
|
|
395
|
+
var enumValue = enumValues[_i24];
|
|
396
|
+
var valueName = enumValue.name; // Ensure valid name.
|
|
605
397
|
|
|
606
|
-
|
|
398
|
+
validateName(context, enumValue);
|
|
607
399
|
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
} catch (err) {
|
|
613
|
-
_didIteratorError12 = true;
|
|
614
|
-
_iteratorError12 = err;
|
|
615
|
-
} finally {
|
|
616
|
-
try {
|
|
617
|
-
if (!_iteratorNormalCompletion12 && _iterator12.return != null) {
|
|
618
|
-
_iterator12.return();
|
|
619
|
-
}
|
|
620
|
-
} finally {
|
|
621
|
-
if (_didIteratorError12) {
|
|
622
|
-
throw _iteratorError12;
|
|
623
|
-
}
|
|
400
|
+
if (valueName === 'true' || valueName === 'false' || valueName === 'null') {
|
|
401
|
+
context.reportError("Enum type ".concat(enumType.name, " cannot include value: ").concat(valueName, "."), enumValue.astNode);
|
|
624
402
|
}
|
|
625
403
|
}
|
|
626
404
|
}
|
|
@@ -633,32 +411,13 @@ function validateInputFields(context, inputObj) {
|
|
|
633
411
|
} // Ensure the arguments are valid
|
|
634
412
|
|
|
635
413
|
|
|
636
|
-
var
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
try {
|
|
641
|
-
for (var _iterator13 = fields[Symbol.iterator](), _step13; !(_iteratorNormalCompletion13 = (_step13 = _iterator13.next()).done); _iteratorNormalCompletion13 = true) {
|
|
642
|
-
var field = _step13.value;
|
|
643
|
-
// Ensure they are named correctly.
|
|
644
|
-
validateName(context, field); // Ensure the type is an input type
|
|
414
|
+
for (var _i26 = 0; _i26 < fields.length; _i26++) {
|
|
415
|
+
var field = fields[_i26];
|
|
416
|
+
// Ensure they are named correctly.
|
|
417
|
+
validateName(context, field); // Ensure the type is an input type
|
|
645
418
|
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
} catch (err) {
|
|
651
|
-
_didIteratorError13 = true;
|
|
652
|
-
_iteratorError13 = err;
|
|
653
|
-
} finally {
|
|
654
|
-
try {
|
|
655
|
-
if (!_iteratorNormalCompletion13 && _iterator13.return != null) {
|
|
656
|
-
_iterator13.return();
|
|
657
|
-
}
|
|
658
|
-
} finally {
|
|
659
|
-
if (_didIteratorError13) {
|
|
660
|
-
throw _iteratorError13;
|
|
661
|
-
}
|
|
419
|
+
if (!isInputType(field.type)) {
|
|
420
|
+
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);
|
|
662
421
|
}
|
|
663
422
|
}
|
|
664
423
|
}
|
|
@@ -684,46 +443,28 @@ function createInputObjectCircularRefsValidator(context) {
|
|
|
684
443
|
visitedTypes[inputObj.name] = true;
|
|
685
444
|
fieldPathIndexByTypeName[inputObj.name] = fieldPath.length;
|
|
686
445
|
var fields = objectValues(inputObj.getFields());
|
|
687
|
-
|
|
688
|
-
var
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
var
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
}).join('.');
|
|
707
|
-
context.reportError("Cannot reference Input Object \"".concat(fieldType.name, "\" within itself through a series of non-null fields: \"").concat(pathStr, "\"."), cyclePath.map(function (fieldObj) {
|
|
708
|
-
return fieldObj.astNode;
|
|
709
|
-
}));
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
fieldPath.pop();
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
} catch (err) {
|
|
716
|
-
_didIteratorError14 = true;
|
|
717
|
-
_iteratorError14 = err;
|
|
718
|
-
} finally {
|
|
719
|
-
try {
|
|
720
|
-
if (!_iteratorNormalCompletion14 && _iterator14.return != null) {
|
|
721
|
-
_iterator14.return();
|
|
722
|
-
}
|
|
723
|
-
} finally {
|
|
724
|
-
if (_didIteratorError14) {
|
|
725
|
-
throw _iteratorError14;
|
|
446
|
+
|
|
447
|
+
for (var _i28 = 0; _i28 < fields.length; _i28++) {
|
|
448
|
+
var field = fields[_i28];
|
|
449
|
+
|
|
450
|
+
if (isNonNullType(field.type) && isInputObjectType(field.type.ofType)) {
|
|
451
|
+
var fieldType = field.type.ofType;
|
|
452
|
+
var cycleIndex = fieldPathIndexByTypeName[fieldType.name];
|
|
453
|
+
fieldPath.push(field);
|
|
454
|
+
|
|
455
|
+
if (cycleIndex === undefined) {
|
|
456
|
+
detectCycleRecursive(fieldType);
|
|
457
|
+
} else {
|
|
458
|
+
var cyclePath = fieldPath.slice(cycleIndex);
|
|
459
|
+
var pathStr = cyclePath.map(function (fieldObj) {
|
|
460
|
+
return fieldObj.name;
|
|
461
|
+
}).join('.');
|
|
462
|
+
context.reportError("Cannot reference Input Object \"".concat(fieldType.name, "\" within itself through a series of non-null fields: \"").concat(pathStr, "\"."), cyclePath.map(function (fieldObj) {
|
|
463
|
+
return fieldObj.astNode;
|
|
464
|
+
}));
|
|
726
465
|
}
|
|
466
|
+
|
|
467
|
+
fieldPath.pop();
|
|
727
468
|
}
|
|
728
469
|
}
|
|
729
470
|
|