graphql 14.1.1 → 14.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/error/GraphQLError.js +12 -10
- package/error/GraphQLError.js.flow +11 -6
- package/error/GraphQLError.mjs +20 -3
- package/error/formatError.js +2 -2
- package/error/formatError.js.flow +3 -3
- package/error/formatError.mjs +2 -2
- package/error/index.js +1 -1
- package/error/index.js.flow +5 -2
- package/error/index.mjs +2 -2
- package/error/locatedError.js +2 -2
- package/error/locatedError.js.flow +2 -2
- package/error/locatedError.mjs +2 -2
- package/error/printError.js +2 -2
- package/error/printError.js.flow +4 -5
- package/error/printError.mjs +2 -2
- package/error/syntaxError.js +2 -2
- package/error/syntaxError.js.flow +2 -2
- package/error/syntaxError.mjs +2 -2
- package/execution/execute.js +52 -37
- package/execution/execute.js.flow +66 -51
- package/execution/execute.mjs +50 -38
- package/execution/index.js +7 -1
- package/execution/index.js.flow +9 -4
- package/execution/index.mjs +3 -3
- package/execution/values.js +11 -11
- package/execution/values.js.flow +23 -19
- package/execution/values.mjs +11 -11
- package/graphql.js +13 -9
- package/graphql.js.flow +28 -10
- package/graphql.mjs +10 -9
- package/index.js +83 -53
- package/index.js.flow +60 -47
- package/index.mjs +26 -23
- package/jsutils/ObjMap.js +1 -1
- package/jsutils/ObjMap.js.flow +1 -1
- package/jsutils/ObjMap.mjs +1 -0
- package/jsutils/PromiseOrValue.js +1 -0
- package/jsutils/{MaybePromise.js.flow → PromiseOrValue.js.flow} +2 -2
- package/jsutils/PromiseOrValue.mjs +1 -0
- package/jsutils/dedent.js +2 -2
- package/jsutils/dedent.js.flow +1 -1
- package/jsutils/dedent.mjs +2 -2
- package/jsutils/defineToJSON.js +2 -2
- package/jsutils/defineToJSON.js.flow +1 -1
- package/jsutils/defineToJSON.mjs +2 -2
- package/jsutils/defineToStringTag.js +2 -2
- package/jsutils/defineToStringTag.js.flow +1 -1
- package/jsutils/defineToStringTag.mjs +2 -2
- package/jsutils/inspect.js +94 -19
- package/jsutils/inspect.js.flow +98 -20
- package/jsutils/inspect.mjs +94 -20
- package/jsutils/instanceOf.js +2 -2
- package/jsutils/instanceOf.js.flow +1 -1
- package/jsutils/instanceOf.mjs +2 -2
- package/jsutils/invariant.js +5 -3
- package/jsutils/invariant.js.flow +3 -2
- package/jsutils/invariant.mjs +5 -3
- package/jsutils/isInvalid.js +2 -2
- package/jsutils/isInvalid.js.flow +1 -1
- package/jsutils/isInvalid.mjs +2 -2
- package/jsutils/isNullish.js +2 -2
- package/jsutils/isNullish.js.flow +1 -1
- package/jsutils/isNullish.mjs +2 -2
- package/jsutils/isPromise.js +2 -2
- package/jsutils/isPromise.js.flow +1 -1
- package/jsutils/isPromise.mjs +2 -2
- package/jsutils/keyMap.js +4 -3
- package/jsutils/keyMap.js.flow +6 -6
- package/jsutils/keyMap.mjs +4 -3
- package/jsutils/keyValMap.js +4 -3
- package/jsutils/keyValMap.js.flow +6 -6
- package/jsutils/keyValMap.mjs +4 -3
- package/jsutils/mapValue.js +2 -2
- package/jsutils/mapValue.js.flow +2 -2
- package/jsutils/mapValue.mjs +2 -2
- package/jsutils/memoize3.js +3 -3
- package/jsutils/memoize3.js.flow +2 -2
- package/jsutils/memoize3.mjs +3 -3
- package/jsutils/nodejsCustomInspectSymbol.js +2 -2
- package/jsutils/nodejsCustomInspectSymbol.js.flow +1 -1
- package/jsutils/nodejsCustomInspectSymbol.mjs +2 -2
- package/jsutils/orList.js +2 -2
- package/jsutils/orList.js.flow +1 -1
- package/jsutils/orList.mjs +2 -2
- package/jsutils/promiseForObject.js +2 -2
- package/jsutils/promiseForObject.js.flow +2 -2
- package/jsutils/promiseForObject.mjs +2 -2
- package/jsutils/promiseReduce.js +2 -2
- package/jsutils/promiseReduce.js.flow +5 -5
- package/jsutils/promiseReduce.mjs +2 -2
- package/jsutils/quotedOrList.js +2 -2
- package/jsutils/quotedOrList.js.flow +1 -1
- package/jsutils/quotedOrList.mjs +2 -2
- package/jsutils/suggestionList.js +2 -2
- package/jsutils/suggestionList.js.flow +1 -1
- package/jsutils/suggestionList.mjs +2 -2
- package/language/ast.js +1 -1
- package/language/ast.js.flow +3 -3
- package/language/ast.mjs +1 -0
- package/language/blockString.js +114 -0
- package/language/blockString.js.flow +102 -0
- package/language/blockString.mjs +104 -0
- package/language/directiveLocation.js +2 -2
- package/language/directiveLocation.js.flow +1 -1
- package/language/directiveLocation.mjs +2 -2
- package/language/index.js +9 -9
- package/language/index.js.flow +10 -5
- package/language/index.mjs +3 -3
- package/language/kinds.js +2 -2
- package/language/kinds.js.flow +1 -1
- package/language/kinds.mjs +2 -2
- package/language/lexer.js +52 -44
- package/language/lexer.js.flow +65 -54
- package/language/lexer.mjs +49 -43
- package/language/location.js +2 -2
- package/language/location.js.flow +2 -2
- package/language/location.mjs +2 -2
- package/language/parser.js +75 -67
- package/language/parser.js.flow +138 -127
- package/language/parser.mjs +76 -68
- package/language/predicates.js +2 -2
- package/language/predicates.js.flow +2 -2
- package/language/predicates.mjs +2 -2
- package/language/printer.js +6 -14
- package/language/printer.js.flow +8 -17
- package/language/printer.mjs +5 -14
- package/language/source.js +2 -2
- package/language/source.js.flow +1 -1
- package/language/source.mjs +2 -2
- package/language/visitor.js +4 -6
- package/language/visitor.js.flow +3 -3
- package/language/visitor.mjs +4 -6
- package/package.json +1 -1
- package/polyfills/find.js +2 -2
- package/polyfills/find.js.flow +1 -1
- package/polyfills/find.mjs +2 -2
- package/polyfills/flatMap.js +38 -0
- package/polyfills/flatMap.js.flow +34 -0
- package/polyfills/flatMap.mjs +30 -0
- package/polyfills/isFinite.js +2 -2
- package/polyfills/isFinite.js.flow +1 -1
- package/polyfills/isFinite.mjs +2 -2
- package/polyfills/isInteger.js +2 -2
- package/polyfills/isInteger.js.flow +1 -1
- package/polyfills/isInteger.mjs +2 -2
- package/polyfills/objectEntries.js +2 -2
- package/polyfills/objectEntries.js.flow +2 -2
- package/polyfills/objectEntries.mjs +2 -2
- package/polyfills/objectValues.js +2 -2
- package/polyfills/objectValues.js.flow +2 -2
- package/polyfills/objectValues.mjs +2 -2
- package/subscription/asyncIteratorReject.js +1 -1
- package/subscription/asyncIteratorReject.js.flow +1 -1
- package/subscription/asyncIteratorReject.mjs +2 -2
- package/subscription/index.js +1 -1
- package/subscription/index.js.flow +1 -1
- package/subscription/index.mjs +2 -2
- package/subscription/mapAsyncIterator.js +1 -1
- package/subscription/mapAsyncIterator.js.flow +5 -5
- package/subscription/mapAsyncIterator.mjs +2 -2
- package/subscription/subscribe.js +2 -2
- package/subscription/subscribe.js.flow +6 -6
- package/subscription/subscribe.mjs +2 -2
- package/type/definition.js +138 -22
- package/type/definition.js.flow +184 -36
- package/type/definition.mjs +136 -23
- package/type/directives.js +14 -3
- package/type/directives.js.flow +24 -11
- package/type/directives.mjs +16 -5
- package/type/index.js +7 -7
- package/type/index.js.flow +8 -4
- package/type/index.mjs +10 -6
- package/type/introspection.js +14 -9
- package/type/introspection.js.flow +12 -18
- package/type/introspection.mjs +14 -9
- package/type/scalars.js +5 -4
- package/type/scalars.js.flow +4 -10
- package/type/scalars.mjs +7 -6
- package/type/schema.js +55 -3
- package/type/schema.js.flow +73 -17
- package/type/schema.mjs +56 -4
- package/type/validate.js +19 -47
- package/type/validate.js.flow +17 -29
- package/type/validate.mjs +18 -47
- package/utilities/TypeInfo.js +93 -73
- package/utilities/TypeInfo.js.flow +30 -23
- package/utilities/TypeInfo.mjs +93 -73
- package/utilities/assertValidName.js +2 -2
- package/utilities/assertValidName.js.flow +2 -2
- package/utilities/assertValidName.mjs +2 -2
- package/utilities/astFromValue.js +5 -4
- package/utilities/astFromValue.js.flow +8 -7
- package/utilities/astFromValue.mjs +7 -6
- package/utilities/buildASTSchema.js +63 -62
- package/utilities/buildASTSchema.js.flow +92 -108
- package/utilities/buildASTSchema.mjs +61 -62
- package/utilities/buildClientSchema.js +38 -45
- package/utilities/buildClientSchema.js.flow +66 -79
- package/utilities/buildClientSchema.mjs +37 -44
- package/utilities/coerceValue.js +6 -7
- package/utilities/coerceValue.js.flow +5 -4
- package/utilities/coerceValue.mjs +7 -8
- package/utilities/concatAST.js +9 -13
- package/utilities/concatAST.js.flow +4 -10
- package/utilities/concatAST.mjs +6 -13
- package/utilities/extendSchema.js +219 -511
- package/utilities/extendSchema.js.flow +195 -304
- package/utilities/extendSchema.mjs +218 -512
- package/utilities/findBreakingChanges.js +54 -95
- package/utilities/findBreakingChanges.js.flow +49 -47
- package/utilities/findBreakingChanges.mjs +80 -95
- package/utilities/findDeprecatedUsages.js +4 -4
- package/utilities/findDeprecatedUsages.js.flow +5 -5
- package/utilities/findDeprecatedUsages.mjs +4 -4
- package/utilities/getOperationAST.js +2 -2
- package/utilities/getOperationAST.js.flow +5 -2
- package/utilities/getOperationAST.mjs +2 -2
- package/utilities/getOperationRootType.js +24 -24
- package/utilities/getOperationRootType.js.flow +40 -35
- package/utilities/getOperationRootType.mjs +24 -24
- package/utilities/index.js +9 -1
- package/utilities/index.js.flow +13 -6
- package/utilities/index.mjs +13 -8
- package/utilities/introspectionFromSchema.js +6 -4
- package/utilities/introspectionFromSchema.js.flow +8 -7
- package/utilities/introspectionFromSchema.mjs +6 -5
- package/utilities/introspectionQuery.js +2 -2
- package/utilities/introspectionQuery.js.flow +2 -2
- package/utilities/introspectionQuery.mjs +2 -2
- package/utilities/isValidJSValue.js +4 -2
- package/utilities/isValidJSValue.js.flow +3 -2
- package/utilities/isValidJSValue.mjs +4 -2
- package/utilities/isValidLiteralValue.js +2 -2
- package/utilities/isValidLiteralValue.js.flow +4 -4
- package/utilities/isValidLiteralValue.mjs +2 -2
- package/utilities/lexicographicSortSchema.js +84 -123
- package/utilities/lexicographicSortSchema.js.flow +68 -96
- package/utilities/lexicographicSortSchema.mjs +84 -123
- package/utilities/schemaPrinter.js +47 -73
- package/utilities/schemaPrinter.js.flow +69 -120
- package/utilities/schemaPrinter.mjs +45 -72
- package/utilities/separateOperations.js +8 -12
- package/utilities/separateOperations.js.flow +6 -3
- package/utilities/separateOperations.mjs +8 -12
- package/utilities/stripIgnoredCharacters.js +140 -0
- package/utilities/stripIgnoredCharacters.js.flow +129 -0
- package/utilities/stripIgnoredCharacters.mjs +127 -0
- package/utilities/typeComparators.js +2 -2
- package/utilities/typeComparators.js.flow +4 -3
- package/utilities/typeComparators.mjs +2 -2
- package/utilities/typeFromAST.js +9 -4
- package/utilities/typeFromAST.js.flow +15 -9
- package/utilities/typeFromAST.mjs +6 -4
- package/utilities/valueFromAST.js +7 -4
- package/utilities/valueFromAST.js.flow +7 -5
- package/utilities/valueFromAST.mjs +6 -4
- package/utilities/valueFromASTUntyped.js +11 -6
- package/utilities/valueFromASTUntyped.js.flow +9 -5
- package/utilities/valueFromASTUntyped.mjs +10 -6
- package/validation/ValidationContext.js +1 -1
- package/validation/ValidationContext.js.flow +19 -20
- package/validation/ValidationContext.mjs +2 -2
- package/validation/index.js +1 -1
- package/validation/index.js.flow +2 -1
- package/validation/index.mjs +3 -2
- package/validation/rules/ExecutableDefinitions.js +3 -3
- package/validation/rules/ExecutableDefinitions.js.flow +4 -4
- package/validation/rules/ExecutableDefinitions.mjs +3 -3
- package/validation/rules/FieldsOnCorrectType.js +3 -3
- package/validation/rules/FieldsOnCorrectType.js.flow +7 -7
- package/validation/rules/FieldsOnCorrectType.mjs +3 -3
- package/validation/rules/FragmentsOnCompositeTypes.js +4 -4
- package/validation/rules/FragmentsOnCompositeTypes.js.flow +5 -5
- package/validation/rules/FragmentsOnCompositeTypes.mjs +4 -4
- package/validation/rules/KnownArgumentNames.js +1 -1
- package/validation/rules/KnownArgumentNames.js.flow +5 -5
- package/validation/rules/KnownArgumentNames.mjs +2 -2
- package/validation/rules/KnownDirectives.js +8 -6
- package/validation/rules/KnownDirectives.js.flow +11 -9
- package/validation/rules/KnownDirectives.mjs +8 -6
- package/validation/rules/KnownFragmentNames.js +3 -3
- package/validation/rules/KnownFragmentNames.js.flow +4 -4
- package/validation/rules/KnownFragmentNames.mjs +3 -3
- package/validation/rules/KnownTypeNames.js +2 -2
- package/validation/rules/KnownTypeNames.js.flow +6 -6
- package/validation/rules/KnownTypeNames.mjs +2 -2
- package/validation/rules/LoneAnonymousOperation.js +3 -3
- package/validation/rules/LoneAnonymousOperation.js.flow +4 -4
- package/validation/rules/LoneAnonymousOperation.mjs +3 -3
- package/validation/rules/LoneSchemaDefinition.js +2 -2
- package/validation/rules/LoneSchemaDefinition.js.flow +3 -3
- package/validation/rules/LoneSchemaDefinition.mjs +2 -2
- package/validation/rules/NoFragmentCycles.js +2 -2
- package/validation/rules/NoFragmentCycles.js.flow +4 -4
- package/validation/rules/NoFragmentCycles.mjs +2 -2
- package/validation/rules/NoUndefinedVariables.js +2 -2
- package/validation/rules/NoUndefinedVariables.js.flow +3 -3
- package/validation/rules/NoUndefinedVariables.mjs +2 -2
- package/validation/rules/NoUnusedFragments.js +7 -7
- package/validation/rules/NoUnusedFragments.js.flow +4 -4
- package/validation/rules/NoUnusedFragments.mjs +7 -7
- package/validation/rules/NoUnusedVariables.js +5 -5
- package/validation/rules/NoUnusedVariables.js.flow +6 -5
- package/validation/rules/NoUnusedVariables.mjs +5 -5
- package/validation/rules/OverlappingFieldsCanBeMerged.js +26 -23
- package/validation/rules/OverlappingFieldsCanBeMerged.js.flow +17 -17
- package/validation/rules/OverlappingFieldsCanBeMerged.mjs +26 -23
- package/validation/rules/PossibleFragmentSpreads.js +4 -4
- package/validation/rules/PossibleFragmentSpreads.js.flow +5 -5
- package/validation/rules/PossibleFragmentSpreads.mjs +4 -4
- package/validation/rules/PossibleTypeExtensions.js +3 -3
- package/validation/rules/PossibleTypeExtensions.js.flow +5 -5
- package/validation/rules/PossibleTypeExtensions.mjs +4 -4
- package/validation/rules/ProvidedRequiredArguments.js +6 -8
- package/validation/rules/ProvidedRequiredArguments.js.flow +8 -8
- package/validation/rules/ProvidedRequiredArguments.mjs +7 -9
- package/validation/rules/ScalarLeafs.js +4 -4
- package/validation/rules/ScalarLeafs.js.flow +6 -6
- package/validation/rules/ScalarLeafs.mjs +4 -4
- package/validation/rules/SingleFieldSubscriptions.js +2 -2
- package/validation/rules/SingleFieldSubscriptions.js.flow +4 -4
- package/validation/rules/SingleFieldSubscriptions.mjs +2 -2
- package/validation/rules/UniqueArgumentNames.js +2 -2
- package/validation/rules/UniqueArgumentNames.js.flow +3 -3
- package/validation/rules/UniqueArgumentNames.mjs +2 -2
- package/validation/rules/UniqueDirectiveNames.js +2 -2
- package/validation/rules/UniqueDirectiveNames.js.flow +3 -3
- package/validation/rules/UniqueDirectiveNames.mjs +2 -2
- package/validation/rules/UniqueDirectivesPerLocation.js +3 -2
- package/validation/rules/UniqueDirectivesPerLocation.js.flow +4 -4
- package/validation/rules/UniqueDirectivesPerLocation.mjs +3 -2
- package/validation/rules/UniqueEnumValueNames.js +4 -8
- package/validation/rules/UniqueEnumValueNames.js.flow +6 -8
- package/validation/rules/UniqueEnumValueNames.mjs +4 -8
- package/validation/rules/UniqueFieldDefinitionNames.js +4 -8
- package/validation/rules/UniqueFieldDefinitionNames.js.flow +6 -8
- package/validation/rules/UniqueFieldDefinitionNames.mjs +4 -8
- package/validation/rules/UniqueFragmentNames.js +2 -2
- package/validation/rules/UniqueFragmentNames.js.flow +3 -3
- package/validation/rules/UniqueFragmentNames.mjs +2 -2
- package/validation/rules/UniqueInputFieldNames.js +2 -4
- package/validation/rules/UniqueInputFieldNames.js.flow +3 -4
- package/validation/rules/UniqueInputFieldNames.mjs +2 -4
- package/validation/rules/UniqueOperationNames.js +2 -2
- package/validation/rules/UniqueOperationNames.js.flow +3 -3
- package/validation/rules/UniqueOperationNames.mjs +2 -2
- package/validation/rules/UniqueOperationTypes.js +2 -2
- package/validation/rules/UniqueOperationTypes.js.flow +3 -3
- package/validation/rules/UniqueOperationTypes.mjs +2 -2
- package/validation/rules/UniqueTypeNames.js +2 -2
- package/validation/rules/UniqueTypeNames.js.flow +4 -4
- package/validation/rules/UniqueTypeNames.mjs +2 -2
- package/validation/rules/UniqueVariableNames.js +2 -2
- package/validation/rules/UniqueVariableNames.js.flow +4 -4
- package/validation/rules/UniqueVariableNames.mjs +2 -2
- package/validation/rules/ValuesOfCorrectType.js +2 -2
- package/validation/rules/ValuesOfCorrectType.js.flow +5 -5
- package/validation/rules/ValuesOfCorrectType.mjs +2 -2
- package/validation/rules/VariablesAreInputTypes.js +3 -3
- package/validation/rules/VariablesAreInputTypes.js.flow +5 -5
- package/validation/rules/VariablesAreInputTypes.mjs +3 -3
- package/validation/rules/VariablesInAllowedPosition.js +3 -3
- package/validation/rules/VariablesInAllowedPosition.js.flow +7 -8
- package/validation/rules/VariablesInAllowedPosition.mjs +3 -3
- package/validation/specifiedRules.js +2 -2
- package/validation/specifiedRules.js.flow +13 -6
- package/validation/specifiedRules.mjs +7 -7
- package/validation/validate.js +2 -2
- package/validation/validate.js.flow +10 -6
- package/validation/validate.mjs +2 -2
- package/jsutils/MaybePromise.js +0 -1
- package/jsutils/MaybePromise.mjs +0 -0
- package/language/blockStringValue.js +0 -73
- package/language/blockStringValue.js.flow +0 -64
- package/language/blockStringValue.mjs +0 -66
package/language/parser.js
CHANGED
|
@@ -27,7 +27,7 @@ var _directiveLocation = require("./directiveLocation");
|
|
|
27
27
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
-
* Copyright (c)
|
|
30
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
31
31
|
*
|
|
32
32
|
* This source code is licensed under the MIT license found in the
|
|
33
33
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -64,9 +64,9 @@ function parse(source, options) {
|
|
|
64
64
|
function parseValue(source, options) {
|
|
65
65
|
var sourceObj = typeof source === 'string' ? new _source.Source(source) : source;
|
|
66
66
|
var lexer = (0, _lexer.createLexer)(sourceObj, options || {});
|
|
67
|
-
|
|
67
|
+
expectToken(lexer, _lexer.TokenKind.SOF);
|
|
68
68
|
var value = parseValueLiteral(lexer, false);
|
|
69
|
-
|
|
69
|
+
expectToken(lexer, _lexer.TokenKind.EOF);
|
|
70
70
|
return value;
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
@@ -84,9 +84,9 @@ function parseValue(source, options) {
|
|
|
84
84
|
function parseType(source, options) {
|
|
85
85
|
var sourceObj = typeof source === 'string' ? new _source.Source(source) : source;
|
|
86
86
|
var lexer = (0, _lexer.createLexer)(sourceObj, options || {});
|
|
87
|
-
|
|
87
|
+
expectToken(lexer, _lexer.TokenKind.SOF);
|
|
88
88
|
var type = parseTypeReference(lexer);
|
|
89
|
-
|
|
89
|
+
expectToken(lexer, _lexer.TokenKind.EOF);
|
|
90
90
|
return type;
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
@@ -95,7 +95,7 @@ function parseType(source, options) {
|
|
|
95
95
|
|
|
96
96
|
|
|
97
97
|
function parseName(lexer) {
|
|
98
|
-
var token =
|
|
98
|
+
var token = expectToken(lexer, _lexer.TokenKind.NAME);
|
|
99
99
|
return {
|
|
100
100
|
kind: _kinds.Kind.NAME,
|
|
101
101
|
value: token.value,
|
|
@@ -224,7 +224,7 @@ function parseOperationDefinition(lexer) {
|
|
|
224
224
|
|
|
225
225
|
|
|
226
226
|
function parseOperationType(lexer) {
|
|
227
|
-
var operationToken =
|
|
227
|
+
var operationToken = expectToken(lexer, _lexer.TokenKind.NAME);
|
|
228
228
|
|
|
229
229
|
switch (operationToken.value) {
|
|
230
230
|
case 'query':
|
|
@@ -257,8 +257,8 @@ function parseVariableDefinition(lexer) {
|
|
|
257
257
|
return {
|
|
258
258
|
kind: _kinds.Kind.VARIABLE_DEFINITION,
|
|
259
259
|
variable: parseVariable(lexer),
|
|
260
|
-
type: (
|
|
261
|
-
defaultValue:
|
|
260
|
+
type: (expectToken(lexer, _lexer.TokenKind.COLON), parseTypeReference(lexer)),
|
|
261
|
+
defaultValue: expectOptionalToken(lexer, _lexer.TokenKind.EQUALS) ? parseValueLiteral(lexer, true) : undefined,
|
|
262
262
|
directives: parseDirectives(lexer, true),
|
|
263
263
|
loc: loc(lexer, start)
|
|
264
264
|
};
|
|
@@ -270,7 +270,7 @@ function parseVariableDefinition(lexer) {
|
|
|
270
270
|
|
|
271
271
|
function parseVariable(lexer) {
|
|
272
272
|
var start = lexer.token;
|
|
273
|
-
|
|
273
|
+
expectToken(lexer, _lexer.TokenKind.DOLLAR);
|
|
274
274
|
return {
|
|
275
275
|
kind: _kinds.Kind.VARIABLE,
|
|
276
276
|
name: parseName(lexer),
|
|
@@ -314,7 +314,7 @@ function parseField(lexer) {
|
|
|
314
314
|
var alias;
|
|
315
315
|
var name;
|
|
316
316
|
|
|
317
|
-
if (
|
|
317
|
+
if (expectOptionalToken(lexer, _lexer.TokenKind.COLON)) {
|
|
318
318
|
alias = nameOrAlias;
|
|
319
319
|
name = parseName(lexer);
|
|
320
320
|
} else {
|
|
@@ -347,10 +347,12 @@ function parseArguments(lexer, isConst) {
|
|
|
347
347
|
|
|
348
348
|
function parseArgument(lexer) {
|
|
349
349
|
var start = lexer.token;
|
|
350
|
+
var name = parseName(lexer);
|
|
351
|
+
expectToken(lexer, _lexer.TokenKind.COLON);
|
|
350
352
|
return {
|
|
351
353
|
kind: _kinds.Kind.ARGUMENT,
|
|
352
|
-
name:
|
|
353
|
-
value:
|
|
354
|
+
name: name,
|
|
355
|
+
value: parseValueLiteral(lexer, false),
|
|
354
356
|
loc: loc(lexer, start)
|
|
355
357
|
};
|
|
356
358
|
}
|
|
@@ -360,7 +362,7 @@ function parseConstArgument(lexer) {
|
|
|
360
362
|
return {
|
|
361
363
|
kind: _kinds.Kind.ARGUMENT,
|
|
362
364
|
name: parseName(lexer),
|
|
363
|
-
value: (
|
|
365
|
+
value: (expectToken(lexer, _lexer.TokenKind.COLON), parseConstValue(lexer)),
|
|
364
366
|
loc: loc(lexer, start)
|
|
365
367
|
};
|
|
366
368
|
} // Implements the parsing rules in the Fragments section.
|
|
@@ -376,8 +378,8 @@ function parseConstArgument(lexer) {
|
|
|
376
378
|
|
|
377
379
|
function parseFragment(lexer) {
|
|
378
380
|
var start = lexer.token;
|
|
379
|
-
|
|
380
|
-
var hasTypeCondition =
|
|
381
|
+
expectToken(lexer, _lexer.TokenKind.SPREAD);
|
|
382
|
+
var hasTypeCondition = expectOptionalKeyword(lexer, 'on');
|
|
381
383
|
|
|
382
384
|
if (!hasTypeCondition && peek(lexer, _lexer.TokenKind.NAME)) {
|
|
383
385
|
return {
|
|
@@ -571,16 +573,14 @@ function parseList(lexer, isConst) {
|
|
|
571
573
|
|
|
572
574
|
function parseObject(lexer, isConst) {
|
|
573
575
|
var start = lexer.token;
|
|
574
|
-
expect(lexer, _lexer.TokenKind.BRACE_L);
|
|
575
|
-
var fields = [];
|
|
576
576
|
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
}
|
|
577
|
+
var item = function item() {
|
|
578
|
+
return parseObjectField(lexer, isConst);
|
|
579
|
+
};
|
|
580
580
|
|
|
581
581
|
return {
|
|
582
582
|
kind: _kinds.Kind.OBJECT,
|
|
583
|
-
fields:
|
|
583
|
+
fields: any(lexer, _lexer.TokenKind.BRACE_L, item, _lexer.TokenKind.BRACE_R),
|
|
584
584
|
loc: loc(lexer, start)
|
|
585
585
|
};
|
|
586
586
|
}
|
|
@@ -591,10 +591,12 @@ function parseObject(lexer, isConst) {
|
|
|
591
591
|
|
|
592
592
|
function parseObjectField(lexer, isConst) {
|
|
593
593
|
var start = lexer.token;
|
|
594
|
+
var name = parseName(lexer);
|
|
595
|
+
expectToken(lexer, _lexer.TokenKind.COLON);
|
|
594
596
|
return {
|
|
595
597
|
kind: _kinds.Kind.OBJECT_FIELD,
|
|
596
|
-
name:
|
|
597
|
-
value:
|
|
598
|
+
name: name,
|
|
599
|
+
value: parseValueLiteral(lexer, isConst),
|
|
598
600
|
loc: loc(lexer, start)
|
|
599
601
|
};
|
|
600
602
|
} // Implements the parsing rules in the Directives section.
|
|
@@ -620,7 +622,7 @@ function parseDirectives(lexer, isConst) {
|
|
|
620
622
|
|
|
621
623
|
function parseDirective(lexer, isConst) {
|
|
622
624
|
var start = lexer.token;
|
|
623
|
-
|
|
625
|
+
expectToken(lexer, _lexer.TokenKind.AT);
|
|
624
626
|
return {
|
|
625
627
|
kind: _kinds.Kind.DIRECTIVE,
|
|
626
628
|
name: parseName(lexer),
|
|
@@ -641,9 +643,9 @@ function parseTypeReference(lexer) {
|
|
|
641
643
|
var start = lexer.token;
|
|
642
644
|
var type;
|
|
643
645
|
|
|
644
|
-
if (
|
|
646
|
+
if (expectOptionalToken(lexer, _lexer.TokenKind.BRACKET_L)) {
|
|
645
647
|
type = parseTypeReference(lexer);
|
|
646
|
-
|
|
648
|
+
expectToken(lexer, _lexer.TokenKind.BRACKET_R);
|
|
647
649
|
type = {
|
|
648
650
|
kind: _kinds.Kind.LIST_TYPE,
|
|
649
651
|
type: type,
|
|
@@ -653,7 +655,7 @@ function parseTypeReference(lexer) {
|
|
|
653
655
|
type = parseNamedType(lexer);
|
|
654
656
|
}
|
|
655
657
|
|
|
656
|
-
if (
|
|
658
|
+
if (expectOptionalToken(lexer, _lexer.TokenKind.BANG)) {
|
|
657
659
|
return {
|
|
658
660
|
kind: _kinds.Kind.NON_NULL_TYPE,
|
|
659
661
|
type: type,
|
|
@@ -766,7 +768,7 @@ function parseSchemaDefinition(lexer) {
|
|
|
766
768
|
function parseOperationTypeDefinition(lexer) {
|
|
767
769
|
var start = lexer.token;
|
|
768
770
|
var operation = parseOperationType(lexer);
|
|
769
|
-
|
|
771
|
+
expectToken(lexer, _lexer.TokenKind.COLON);
|
|
770
772
|
var type = parseNamedType(lexer);
|
|
771
773
|
return {
|
|
772
774
|
kind: _kinds.Kind.OPERATION_TYPE_DEFINITION,
|
|
@@ -829,13 +831,13 @@ function parseObjectTypeDefinition(lexer) {
|
|
|
829
831
|
function parseImplementsInterfaces(lexer) {
|
|
830
832
|
var types = [];
|
|
831
833
|
|
|
832
|
-
if (
|
|
834
|
+
if (expectOptionalKeyword(lexer, 'implements')) {
|
|
833
835
|
// Optional leading ampersand
|
|
834
|
-
|
|
836
|
+
expectOptionalToken(lexer, _lexer.TokenKind.AMP);
|
|
835
837
|
|
|
836
838
|
do {
|
|
837
839
|
types.push(parseNamedType(lexer));
|
|
838
|
-
} while (
|
|
840
|
+
} while (expectOptionalToken(lexer, _lexer.TokenKind.AMP) || // Legacy support for the SDL?
|
|
839
841
|
lexer.options.allowLegacySDLImplementsInterfaces && peek(lexer, _lexer.TokenKind.NAME));
|
|
840
842
|
}
|
|
841
843
|
|
|
@@ -867,7 +869,7 @@ function parseFieldDefinition(lexer) {
|
|
|
867
869
|
var description = parseDescription(lexer);
|
|
868
870
|
var name = parseName(lexer);
|
|
869
871
|
var args = parseArgumentDefs(lexer);
|
|
870
|
-
|
|
872
|
+
expectToken(lexer, _lexer.TokenKind.COLON);
|
|
871
873
|
var type = parseTypeReference(lexer);
|
|
872
874
|
var directives = parseDirectives(lexer, true);
|
|
873
875
|
return {
|
|
@@ -902,11 +904,11 @@ function parseInputValueDef(lexer) {
|
|
|
902
904
|
var start = lexer.token;
|
|
903
905
|
var description = parseDescription(lexer);
|
|
904
906
|
var name = parseName(lexer);
|
|
905
|
-
|
|
907
|
+
expectToken(lexer, _lexer.TokenKind.COLON);
|
|
906
908
|
var type = parseTypeReference(lexer);
|
|
907
909
|
var defaultValue;
|
|
908
910
|
|
|
909
|
-
if (
|
|
911
|
+
if (expectOptionalToken(lexer, _lexer.TokenKind.EQUALS)) {
|
|
910
912
|
defaultValue = parseConstValue(lexer);
|
|
911
913
|
}
|
|
912
914
|
|
|
@@ -975,13 +977,13 @@ function parseUnionTypeDefinition(lexer) {
|
|
|
975
977
|
function parseUnionMemberTypes(lexer) {
|
|
976
978
|
var types = [];
|
|
977
979
|
|
|
978
|
-
if (
|
|
980
|
+
if (expectOptionalToken(lexer, _lexer.TokenKind.EQUALS)) {
|
|
979
981
|
// Optional leading pipe
|
|
980
|
-
|
|
982
|
+
expectOptionalToken(lexer, _lexer.TokenKind.PIPE);
|
|
981
983
|
|
|
982
984
|
do {
|
|
983
985
|
types.push(parseNamedType(lexer));
|
|
984
|
-
} while (
|
|
986
|
+
} while (expectOptionalToken(lexer, _lexer.TokenKind.PIPE));
|
|
985
987
|
}
|
|
986
988
|
|
|
987
989
|
return types;
|
|
@@ -1308,7 +1310,7 @@ function parseDirectiveDefinition(lexer) {
|
|
|
1308
1310
|
var start = lexer.token;
|
|
1309
1311
|
var description = parseDescription(lexer);
|
|
1310
1312
|
expectKeyword(lexer, 'directive');
|
|
1311
|
-
|
|
1313
|
+
expectToken(lexer, _lexer.TokenKind.AT);
|
|
1312
1314
|
var name = parseName(lexer);
|
|
1313
1315
|
var args = parseArgumentDefs(lexer);
|
|
1314
1316
|
expectKeyword(lexer, 'on');
|
|
@@ -1331,12 +1333,12 @@ function parseDirectiveDefinition(lexer) {
|
|
|
1331
1333
|
|
|
1332
1334
|
function parseDirectiveLocations(lexer) {
|
|
1333
1335
|
// Optional leading pipe
|
|
1334
|
-
|
|
1336
|
+
expectOptionalToken(lexer, _lexer.TokenKind.PIPE);
|
|
1335
1337
|
var locations = [];
|
|
1336
1338
|
|
|
1337
1339
|
do {
|
|
1338
1340
|
locations.push(parseDirectiveLocation(lexer));
|
|
1339
|
-
} while (
|
|
1341
|
+
} while (expectOptionalToken(lexer, _lexer.TokenKind.PIPE));
|
|
1340
1342
|
|
|
1341
1343
|
return locations;
|
|
1342
1344
|
}
|
|
@@ -1373,7 +1375,7 @@ function parseDirectiveLocation(lexer) {
|
|
|
1373
1375
|
var start = lexer.token;
|
|
1374
1376
|
var name = parseName(lexer);
|
|
1375
1377
|
|
|
1376
|
-
if (_directiveLocation.DirectiveLocation
|
|
1378
|
+
if (_directiveLocation.DirectiveLocation[name.value] !== undefined) {
|
|
1377
1379
|
return name;
|
|
1378
1380
|
}
|
|
1379
1381
|
|
|
@@ -1415,26 +1417,28 @@ function peek(lexer, kind) {
|
|
|
1415
1417
|
return lexer.token.kind === kind;
|
|
1416
1418
|
}
|
|
1417
1419
|
/**
|
|
1418
|
-
* If the next token is of the given kind, return
|
|
1419
|
-
* the lexer. Otherwise, do not change the parser state and
|
|
1420
|
+
* If the next token is of the given kind, return that token after advancing
|
|
1421
|
+
* the lexer. Otherwise, do not change the parser state and throw an error.
|
|
1420
1422
|
*/
|
|
1421
1423
|
|
|
1422
1424
|
|
|
1423
|
-
function
|
|
1424
|
-
|
|
1425
|
+
function expectToken(lexer, kind) {
|
|
1426
|
+
var token = lexer.token;
|
|
1427
|
+
|
|
1428
|
+
if (token.kind === kind) {
|
|
1425
1429
|
lexer.advance();
|
|
1426
|
-
return
|
|
1430
|
+
return token;
|
|
1427
1431
|
}
|
|
1428
1432
|
|
|
1429
|
-
|
|
1433
|
+
throw (0, _error.syntaxError)(lexer.source, token.start, "Expected ".concat(kind, ", found ").concat((0, _lexer.getTokenDesc)(token)));
|
|
1430
1434
|
}
|
|
1431
1435
|
/**
|
|
1432
1436
|
* If the next token is of the given kind, return that token after advancing
|
|
1433
|
-
* the lexer. Otherwise, do not change the parser state and
|
|
1437
|
+
* the lexer. Otherwise, do not change the parser state and return undefined.
|
|
1434
1438
|
*/
|
|
1435
1439
|
|
|
1436
1440
|
|
|
1437
|
-
function
|
|
1441
|
+
function expectOptionalToken(lexer, kind) {
|
|
1438
1442
|
var token = lexer.token;
|
|
1439
1443
|
|
|
1440
1444
|
if (token.kind === kind) {
|
|
@@ -1442,35 +1446,39 @@ function expect(lexer, kind) {
|
|
|
1442
1446
|
return token;
|
|
1443
1447
|
}
|
|
1444
1448
|
|
|
1445
|
-
|
|
1449
|
+
return undefined;
|
|
1446
1450
|
}
|
|
1447
1451
|
/**
|
|
1448
|
-
* If the next token is a
|
|
1449
|
-
* the lexer. Otherwise, do not change the parser state and
|
|
1452
|
+
* If the next token is a given keyword, return that token after advancing
|
|
1453
|
+
* the lexer. Otherwise, do not change the parser state and throw an error.
|
|
1450
1454
|
*/
|
|
1451
1455
|
|
|
1452
1456
|
|
|
1453
|
-
function
|
|
1457
|
+
function expectKeyword(lexer, value) {
|
|
1454
1458
|
var token = lexer.token;
|
|
1455
1459
|
|
|
1456
1460
|
if (token.kind === _lexer.TokenKind.NAME && token.value === value) {
|
|
1457
1461
|
lexer.advance();
|
|
1458
|
-
return
|
|
1462
|
+
return token;
|
|
1459
1463
|
}
|
|
1460
1464
|
|
|
1461
|
-
|
|
1465
|
+
throw (0, _error.syntaxError)(lexer.source, token.start, "Expected \"".concat(value, "\", found ").concat((0, _lexer.getTokenDesc)(token)));
|
|
1462
1466
|
}
|
|
1463
1467
|
/**
|
|
1464
|
-
* If the next token is a
|
|
1465
|
-
*
|
|
1466
|
-
* an error.
|
|
1468
|
+
* If the next token is a given keyword, return that token after advancing
|
|
1469
|
+
* the lexer. Otherwise, do not change the parser state and return undefined.
|
|
1467
1470
|
*/
|
|
1468
1471
|
|
|
1469
1472
|
|
|
1470
|
-
function
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
+
function expectOptionalKeyword(lexer, value) {
|
|
1474
|
+
var token = lexer.token;
|
|
1475
|
+
|
|
1476
|
+
if (token.kind === _lexer.TokenKind.NAME && token.value === value) {
|
|
1477
|
+
lexer.advance();
|
|
1478
|
+
return token;
|
|
1473
1479
|
}
|
|
1480
|
+
|
|
1481
|
+
return undefined;
|
|
1474
1482
|
}
|
|
1475
1483
|
/**
|
|
1476
1484
|
* Helper function for creating an error when an unexpected lexed token
|
|
@@ -1491,10 +1499,10 @@ function unexpected(lexer, atToken) {
|
|
|
1491
1499
|
|
|
1492
1500
|
|
|
1493
1501
|
function any(lexer, openKind, parseFn, closeKind) {
|
|
1494
|
-
|
|
1502
|
+
expectToken(lexer, openKind);
|
|
1495
1503
|
var nodes = [];
|
|
1496
1504
|
|
|
1497
|
-
while (!
|
|
1505
|
+
while (!expectOptionalToken(lexer, closeKind)) {
|
|
1498
1506
|
nodes.push(parseFn(lexer));
|
|
1499
1507
|
}
|
|
1500
1508
|
|
|
@@ -1509,12 +1517,12 @@ function any(lexer, openKind, parseFn, closeKind) {
|
|
|
1509
1517
|
|
|
1510
1518
|
|
|
1511
1519
|
function many(lexer, openKind, parseFn, closeKind) {
|
|
1512
|
-
|
|
1520
|
+
expectToken(lexer, openKind);
|
|
1513
1521
|
var nodes = [parseFn(lexer)];
|
|
1514
1522
|
|
|
1515
|
-
while (!
|
|
1523
|
+
while (!expectOptionalToken(lexer, closeKind)) {
|
|
1516
1524
|
nodes.push(parseFn(lexer));
|
|
1517
1525
|
}
|
|
1518
1526
|
|
|
1519
1527
|
return nodes;
|
|
1520
|
-
}
|
|
1528
|
+
}
|