graphql 15.1.0 → 15.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +10 -12
- package/error/GraphQLError.js +5 -5
- package/error/GraphQLError.js.flow +5 -5
- package/error/GraphQLError.mjs +1 -1
- package/error/formatError.js +1 -1
- package/error/formatError.js.flow +2 -3
- package/error/index.js +4 -4
- package/error/index.js.flow +0 -1
- package/error/locatedError.d.ts +2 -2
- package/error/locatedError.js +10 -5
- package/error/locatedError.js.flow +11 -5
- package/error/locatedError.mjs +6 -4
- package/error/syntaxError.js +1 -1
- package/error/syntaxError.js.flow +1 -2
- package/execution/execute.d.ts +24 -16
- package/execution/execute.js +123 -105
- package/execution/execute.js.flow +169 -153
- package/execution/execute.mjs +101 -82
- package/execution/index.d.ts +2 -0
- package/execution/index.js +9 -3
- package/execution/index.js.flow +12 -3
- package/execution/index.mjs +1 -1
- package/execution/values.js +11 -11
- package/execution/values.js.flow +10 -14
- package/graphql.js +5 -5
- package/graphql.js.flow +9 -9
- package/index.d.ts +19 -1
- package/index.js +27 -9
- package/index.js.flow +10 -3
- package/index.mjs +4 -3
- package/jsutils/ObjMap.js.flow +0 -1
- package/jsutils/Path.d.ts +6 -1
- package/jsutils/Path.js +3 -2
- package/jsutils/Path.js.flow +3 -2
- package/jsutils/Path.mjs +3 -2
- package/jsutils/PromiseOrValue.js.flow +0 -1
- package/jsutils/defineInspect.js +2 -2
- package/jsutils/defineInspect.js.flow +0 -1
- package/jsutils/devAssert.js.flow +0 -1
- package/jsutils/didYouMean.js.flow +0 -1
- package/jsutils/identityFunc.js.flow +0 -1
- package/jsutils/inspect.js +1 -2
- package/jsutils/inspect.js.flow +10 -8
- package/jsutils/inspect.mjs +1 -1
- package/jsutils/instanceOf.js.flow +2 -3
- package/jsutils/invariant.js.flow +0 -1
- package/jsutils/isAsyncIterable.js +19 -0
- package/jsutils/isAsyncIterable.js.flow +18 -0
- package/jsutils/isAsyncIterable.mjs +16 -0
- package/jsutils/isCollection.js +1 -1
- package/jsutils/isCollection.js.flow +0 -1
- package/jsutils/isObjectLike.js.flow +0 -1
- package/jsutils/isPromise.js.flow +0 -1
- package/jsutils/keyMap.js.flow +1 -2
- package/jsutils/keyValMap.js.flow +1 -2
- package/jsutils/mapValue.js +1 -1
- package/jsutils/mapValue.js.flow +1 -2
- package/jsutils/memoize3.js +2 -5
- package/jsutils/memoize3.js.flow +2 -5
- package/jsutils/memoize3.mjs +2 -5
- package/jsutils/nodejsCustomInspectSymbol.js.flow +0 -1
- package/jsutils/printPathArray.js.flow +0 -1
- package/jsutils/promiseForObject.js.flow +1 -2
- package/jsutils/promiseReduce.js +1 -1
- package/jsutils/promiseReduce.js.flow +1 -1
- package/jsutils/promiseReduce.mjs +1 -1
- package/jsutils/suggestionList.js.flow +1 -2
- package/jsutils/toObjMap.js +1 -1
- package/jsutils/toObjMap.js.flow +5 -6
- package/language/ast.js +1 -1
- package/language/ast.js.flow +2 -3
- package/language/blockString.d.ts +1 -1
- package/language/blockString.js +53 -32
- package/language/blockString.js.flow +49 -34
- package/language/blockString.mjs +54 -33
- package/language/directiveLocation.js.flow +0 -1
- package/language/experimentalOnlineParser/grammar.d.ts +1006 -0
- package/language/experimentalOnlineParser/grammar.js +987 -0
- package/language/experimentalOnlineParser/grammar.js.flow +1000 -0
- package/language/experimentalOnlineParser/grammar.mjs +980 -0
- package/language/experimentalOnlineParser/index.d.ts +6 -0
- package/language/experimentalOnlineParser/index.js +31 -0
- package/language/experimentalOnlineParser/index.js.flow +7 -0
- package/language/experimentalOnlineParser/index.mjs +1 -0
- package/language/experimentalOnlineParser/onlineParser.d.ts +125 -0
- package/language/experimentalOnlineParser/onlineParser.js +604 -0
- package/language/experimentalOnlineParser/onlineParser.js.flow +723 -0
- package/language/experimentalOnlineParser/onlineParser.mjs +587 -0
- package/language/index.js +12 -12
- package/language/index.js.flow +0 -1
- package/language/kinds.js.flow +0 -1
- package/language/lexer.js +242 -183
- package/language/lexer.js.flow +191 -186
- package/language/lexer.mjs +239 -180
- package/language/location.js.flow +1 -2
- package/language/parser.js +73 -68
- package/language/parser.js.flow +112 -106
- package/language/parser.mjs +66 -62
- package/language/predicates.js +1 -1
- package/language/predicates.js.flow +1 -2
- package/language/printLocation.js +1 -1
- package/language/printLocation.js.flow +4 -4
- package/language/printer.js +20 -13
- package/language/printer.js.flow +27 -25
- package/language/printer.mjs +18 -11
- package/language/source.d.ts +12 -6
- package/language/source.js +25 -9
- package/language/source.js.flow +25 -8
- package/language/source.mjs +19 -7
- package/language/tokenKind.js.flow +0 -1
- package/language/visitor.d.ts +3 -3
- package/language/visitor.js +5 -5
- package/language/visitor.js.flow +5 -5
- package/language/visitor.mjs +3 -3
- package/package.json +1 -1
- package/polyfills/arrayFrom.js +2 -2
- package/polyfills/arrayFrom.js.flow +1 -2
- package/polyfills/arrayFrom.mjs +1 -1
- package/polyfills/find.js +1 -1
- package/polyfills/find.js.flow +1 -2
- package/polyfills/find.mjs +1 -1
- package/polyfills/isFinite.js +1 -1
- package/polyfills/isFinite.js.flow +1 -2
- package/polyfills/isFinite.mjs +1 -1
- package/polyfills/isInteger.js +1 -1
- package/polyfills/isInteger.js.flow +1 -2
- package/polyfills/isInteger.mjs +1 -1
- package/polyfills/objectEntries.js +1 -1
- package/polyfills/objectEntries.js.flow +2 -3
- package/polyfills/objectEntries.mjs +1 -1
- package/polyfills/objectValues.js +1 -1
- package/polyfills/objectValues.js.flow +2 -3
- package/polyfills/objectValues.mjs +1 -1
- package/polyfills/symbols.js +3 -5
- package/polyfills/symbols.js.flow +9 -6
- package/polyfills/symbols.mjs +3 -5
- package/subscription/index.js +1 -1
- package/subscription/index.js.flow +0 -1
- package/subscription/mapAsyncIterator.js +2 -2
- package/subscription/mapAsyncIterator.js.flow +9 -10
- package/subscription/mapAsyncIterator.mjs +1 -1
- package/subscription/subscribe.js +61 -73
- package/subscription/subscribe.js.flow +74 -88
- package/subscription/subscribe.mjs +53 -65
- package/type/definition.d.ts +181 -31
- package/type/definition.js +37 -32
- package/type/definition.js.flow +66 -51
- package/type/definition.mjs +20 -18
- package/type/directives.d.ts +17 -3
- package/type/directives.js +17 -16
- package/type/directives.js.flow +20 -21
- package/type/directives.mjs +6 -5
- package/type/index.d.ts +12 -0
- package/type/index.js +6 -6
- package/type/index.js.flow +0 -1
- package/type/introspection.js +86 -68
- package/type/introspection.js.flow +85 -54
- package/type/introspection.mjs +79 -61
- package/type/scalars.js +9 -9
- package/type/scalars.js.flow +3 -3
- package/type/scalars.mjs +1 -1
- package/type/schema.d.ts +17 -4
- package/type/schema.js +13 -13
- package/type/schema.js.flow +18 -16
- package/type/schema.mjs +1 -1
- package/type/validate.js +52 -19
- package/type/validate.js.flow +67 -18
- package/type/validate.mjs +44 -10
- package/utilities/TypeInfo.js +7 -7
- package/utilities/TypeInfo.js.flow +16 -18
- package/utilities/TypeInfo.mjs +1 -1
- package/utilities/assertValidName.js +2 -2
- package/utilities/assertValidName.js.flow +0 -1
- package/utilities/astFromValue.js +10 -10
- package/utilities/astFromValue.js.flow +2 -3
- package/utilities/buildASTSchema.js +17 -27
- package/utilities/buildASTSchema.js.flow +11 -28
- package/utilities/buildASTSchema.mjs +11 -21
- package/utilities/buildClientSchema.js +14 -14
- package/utilities/buildClientSchema.js.flow +41 -29
- package/utilities/buildClientSchema.mjs +5 -5
- package/utilities/coerceInputValue.js +14 -14
- package/utilities/coerceInputValue.js.flow +7 -6
- package/utilities/coerceInputValue.mjs +2 -2
- package/utilities/concatAST.js +9 -8
- package/utilities/concatAST.js.flow +9 -9
- package/utilities/concatAST.mjs +9 -6
- package/utilities/extendSchema.js +26 -19
- package/utilities/extendSchema.js.flow +58 -45
- package/utilities/extendSchema.mjs +9 -2
- package/utilities/findBreakingChanges.js +9 -9
- package/utilities/findBreakingChanges.js.flow +12 -11
- package/utilities/findDeprecatedUsages.d.ts +9 -1
- package/utilities/findDeprecatedUsages.js +11 -27
- package/utilities/findDeprecatedUsages.js.flow +15 -44
- package/utilities/findDeprecatedUsages.mjs +11 -25
- package/utilities/getIntrospectionQuery.js.flow +2 -3
- package/utilities/getOperationAST.js +1 -1
- package/utilities/getOperationAST.js.flow +1 -5
- package/utilities/getOperationAST.mjs +1 -1
- package/utilities/getOperationRootType.js +1 -1
- package/utilities/getOperationRootType.js.flow +5 -6
- package/utilities/index.d.ts +4 -1
- package/utilities/index.js +22 -22
- package/utilities/index.js.flow +1 -2
- package/utilities/index.mjs +1 -1
- package/utilities/introspectionFromSchema.js +6 -8
- package/utilities/introspectionFromSchema.js.flow +10 -10
- package/utilities/introspectionFromSchema.mjs +3 -4
- package/utilities/lexicographicSortSchema.js +10 -8
- package/utilities/lexicographicSortSchema.js.flow +19 -12
- package/utilities/lexicographicSortSchema.mjs +3 -1
- package/utilities/printSchema.js +15 -16
- package/utilities/printSchema.js.flow +34 -25
- package/utilities/printSchema.mjs +6 -7
- package/utilities/separateOperations.js +2 -2
- package/utilities/separateOperations.js.flow +2 -6
- package/utilities/separateOperations.mjs +1 -1
- package/utilities/stripIgnoredCharacters.js +6 -16
- package/utilities/stripIgnoredCharacters.js.flow +4 -13
- package/utilities/stripIgnoredCharacters.mjs +3 -10
- package/utilities/typeComparators.js +1 -1
- package/utilities/typeComparators.js.flow +2 -4
- package/utilities/typeFromAST.js +6 -6
- package/utilities/typeFromAST.js.flow +11 -14
- package/utilities/typeFromAST.mjs +2 -2
- package/utilities/typedQueryDocumentNode.d.ts +20 -0
- package/utilities/valueFromAST.js +6 -6
- package/utilities/valueFromAST.js.flow +7 -5
- package/utilities/valueFromASTUntyped.js +4 -4
- package/utilities/valueFromASTUntyped.js.flow +2 -3
- package/validation/ValidationContext.d.ts +3 -0
- package/validation/ValidationContext.js +7 -3
- package/validation/ValidationContext.js.flow +28 -22
- package/validation/ValidationContext.mjs +4 -0
- package/validation/index.d.ts +4 -0
- package/validation/index.js +52 -36
- package/validation/index.js.flow +4 -1
- package/validation/index.mjs +4 -1
- package/validation/rules/ExecutableDefinitions.js +1 -1
- package/validation/rules/ExecutableDefinitions.js.flow +0 -1
- package/validation/rules/ExecutableDefinitionsRule.js +3 -3
- package/validation/rules/ExecutableDefinitionsRule.js.flow +2 -3
- package/validation/rules/FieldsOnCorrectTypeRule.js +5 -5
- package/validation/rules/FieldsOnCorrectTypeRule.js.flow +9 -8
- package/validation/rules/FragmentsOnCompositeTypesRule.js +4 -4
- package/validation/rules/FragmentsOnCompositeTypesRule.js.flow +2 -3
- package/validation/rules/KnownArgumentNamesRule.js +5 -5
- package/validation/rules/KnownArgumentNamesRule.js.flow +5 -5
- package/validation/rules/KnownDirectivesRule.js +6 -6
- package/validation/rules/KnownDirectivesRule.js.flow +10 -11
- package/validation/rules/KnownFragmentNamesRule.js +1 -1
- package/validation/rules/KnownFragmentNamesRule.js.flow +3 -3
- package/validation/rules/KnownTypeNamesRule.js +12 -10
- package/validation/rules/KnownTypeNamesRule.js.flow +14 -11
- package/validation/rules/KnownTypeNamesRule.mjs +6 -5
- package/validation/rules/LoneAnonymousOperationRule.js +2 -2
- package/validation/rules/LoneAnonymousOperationRule.js.flow +2 -3
- package/validation/rules/LoneSchemaDefinition.js +1 -1
- package/validation/rules/LoneSchemaDefinition.js.flow +0 -1
- package/validation/rules/LoneSchemaDefinitionRule.js +1 -1
- package/validation/rules/LoneSchemaDefinitionRule.js.flow +2 -3
- package/validation/rules/NoFragmentCyclesRule.js +1 -1
- package/validation/rules/NoFragmentCyclesRule.js.flow +4 -5
- package/validation/rules/NoUndefinedVariablesRule.js +1 -1
- package/validation/rules/NoUndefinedVariablesRule.js.flow +3 -3
- package/validation/rules/NoUnusedFragmentsRule.js +1 -1
- package/validation/rules/NoUnusedFragmentsRule.js.flow +3 -3
- package/validation/rules/NoUnusedVariablesRule.js +1 -1
- package/validation/rules/NoUnusedVariablesRule.js.flow +3 -3
- package/validation/rules/OverlappingFieldsCanBeMergedRule.js +20 -20
- package/validation/rules/OverlappingFieldsCanBeMergedRule.js.flow +29 -27
- package/validation/rules/OverlappingFieldsCanBeMergedRule.mjs +12 -12
- package/validation/rules/PossibleFragmentSpreadsRule.js +5 -5
- package/validation/rules/PossibleFragmentSpreadsRule.js.flow +7 -4
- package/validation/rules/PossibleTypeExtensions.js +1 -1
- package/validation/rules/PossibleTypeExtensions.js.flow +0 -1
- package/validation/rules/PossibleTypeExtensionsRule.js +8 -8
- package/validation/rules/PossibleTypeExtensionsRule.js.flow +8 -6
- package/validation/rules/ProvidedRequiredArgumentsRule.js +7 -7
- package/validation/rules/ProvidedRequiredArgumentsRule.js.flow +7 -6
- package/validation/rules/ScalarLeafsRule.js +3 -3
- package/validation/rules/ScalarLeafsRule.js.flow +3 -4
- package/validation/rules/SingleFieldSubscriptionsRule.js +1 -1
- package/validation/rules/SingleFieldSubscriptionsRule.js.flow +3 -4
- package/validation/rules/UniqueArgumentNamesRule.js +1 -1
- package/validation/rules/UniqueArgumentNamesRule.js.flow +2 -3
- package/validation/rules/UniqueDirectiveNames.js +1 -1
- package/validation/rules/UniqueDirectiveNames.js.flow +0 -1
- package/validation/rules/UniqueDirectiveNamesRule.js +1 -1
- package/validation/rules/UniqueDirectiveNamesRule.js.flow +2 -3
- package/validation/rules/UniqueDirectivesPerLocationRule.js +4 -4
- package/validation/rules/UniqueDirectivesPerLocationRule.js.flow +4 -5
- package/validation/rules/UniqueEnumValueNames.js +1 -1
- package/validation/rules/UniqueEnumValueNames.js.flow +0 -1
- package/validation/rules/UniqueEnumValueNamesRule.js +2 -2
- package/validation/rules/UniqueEnumValueNamesRule.js.flow +11 -4
- package/validation/rules/UniqueFieldDefinitionNames.js +1 -1
- package/validation/rules/UniqueFieldDefinitionNames.js.flow +0 -1
- package/validation/rules/UniqueFieldDefinitionNamesRule.js +3 -3
- package/validation/rules/UniqueFieldDefinitionNamesRule.js.flow +17 -6
- package/validation/rules/UniqueFieldDefinitionNamesRule.mjs +1 -1
- package/validation/rules/UniqueFragmentNamesRule.js +1 -1
- package/validation/rules/UniqueFragmentNamesRule.js.flow +3 -3
- package/validation/rules/UniqueInputFieldNamesRule.js +1 -1
- package/validation/rules/UniqueInputFieldNamesRule.js.flow +3 -3
- package/validation/rules/UniqueOperationNamesRule.js +1 -1
- package/validation/rules/UniqueOperationNamesRule.js.flow +3 -3
- package/validation/rules/UniqueOperationTypes.js +1 -1
- package/validation/rules/UniqueOperationTypes.js.flow +0 -1
- package/validation/rules/UniqueOperationTypesRule.js +1 -1
- package/validation/rules/UniqueOperationTypesRule.js.flow +10 -4
- package/validation/rules/UniqueTypeNames.js +1 -1
- package/validation/rules/UniqueTypeNames.js.flow +0 -1
- package/validation/rules/UniqueTypeNamesRule.js +1 -1
- package/validation/rules/UniqueTypeNamesRule.js.flow +3 -4
- package/validation/rules/UniqueVariableNamesRule.js +1 -1
- package/validation/rules/UniqueVariableNamesRule.js.flow +3 -4
- package/validation/rules/ValuesOfCorrectTypeRule.js +8 -8
- package/validation/rules/ValuesOfCorrectTypeRule.js.flow +3 -4
- package/validation/rules/VariablesAreInputTypesRule.js +4 -4
- package/validation/rules/VariablesAreInputTypesRule.js.flow +3 -4
- package/validation/rules/VariablesInAllowedPositionRule.js +6 -6
- package/validation/rules/VariablesInAllowedPositionRule.js.flow +6 -6
- package/validation/rules/custom/NoDeprecatedCustomRule.d.ts +14 -0
- package/validation/rules/custom/NoDeprecatedCustomRule.js +79 -0
- package/validation/rules/custom/NoDeprecatedCustomRule.js.flow +94 -0
- package/validation/rules/custom/NoDeprecatedCustomRule.mjs +68 -0
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.d.ts +16 -0
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.js +34 -0
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.js.flow +38 -0
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.mjs +25 -0
- package/validation/specifiedRules.js +33 -33
- package/validation/specifiedRules.js.flow +0 -1
- package/validation/validate.js +7 -7
- package/validation/validate.js.flow +4 -9
- package/version.js +2 -2
- package/version.js.flow +2 -3
- package/version.mjs +2 -2
- package/polyfills/flatMap.js +0 -30
- package/polyfills/flatMap.js.flow +0 -28
- package/polyfills/flatMap.mjs +0 -23
package/execution/execute.js
CHANGED
|
@@ -4,55 +4,55 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.execute = execute;
|
|
7
|
+
exports.executeSync = executeSync;
|
|
7
8
|
exports.assertValidExecutionArguments = assertValidExecutionArguments;
|
|
8
9
|
exports.buildExecutionContext = buildExecutionContext;
|
|
9
10
|
exports.collectFields = collectFields;
|
|
10
11
|
exports.buildResolveInfo = buildResolveInfo;
|
|
11
|
-
exports.resolveFieldValueOrError = resolveFieldValueOrError;
|
|
12
12
|
exports.getFieldDef = getFieldDef;
|
|
13
13
|
exports.defaultFieldResolver = exports.defaultTypeResolver = void 0;
|
|
14
14
|
|
|
15
|
-
var _arrayFrom = _interopRequireDefault(require("../polyfills/arrayFrom"));
|
|
15
|
+
var _arrayFrom = _interopRequireDefault(require("../polyfills/arrayFrom.js"));
|
|
16
16
|
|
|
17
|
-
var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
|
|
17
|
+
var _inspect = _interopRequireDefault(require("../jsutils/inspect.js"));
|
|
18
18
|
|
|
19
|
-
var _memoize = _interopRequireDefault(require("../jsutils/memoize3"));
|
|
19
|
+
var _memoize = _interopRequireDefault(require("../jsutils/memoize3.js"));
|
|
20
20
|
|
|
21
|
-
var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
|
|
21
|
+
var _invariant = _interopRequireDefault(require("../jsutils/invariant.js"));
|
|
22
22
|
|
|
23
|
-
var _devAssert = _interopRequireDefault(require("../jsutils/devAssert"));
|
|
23
|
+
var _devAssert = _interopRequireDefault(require("../jsutils/devAssert.js"));
|
|
24
24
|
|
|
25
|
-
var _isPromise = _interopRequireDefault(require("../jsutils/isPromise"));
|
|
25
|
+
var _isPromise = _interopRequireDefault(require("../jsutils/isPromise.js"));
|
|
26
26
|
|
|
27
|
-
var _isObjectLike = _interopRequireDefault(require("../jsutils/isObjectLike"));
|
|
27
|
+
var _isObjectLike = _interopRequireDefault(require("../jsutils/isObjectLike.js"));
|
|
28
28
|
|
|
29
|
-
var _isCollection = _interopRequireDefault(require("../jsutils/isCollection"));
|
|
29
|
+
var _isCollection = _interopRequireDefault(require("../jsutils/isCollection.js"));
|
|
30
30
|
|
|
31
|
-
var _promiseReduce = _interopRequireDefault(require("../jsutils/promiseReduce"));
|
|
31
|
+
var _promiseReduce = _interopRequireDefault(require("../jsutils/promiseReduce.js"));
|
|
32
32
|
|
|
33
|
-
var _promiseForObject = _interopRequireDefault(require("../jsutils/promiseForObject"));
|
|
33
|
+
var _promiseForObject = _interopRequireDefault(require("../jsutils/promiseForObject.js"));
|
|
34
34
|
|
|
35
|
-
var _Path = require("../jsutils/Path");
|
|
35
|
+
var _Path = require("../jsutils/Path.js");
|
|
36
36
|
|
|
37
|
-
var _GraphQLError = require("../error/GraphQLError");
|
|
37
|
+
var _GraphQLError = require("../error/GraphQLError.js");
|
|
38
38
|
|
|
39
|
-
var _locatedError = require("../error/locatedError");
|
|
39
|
+
var _locatedError = require("../error/locatedError.js");
|
|
40
40
|
|
|
41
|
-
var _kinds = require("../language/kinds");
|
|
41
|
+
var _kinds = require("../language/kinds.js");
|
|
42
42
|
|
|
43
|
-
var _validate = require("../type/validate");
|
|
43
|
+
var _validate = require("../type/validate.js");
|
|
44
44
|
|
|
45
|
-
var _introspection = require("../type/introspection");
|
|
45
|
+
var _introspection = require("../type/introspection.js");
|
|
46
46
|
|
|
47
|
-
var _directives = require("../type/directives");
|
|
47
|
+
var _directives = require("../type/directives.js");
|
|
48
48
|
|
|
49
|
-
var _definition = require("../type/definition");
|
|
49
|
+
var _definition = require("../type/definition.js");
|
|
50
50
|
|
|
51
|
-
var _typeFromAST = require("../utilities/typeFromAST");
|
|
51
|
+
var _typeFromAST = require("../utilities/typeFromAST.js");
|
|
52
52
|
|
|
53
|
-
var _getOperationRootType = require("../utilities/getOperationRootType");
|
|
53
|
+
var _getOperationRootType = require("../utilities/getOperationRootType.js");
|
|
54
54
|
|
|
55
|
-
var _values = require("./values");
|
|
55
|
+
var _values = require("./values.js");
|
|
56
56
|
|
|
57
57
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
58
58
|
|
|
@@ -70,6 +70,22 @@ function execute(argsOrSchema, document, rootValue, contextValue, variableValues
|
|
|
70
70
|
typeResolver: typeResolver
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Also implements the "Evaluating requests" section of the GraphQL specification.
|
|
75
|
+
* However, it guarantees to complete synchronously (or throw an error) assuming
|
|
76
|
+
* that all field resolvers are also synchronous.
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
function executeSync(args) {
|
|
81
|
+
var result = executeImpl(args); // Assert that the execution was synchronous.
|
|
82
|
+
|
|
83
|
+
if ((0, _isPromise.default)(result)) {
|
|
84
|
+
throw new Error('GraphQL execution failed to complete synchronously.');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
73
89
|
|
|
74
90
|
function executeImpl(args) {
|
|
75
91
|
var schema = args.schema,
|
|
@@ -217,8 +233,6 @@ function executeOperation(exeContext, operation, rootValue) {
|
|
|
217
233
|
var path = undefined; // Errors from sub-fields of a NonNull type may propagate to the top level,
|
|
218
234
|
// at which point we still log the error and null the parent field, which
|
|
219
235
|
// in this case is the entire response.
|
|
220
|
-
//
|
|
221
|
-
// Similar to completeValueCatchingError.
|
|
222
236
|
|
|
223
237
|
try {
|
|
224
238
|
var result = operation.operation === 'mutation' ? executeFieldsSerially(exeContext, type, rootValue, path, fields) : executeFields(exeContext, type, rootValue, path, fields);
|
|
@@ -245,7 +259,7 @@ function executeOperation(exeContext, operation, rootValue) {
|
|
|
245
259
|
function executeFieldsSerially(exeContext, parentType, sourceValue, path, fields) {
|
|
246
260
|
return (0, _promiseReduce.default)(Object.keys(fields), function (results, responseName) {
|
|
247
261
|
var fieldNodes = fields[responseName];
|
|
248
|
-
var fieldPath = (0, _Path.addPath)(path, responseName);
|
|
262
|
+
var fieldPath = (0, _Path.addPath)(path, responseName, parentType.name);
|
|
249
263
|
var result = resolveField(exeContext, parentType, sourceValue, fieldNodes, fieldPath);
|
|
250
264
|
|
|
251
265
|
if (result === undefined) {
|
|
@@ -276,13 +290,13 @@ function executeFields(exeContext, parentType, sourceValue, path, fields) {
|
|
|
276
290
|
for (var _i4 = 0, _Object$keys2 = Object.keys(fields); _i4 < _Object$keys2.length; _i4++) {
|
|
277
291
|
var responseName = _Object$keys2[_i4];
|
|
278
292
|
var fieldNodes = fields[responseName];
|
|
279
|
-
var fieldPath = (0, _Path.addPath)(path, responseName);
|
|
293
|
+
var fieldPath = (0, _Path.addPath)(path, responseName, parentType.name);
|
|
280
294
|
var result = resolveField(exeContext, parentType, sourceValue, fieldNodes, fieldPath);
|
|
281
295
|
|
|
282
296
|
if (result !== undefined) {
|
|
283
297
|
results[responseName] = result;
|
|
284
298
|
|
|
285
|
-
if (
|
|
299
|
+
if ((0, _isPromise.default)(result)) {
|
|
286
300
|
containsPromise = true;
|
|
287
301
|
}
|
|
288
302
|
}
|
|
@@ -436,43 +450,10 @@ function resolveField(exeContext, parentType, source, fieldNodes, path) {
|
|
|
436
450
|
return;
|
|
437
451
|
}
|
|
438
452
|
|
|
453
|
+
var returnType = fieldDef.type;
|
|
439
454
|
var resolveFn = (_fieldDef$resolve = fieldDef.resolve) !== null && _fieldDef$resolve !== void 0 ? _fieldDef$resolve : exeContext.fieldResolver;
|
|
440
|
-
var info = buildResolveInfo(exeContext, fieldDef, fieldNodes, parentType, path); // Get the resolve function, regardless of if its result is normal
|
|
441
|
-
// or abrupt (error).
|
|
442
|
-
|
|
443
|
-
var result = resolveFieldValueOrError(exeContext, fieldDef, fieldNodes, resolveFn, source, info);
|
|
444
|
-
return completeValueCatchingError(exeContext, fieldDef.type, fieldNodes, info, path, result);
|
|
445
|
-
}
|
|
446
|
-
/**
|
|
447
|
-
* @internal
|
|
448
|
-
*/
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
function buildResolveInfo(exeContext, fieldDef, fieldNodes, parentType, path) {
|
|
452
|
-
// The resolve function's optional fourth argument is a collection of
|
|
453
|
-
// information about the current execution state.
|
|
454
|
-
return {
|
|
455
|
-
fieldName: fieldDef.name,
|
|
456
|
-
fieldNodes: fieldNodes,
|
|
457
|
-
returnType: fieldDef.type,
|
|
458
|
-
parentType: parentType,
|
|
459
|
-
path: path,
|
|
460
|
-
schema: exeContext.schema,
|
|
461
|
-
fragments: exeContext.fragments,
|
|
462
|
-
rootValue: exeContext.rootValue,
|
|
463
|
-
operation: exeContext.operation,
|
|
464
|
-
variableValues: exeContext.variableValues
|
|
465
|
-
};
|
|
466
|
-
}
|
|
467
|
-
/**
|
|
468
|
-
* Isolates the "ReturnOrAbrupt" behavior to not de-opt the `resolveField`
|
|
469
|
-
* function. Returns the result of resolveFn or the abrupt-return Error object.
|
|
470
|
-
*
|
|
471
|
-
* @internal
|
|
472
|
-
*/
|
|
473
|
-
|
|
455
|
+
var info = buildResolveInfo(exeContext, fieldDef, fieldNodes, parentType, path); // Get the resolve function, regardless of if its result is normal or abrupt (error).
|
|
474
456
|
|
|
475
|
-
function resolveFieldValueOrError(exeContext, fieldDef, fieldNodes, resolveFn, source, info) {
|
|
476
457
|
try {
|
|
477
458
|
// Build a JS object of arguments from the field.arguments AST, using the
|
|
478
459
|
// variables scope to fulfill any variable references.
|
|
@@ -483,26 +464,6 @@ function resolveFieldValueOrError(exeContext, fieldDef, fieldNodes, resolveFn, s
|
|
|
483
464
|
|
|
484
465
|
var _contextValue = exeContext.contextValue;
|
|
485
466
|
var result = resolveFn(source, args, _contextValue, info);
|
|
486
|
-
return (0, _isPromise.default)(result) ? result.then(undefined, asErrorInstance) : result;
|
|
487
|
-
} catch (error) {
|
|
488
|
-
return asErrorInstance(error);
|
|
489
|
-
}
|
|
490
|
-
} // Sometimes a non-error is thrown, wrap it as an Error instance to ensure a
|
|
491
|
-
// consistent Error interface.
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
function asErrorInstance(error) {
|
|
495
|
-
if (error instanceof Error) {
|
|
496
|
-
return error;
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
return new Error('Unexpected error value: ' + (0, _inspect.default)(error));
|
|
500
|
-
} // This is a small wrapper around completeValue which detects and logs errors
|
|
501
|
-
// in the execution context.
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
function completeValueCatchingError(exeContext, returnType, fieldNodes, info, path, result) {
|
|
505
|
-
try {
|
|
506
467
|
var completed;
|
|
507
468
|
|
|
508
469
|
if ((0, _isPromise.default)(result)) {
|
|
@@ -516,21 +477,43 @@ function completeValueCatchingError(exeContext, returnType, fieldNodes, info, pa
|
|
|
516
477
|
if ((0, _isPromise.default)(completed)) {
|
|
517
478
|
// Note: we don't rely on a `catch` method, but we do expect "thenable"
|
|
518
479
|
// to take a second callback for the error case.
|
|
519
|
-
return completed.then(undefined, function (
|
|
520
|
-
|
|
480
|
+
return completed.then(undefined, function (rawError) {
|
|
481
|
+
var error = (0, _locatedError.locatedError)(rawError, fieldNodes, (0, _Path.pathToArray)(path));
|
|
482
|
+
return handleFieldError(error, returnType, exeContext);
|
|
521
483
|
});
|
|
522
484
|
}
|
|
523
485
|
|
|
524
486
|
return completed;
|
|
525
|
-
} catch (
|
|
526
|
-
|
|
487
|
+
} catch (rawError) {
|
|
488
|
+
var error = (0, _locatedError.locatedError)(rawError, fieldNodes, (0, _Path.pathToArray)(path));
|
|
489
|
+
return handleFieldError(error, returnType, exeContext);
|
|
527
490
|
}
|
|
528
491
|
}
|
|
492
|
+
/**
|
|
493
|
+
* @internal
|
|
494
|
+
*/
|
|
529
495
|
|
|
530
|
-
function handleFieldError(rawError, fieldNodes, path, returnType, exeContext) {
|
|
531
|
-
var error = (0, _locatedError.locatedError)(asErrorInstance(rawError), fieldNodes, (0, _Path.pathToArray)(path)); // If the field type is non-nullable, then it is resolved without any
|
|
532
|
-
// protection from errors, however it still properly locates the error.
|
|
533
496
|
|
|
497
|
+
function buildResolveInfo(exeContext, fieldDef, fieldNodes, parentType, path) {
|
|
498
|
+
// The resolve function's optional fourth argument is a collection of
|
|
499
|
+
// information about the current execution state.
|
|
500
|
+
return {
|
|
501
|
+
fieldName: fieldDef.name,
|
|
502
|
+
fieldNodes: fieldNodes,
|
|
503
|
+
returnType: fieldDef.type,
|
|
504
|
+
parentType: parentType,
|
|
505
|
+
path: path,
|
|
506
|
+
schema: exeContext.schema,
|
|
507
|
+
fragments: exeContext.fragments,
|
|
508
|
+
rootValue: exeContext.rootValue,
|
|
509
|
+
operation: exeContext.operation,
|
|
510
|
+
variableValues: exeContext.variableValues
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
function handleFieldError(error, returnType, exeContext) {
|
|
515
|
+
// If the field type is non-nullable, then it is resolved without any
|
|
516
|
+
// protection from errors, however it still properly locates the error.
|
|
534
517
|
if ((0, _definition.isNonNullType)(returnType)) {
|
|
535
518
|
throw error;
|
|
536
519
|
} // Otherwise, error protection is applied, logging the error and resolving
|
|
@@ -630,14 +613,34 @@ function completeListValue(exeContext, returnType, fieldNodes, info, path, resul
|
|
|
630
613
|
var completedResults = (0, _arrayFrom.default)(result, function (item, index) {
|
|
631
614
|
// No need to modify the info object containing the path,
|
|
632
615
|
// since from here on it is not ever accessed by resolver functions.
|
|
633
|
-
var
|
|
634
|
-
var completedItem = completeValueCatchingError(exeContext, itemType, fieldNodes, info, fieldPath, item);
|
|
616
|
+
var itemPath = (0, _Path.addPath)(path, index, undefined);
|
|
635
617
|
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
618
|
+
try {
|
|
619
|
+
var completedItem;
|
|
620
|
+
|
|
621
|
+
if ((0, _isPromise.default)(item)) {
|
|
622
|
+
completedItem = item.then(function (resolved) {
|
|
623
|
+
return completeValue(exeContext, itemType, fieldNodes, info, itemPath, resolved);
|
|
624
|
+
});
|
|
625
|
+
} else {
|
|
626
|
+
completedItem = completeValue(exeContext, itemType, fieldNodes, info, itemPath, item);
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
if ((0, _isPromise.default)(completedItem)) {
|
|
630
|
+
containsPromise = true; // Note: we don't rely on a `catch` method, but we do expect "thenable"
|
|
631
|
+
// to take a second callback for the error case.
|
|
639
632
|
|
|
640
|
-
|
|
633
|
+
return completedItem.then(undefined, function (rawError) {
|
|
634
|
+
var error = (0, _locatedError.locatedError)(rawError, fieldNodes, (0, _Path.pathToArray)(itemPath));
|
|
635
|
+
return handleFieldError(error, itemType, exeContext);
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
return completedItem;
|
|
640
|
+
} catch (rawError) {
|
|
641
|
+
var error = (0, _locatedError.locatedError)(rawError, fieldNodes, (0, _Path.pathToArray)(itemPath));
|
|
642
|
+
return handleFieldError(error, itemType, exeContext);
|
|
643
|
+
}
|
|
641
644
|
});
|
|
642
645
|
return containsPromise ? Promise.all(completedResults) : completedResults;
|
|
643
646
|
}
|
|
@@ -679,10 +682,25 @@ function completeAbstractValue(exeContext, returnType, fieldNodes, info, path, r
|
|
|
679
682
|
}
|
|
680
683
|
|
|
681
684
|
function ensureValidRuntimeType(runtimeTypeOrName, exeContext, returnType, fieldNodes, info, result) {
|
|
682
|
-
|
|
685
|
+
if (runtimeTypeOrName == null) {
|
|
686
|
+
throw new _GraphQLError.GraphQLError("Abstract type \"".concat(returnType.name, "\" must resolve to an Object type at runtime for field \"").concat(info.parentType.name, ".").concat(info.fieldName, "\". Either the \"").concat(returnType.name, "\" type should provide a \"resolveType\" function or each possible type should provide an \"isTypeOf\" function."), fieldNodes);
|
|
687
|
+
} // FIXME: temporary workaround until support for passing object types would be removed in v16.0.0
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
var runtimeTypeName = (0, _definition.isNamedType)(runtimeTypeOrName) ? runtimeTypeOrName.name : runtimeTypeOrName;
|
|
691
|
+
|
|
692
|
+
if (typeof runtimeTypeName !== 'string') {
|
|
693
|
+
throw new _GraphQLError.GraphQLError("Abstract type \"".concat(returnType.name, "\" must resolve to an Object type at runtime for field \"").concat(info.parentType.name, ".").concat(info.fieldName, "\" with ") + "value ".concat((0, _inspect.default)(result), ", received \"").concat((0, _inspect.default)(runtimeTypeOrName), "\"."));
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
var runtimeType = exeContext.schema.getType(runtimeTypeName);
|
|
697
|
+
|
|
698
|
+
if (runtimeType == null) {
|
|
699
|
+
throw new _GraphQLError.GraphQLError("Abstract type \"".concat(returnType.name, "\" was resolve to a type \"").concat(runtimeTypeName, "\" that does not exist inside schema."), fieldNodes);
|
|
700
|
+
}
|
|
683
701
|
|
|
684
702
|
if (!(0, _definition.isObjectType)(runtimeType)) {
|
|
685
|
-
throw new _GraphQLError.GraphQLError("Abstract type \"".concat(returnType.name, "\"
|
|
703
|
+
throw new _GraphQLError.GraphQLError("Abstract type \"".concat(returnType.name, "\" was resolve to a non-object type \"").concat(runtimeTypeName, "\"."), fieldNodes);
|
|
686
704
|
}
|
|
687
705
|
|
|
688
706
|
if (!exeContext.schema.isSubType(returnType, runtimeType)) {
|
|
@@ -784,7 +802,7 @@ var defaultTypeResolver = function defaultTypeResolver(value, contextValue, info
|
|
|
784
802
|
if ((0, _isPromise.default)(isTypeOfResult)) {
|
|
785
803
|
promisedIsTypeOfResults[i] = isTypeOfResult;
|
|
786
804
|
} else if (isTypeOfResult) {
|
|
787
|
-
return type;
|
|
805
|
+
return type.name;
|
|
788
806
|
}
|
|
789
807
|
}
|
|
790
808
|
}
|
|
@@ -793,7 +811,7 @@ var defaultTypeResolver = function defaultTypeResolver(value, contextValue, info
|
|
|
793
811
|
return Promise.all(promisedIsTypeOfResults).then(function (isTypeOfResults) {
|
|
794
812
|
for (var _i9 = 0; _i9 < isTypeOfResults.length; _i9++) {
|
|
795
813
|
if (isTypeOfResults[_i9]) {
|
|
796
|
-
return possibleTypes[_i9];
|
|
814
|
+
return possibleTypes[_i9].name;
|
|
797
815
|
}
|
|
798
816
|
}
|
|
799
817
|
});
|
|
@@ -823,12 +841,12 @@ var defaultFieldResolver = function defaultFieldResolver(source, args, contextVa
|
|
|
823
841
|
};
|
|
824
842
|
/**
|
|
825
843
|
* This method looks up the field on the given type definition.
|
|
826
|
-
* It has special casing for the
|
|
827
|
-
* and __typename. __typename is special because
|
|
828
|
-
* queried as a field, even in situations where no
|
|
829
|
-
* are allowed, like on a Union. __schema
|
|
830
|
-
* added to the query type, but that would
|
|
831
|
-
* definitions, which would cause issues.
|
|
844
|
+
* It has special casing for the three introspection fields,
|
|
845
|
+
* __schema, __type and __typename. __typename is special because
|
|
846
|
+
* it can always be queried as a field, even in situations where no
|
|
847
|
+
* other fields are allowed, like on a Union. __schema and __type
|
|
848
|
+
* could get automatically added to the query type, but that would
|
|
849
|
+
* require mutating type definitions, which would cause issues.
|
|
832
850
|
*
|
|
833
851
|
* @internal
|
|
834
852
|
*/
|