graphql 16.14.0 → 16.14.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/error/GraphQLError.d.ts +151 -15
- package/error/GraphQLError.js +143 -12
- package/error/GraphQLError.mjs +143 -12
- package/error/index.d.ts +6 -0
- package/error/index.mjs +6 -0
- package/error/locatedError.d.ts +20 -0
- package/error/locatedError.js +21 -0
- package/error/locatedError.mjs +20 -0
- package/error/syntaxError.d.ts +15 -0
- package/error/syntaxError.js +16 -0
- package/error/syntaxError.mjs +15 -0
- package/execution/collectFields.js +6 -0
- package/execution/collectFields.mjs +6 -0
- package/execution/execute.d.ts +211 -12
- package/execution/execute.js +214 -23
- package/execution/execute.mjs +213 -23
- package/execution/index.d.ts +6 -0
- package/execution/index.mjs +6 -0
- package/execution/mapAsyncIterator.d.ts +2 -0
- package/execution/mapAsyncIterator.js +2 -0
- package/execution/mapAsyncIterator.mjs +2 -0
- package/execution/subscribe.d.ts +195 -5
- package/execution/subscribe.js +154 -11
- package/execution/subscribe.mjs +153 -11
- package/execution/values.d.ts +167 -10
- package/execution/values.js +149 -5
- package/execution/values.mjs +148 -5
- package/graphql.d.ts +163 -41
- package/graphql.js +126 -4
- package/graphql.mjs +131 -41
- package/index.d.ts +11 -17
- package/index.mjs +13 -19
- package/jsutils/Maybe.d.ts +5 -1
- package/jsutils/ObjMap.d.ts +4 -0
- package/jsutils/Path.d.ts +30 -0
- package/jsutils/Path.js +29 -0
- package/jsutils/Path.mjs +29 -0
- package/jsutils/PromiseOrValue.d.ts +1 -0
- package/jsutils/devAssert.d.ts +1 -0
- package/jsutils/devAssert.js +1 -0
- package/jsutils/devAssert.mjs +1 -0
- package/jsutils/didYouMean.d.ts +4 -1
- package/jsutils/didYouMean.js +4 -1
- package/jsutils/didYouMean.mjs +4 -1
- package/jsutils/groupBy.d.ts +2 -0
- package/jsutils/groupBy.js +2 -0
- package/jsutils/groupBy.mjs +2 -0
- package/jsutils/identityFunc.d.ts +2 -0
- package/jsutils/identityFunc.js +2 -0
- package/jsutils/identityFunc.mjs +2 -0
- package/jsutils/inspect.d.ts +2 -0
- package/jsutils/inspect.js +2 -0
- package/jsutils/inspect.mjs +2 -0
- package/jsutils/instanceOf.d.ts +2 -0
- package/jsutils/instanceOf.js +2 -0
- package/jsutils/instanceOf.mjs +2 -0
- package/jsutils/invariant.d.ts +1 -0
- package/jsutils/invariant.js +1 -0
- package/jsutils/invariant.mjs +1 -0
- package/jsutils/isAsyncIterable.d.ts +2 -0
- package/jsutils/isAsyncIterable.js +2 -0
- package/jsutils/isAsyncIterable.mjs +2 -0
- package/jsutils/isIterableObject.d.ts +6 -5
- package/jsutils/isIterableObject.js +6 -5
- package/jsutils/isIterableObject.mjs +6 -5
- package/jsutils/isObjectLike.d.ts +2 -0
- package/jsutils/isObjectLike.js +2 -0
- package/jsutils/isObjectLike.mjs +2 -0
- package/jsutils/isPromise.d.ts +2 -0
- package/jsutils/isPromise.js +2 -0
- package/jsutils/isPromise.mjs +2 -0
- package/jsutils/keyMap.d.ts +7 -14
- package/jsutils/keyMap.js +7 -14
- package/jsutils/keyMap.mjs +7 -14
- package/jsutils/keyValMap.d.ts +9 -6
- package/jsutils/keyValMap.js +9 -6
- package/jsutils/keyValMap.mjs +9 -6
- package/jsutils/mapValue.d.ts +2 -0
- package/jsutils/mapValue.js +2 -0
- package/jsutils/mapValue.mjs +2 -0
- package/jsutils/memoize3.d.ts +2 -0
- package/jsutils/memoize3.js +2 -0
- package/jsutils/memoize3.mjs +2 -0
- package/jsutils/naturalCompare.d.ts +2 -0
- package/jsutils/naturalCompare.js +2 -0
- package/jsutils/naturalCompare.mjs +2 -0
- package/jsutils/printPathArray.d.ts +2 -0
- package/jsutils/printPathArray.js +2 -0
- package/jsutils/printPathArray.mjs +2 -0
- package/jsutils/promiseForObject.d.ts +2 -0
- package/jsutils/promiseForObject.js +2 -0
- package/jsutils/promiseForObject.mjs +2 -0
- package/jsutils/promiseReduce.d.ts +2 -0
- package/jsutils/promiseReduce.js +2 -0
- package/jsutils/promiseReduce.mjs +2 -0
- package/jsutils/suggestionList.d.ts +2 -0
- package/jsutils/suggestionList.js +4 -0
- package/jsutils/suggestionList.mjs +4 -0
- package/jsutils/toError.d.ts +2 -0
- package/jsutils/toError.js +2 -0
- package/jsutils/toError.mjs +2 -0
- package/jsutils/toObjMap.d.ts +1 -0
- package/jsutils/toObjMap.js +1 -0
- package/jsutils/toObjMap.mjs +1 -0
- package/language/ast.d.ts +412 -54
- package/language/ast.js +95 -38
- package/language/ast.mjs +95 -38
- package/language/blockString.d.ts +1 -3
- package/language/blockString.js +1 -3
- package/language/blockString.mjs +1 -3
- package/language/directiveLocation.d.ts +28 -8
- package/language/directiveLocation.js +9 -6
- package/language/directiveLocation.mjs +9 -6
- package/language/index.d.ts +6 -0
- package/language/index.mjs +6 -0
- package/language/kinds.d.ts +57 -18
- package/language/kinds.js +9 -6
- package/language/kinds.mjs +9 -6
- package/language/lexer.d.ts +47 -14
- package/language/lexer.js +71 -13
- package/language/lexer.mjs +70 -13
- package/language/location.d.ts +16 -3
- package/language/location.js +14 -3
- package/language/location.mjs +14 -3
- package/language/parser.d.ts +236 -13
- package/language/parser.js +224 -0
- package/language/parser.mjs +224 -3
- package/language/predicates.d.ts +169 -0
- package/language/predicates.js +170 -0
- package/language/predicates.mjs +180 -0
- package/language/printLocation.d.ts +28 -0
- package/language/printLocation.js +29 -0
- package/language/printLocation.mjs +28 -0
- package/language/printString.d.ts +2 -0
- package/language/printString.js +5 -1
- package/language/printString.mjs +5 -1
- package/language/printer.d.ts +12 -0
- package/language/printer.js +19 -0
- package/language/printer.mjs +18 -0
- package/language/schemaCoordinateLexer.d.ts +8 -6
- package/language/schemaCoordinateLexer.js +10 -6
- package/language/schemaCoordinateLexer.mjs +10 -6
- package/language/source.d.ts +28 -0
- package/language/source.js +32 -0
- package/language/source.mjs +31 -0
- package/language/tokenKind.d.ts +30 -3
- package/language/tokenKind.js +8 -3
- package/language/tokenKind.mjs +8 -3
- package/language/visitor.d.ts +200 -72
- package/language/visitor.js +122 -50
- package/language/visitor.mjs +122 -54
- package/package.json +1 -1
- package/subscription/index.d.ts +9 -3
- package/subscription/index.mjs +9 -3
- package/type/assertName.d.ts +18 -1
- package/type/assertName.js +19 -1
- package/type/assertName.mjs +18 -1
- package/type/definition.d.ts +2540 -79
- package/type/definition.js +2214 -61
- package/type/definition.mjs +2241 -60
- package/type/directives.d.ts +193 -18
- package/type/directives.js +196 -19
- package/type/directives.mjs +196 -19
- package/type/index.d.ts +6 -0
- package/type/index.mjs +6 -0
- package/type/introspection.d.ts +36 -0
- package/type/introspection.js +33 -0
- package/type/introspection.mjs +41 -0
- package/type/scalars.d.ts +29 -2
- package/type/scalars.js +37 -2
- package/type/scalars.mjs +36 -2
- package/type/schema.d.ts +490 -28
- package/type/schema.js +484 -26
- package/type/schema.mjs +484 -26
- package/type/validate.d.ts +31 -0
- package/type/validate.js +32 -0
- package/type/validate.mjs +31 -0
- package/utilities/TypeInfo.d.ts +441 -1
- package/utilities/TypeInfo.js +444 -1
- package/utilities/TypeInfo.mjs +443 -1
- package/utilities/assertValidName.d.ts +27 -2
- package/utilities/assertValidName.js +28 -2
- package/utilities/assertValidName.mjs +27 -2
- package/utilities/astFromValue.d.ts +33 -3
- package/utilities/astFromValue.js +36 -3
- package/utilities/astFromValue.mjs +35 -3
- package/utilities/buildASTSchema.d.ts +65 -6
- package/utilities/buildASTSchema.js +65 -6
- package/utilities/buildASTSchema.mjs +65 -6
- package/utilities/buildClientSchema.d.ts +15 -0
- package/utilities/buildClientSchema.js +16 -0
- package/utilities/buildClientSchema.mjs +15 -0
- package/utilities/coerceInputValue.d.ts +46 -0
- package/utilities/coerceInputValue.js +47 -0
- package/utilities/coerceInputValue.mjs +46 -0
- package/utilities/concatAST.d.ts +12 -0
- package/utilities/concatAST.js +13 -0
- package/utilities/concatAST.mjs +12 -0
- package/utilities/extendSchema.d.ts +56 -3
- package/utilities/extendSchema.js +63 -3
- package/utilities/extendSchema.mjs +62 -3
- package/utilities/findBreakingChanges.d.ts +95 -0
- package/utilities/findBreakingChanges.js +68 -0
- package/utilities/findBreakingChanges.mjs +70 -0
- package/utilities/getIntrospectionQuery.d.ts +132 -0
- package/utilities/getIntrospectionQuery.js +41 -0
- package/utilities/getIntrospectionQuery.mjs +41 -0
- package/utilities/getOperationAST.d.ts +15 -0
- package/utilities/getOperationAST.js +16 -0
- package/utilities/getOperationAST.mjs +15 -0
- package/utilities/getOperationRootType.d.ts +18 -1
- package/utilities/getOperationRootType.js +19 -1
- package/utilities/getOperationRootType.mjs +18 -1
- package/utilities/index.d.ts +7 -0
- package/utilities/index.mjs +7 -0
- package/utilities/introspectionFromSchema.d.ts +54 -0
- package/utilities/introspectionFromSchema.js +55 -0
- package/utilities/introspectionFromSchema.mjs +54 -0
- package/utilities/lexicographicSortSchema.d.ts +35 -0
- package/utilities/lexicographicSortSchema.js +36 -0
- package/utilities/lexicographicSortSchema.mjs +35 -0
- package/utilities/printSchema.d.ts +63 -0
- package/utilities/printSchema.js +66 -0
- package/utilities/printSchema.mjs +67 -0
- package/utilities/resolveSchemaCoordinate.d.ts +62 -0
- package/utilities/resolveSchemaCoordinate.js +64 -0
- package/utilities/resolveSchemaCoordinate.mjs +63 -0
- package/utilities/separateOperations.d.ts +30 -0
- package/utilities/separateOperations.js +31 -0
- package/utilities/separateOperations.mjs +30 -0
- package/utilities/stripIgnoredCharacters.d.ts +13 -6
- package/utilities/stripIgnoredCharacters.js +16 -6
- package/utilities/stripIgnoredCharacters.mjs +15 -6
- package/utilities/typeComparators.d.ts +84 -0
- package/utilities/typeComparators.js +85 -0
- package/utilities/typeComparators.mjs +84 -0
- package/utilities/typeFromAST.d.ts +86 -0
- package/utilities/typeFromAST.js +3 -0
- package/utilities/typeFromAST.mjs +3 -0
- package/utilities/typedQueryDocumentNode.d.ts +4 -0
- package/utilities/valueFromAST.d.ts +38 -0
- package/utilities/valueFromAST.js +39 -0
- package/utilities/valueFromAST.mjs +38 -0
- package/utilities/valueFromASTUntyped.d.ts +15 -2
- package/utilities/valueFromASTUntyped.js +16 -2
- package/utilities/valueFromASTUntyped.mjs +15 -2
- package/validation/ValidationContext.d.ts +399 -0
- package/validation/ValidationContext.js +400 -0
- package/validation/ValidationContext.mjs +401 -0
- package/validation/index.d.ts +6 -0
- package/validation/index.mjs +6 -0
- package/validation/rules/ExecutableDefinitionsRule.d.ts +28 -0
- package/validation/rules/ExecutableDefinitionsRule.js +29 -0
- package/validation/rules/ExecutableDefinitionsRule.mjs +28 -0
- package/validation/rules/FieldsOnCorrectTypeRule.d.ts +28 -0
- package/validation/rules/FieldsOnCorrectTypeRule.js +33 -0
- package/validation/rules/FieldsOnCorrectTypeRule.mjs +32 -0
- package/validation/rules/FragmentsOnCompositeTypesRule.d.ts +28 -0
- package/validation/rules/FragmentsOnCompositeTypesRule.js +29 -0
- package/validation/rules/FragmentsOnCompositeTypesRule.mjs +28 -0
- package/validation/rules/KnownArgumentNamesRule.d.ts +29 -3
- package/validation/rules/KnownArgumentNamesRule.js +30 -3
- package/validation/rules/KnownArgumentNamesRule.mjs +29 -3
- package/validation/rules/KnownDirectivesRule.d.ts +28 -0
- package/validation/rules/KnownDirectivesRule.js +29 -0
- package/validation/rules/KnownDirectivesRule.mjs +28 -0
- package/validation/rules/KnownFragmentNamesRule.d.ts +28 -0
- package/validation/rules/KnownFragmentNamesRule.js +29 -0
- package/validation/rules/KnownFragmentNamesRule.mjs +28 -0
- package/validation/rules/KnownTypeNamesRule.d.ts +28 -0
- package/validation/rules/KnownTypeNamesRule.js +29 -0
- package/validation/rules/KnownTypeNamesRule.mjs +28 -0
- package/validation/rules/LoneAnonymousOperationRule.d.ts +28 -0
- package/validation/rules/LoneAnonymousOperationRule.js +29 -0
- package/validation/rules/LoneAnonymousOperationRule.mjs +28 -0
- package/validation/rules/LoneSchemaDefinitionRule.d.ts +21 -0
- package/validation/rules/LoneSchemaDefinitionRule.js +22 -0
- package/validation/rules/LoneSchemaDefinitionRule.mjs +21 -0
- package/validation/rules/MaxIntrospectionDepthRule.d.ts +31 -0
- package/validation/rules/MaxIntrospectionDepthRule.js +33 -0
- package/validation/rules/MaxIntrospectionDepthRule.mjs +34 -0
- package/validation/rules/NoFragmentCyclesRule.d.ts +28 -0
- package/validation/rules/NoFragmentCyclesRule.js +29 -0
- package/validation/rules/NoFragmentCyclesRule.mjs +28 -0
- package/validation/rules/NoUndefinedVariablesRule.d.ts +28 -0
- package/validation/rules/NoUndefinedVariablesRule.js +29 -0
- package/validation/rules/NoUndefinedVariablesRule.mjs +28 -0
- package/validation/rules/NoUnusedFragmentsRule.d.ts +28 -0
- package/validation/rules/NoUnusedFragmentsRule.js +29 -0
- package/validation/rules/NoUnusedFragmentsRule.mjs +28 -0
- package/validation/rules/NoUnusedVariablesRule.d.ts +29 -0
- package/validation/rules/NoUnusedVariablesRule.js +30 -0
- package/validation/rules/NoUnusedVariablesRule.mjs +29 -0
- package/validation/rules/OverlappingFieldsCanBeMergedRule.d.ts +33 -0
- package/validation/rules/OverlappingFieldsCanBeMergedRule.js +45 -6
- package/validation/rules/OverlappingFieldsCanBeMergedRule.mjs +45 -6
- package/validation/rules/PossibleFragmentSpreadsRule.d.ts +36 -0
- package/validation/rules/PossibleFragmentSpreadsRule.js +37 -0
- package/validation/rules/PossibleFragmentSpreadsRule.mjs +36 -0
- package/validation/rules/PossibleTypeExtensionsRule.d.ts +21 -0
- package/validation/rules/PossibleTypeExtensionsRule.js +22 -0
- package/validation/rules/PossibleTypeExtensionsRule.mjs +21 -0
- package/validation/rules/ProvidedRequiredArgumentsRule.d.ts +29 -3
- package/validation/rules/ProvidedRequiredArgumentsRule.js +30 -3
- package/validation/rules/ProvidedRequiredArgumentsRule.mjs +29 -3
- package/validation/rules/ScalarLeafsRule.d.ts +28 -0
- package/validation/rules/ScalarLeafsRule.js +29 -0
- package/validation/rules/ScalarLeafsRule.mjs +28 -0
- package/validation/rules/SingleFieldSubscriptionsRule.d.ts +33 -0
- package/validation/rules/SingleFieldSubscriptionsRule.js +34 -0
- package/validation/rules/SingleFieldSubscriptionsRule.mjs +33 -0
- package/validation/rules/UniqueArgumentDefinitionNamesRule.d.ts +21 -0
- package/validation/rules/UniqueArgumentDefinitionNamesRule.js +22 -0
- package/validation/rules/UniqueArgumentDefinitionNamesRule.mjs +21 -0
- package/validation/rules/UniqueArgumentNamesRule.d.ts +28 -0
- package/validation/rules/UniqueArgumentNamesRule.js +29 -0
- package/validation/rules/UniqueArgumentNamesRule.mjs +28 -0
- package/validation/rules/UniqueDirectiveNamesRule.d.ts +21 -0
- package/validation/rules/UniqueDirectiveNamesRule.js +22 -0
- package/validation/rules/UniqueDirectiveNamesRule.mjs +21 -0
- package/validation/rules/UniqueDirectivesPerLocationRule.d.ts +28 -0
- package/validation/rules/UniqueDirectivesPerLocationRule.js +29 -0
- package/validation/rules/UniqueDirectivesPerLocationRule.mjs +28 -0
- package/validation/rules/UniqueEnumValueNamesRule.d.ts +21 -0
- package/validation/rules/UniqueEnumValueNamesRule.js +22 -0
- package/validation/rules/UniqueEnumValueNamesRule.mjs +21 -0
- package/validation/rules/UniqueFieldDefinitionNamesRule.d.ts +21 -0
- package/validation/rules/UniqueFieldDefinitionNamesRule.js +22 -0
- package/validation/rules/UniqueFieldDefinitionNamesRule.mjs +21 -0
- package/validation/rules/UniqueFragmentNamesRule.d.ts +28 -0
- package/validation/rules/UniqueFragmentNamesRule.js +29 -0
- package/validation/rules/UniqueFragmentNamesRule.mjs +28 -0
- package/validation/rules/UniqueInputFieldNamesRule.d.ts +32 -0
- package/validation/rules/UniqueInputFieldNamesRule.js +33 -0
- package/validation/rules/UniqueInputFieldNamesRule.mjs +32 -0
- package/validation/rules/UniqueOperationNamesRule.d.ts +28 -0
- package/validation/rules/UniqueOperationNamesRule.js +29 -0
- package/validation/rules/UniqueOperationNamesRule.mjs +28 -0
- package/validation/rules/UniqueOperationTypesRule.d.ts +21 -0
- package/validation/rules/UniqueOperationTypesRule.js +22 -0
- package/validation/rules/UniqueOperationTypesRule.mjs +21 -0
- package/validation/rules/UniqueTypeNamesRule.d.ts +21 -0
- package/validation/rules/UniqueTypeNamesRule.js +22 -0
- package/validation/rules/UniqueTypeNamesRule.mjs +21 -0
- package/validation/rules/UniqueVariableNamesRule.d.ts +28 -0
- package/validation/rules/UniqueVariableNamesRule.js +29 -0
- package/validation/rules/UniqueVariableNamesRule.mjs +28 -0
- package/validation/rules/ValuesOfCorrectTypeRule.d.ts +28 -0
- package/validation/rules/ValuesOfCorrectTypeRule.js +31 -0
- package/validation/rules/ValuesOfCorrectTypeRule.mjs +30 -0
- package/validation/rules/VariablesAreInputTypesRule.d.ts +32 -0
- package/validation/rules/VariablesAreInputTypesRule.js +33 -0
- package/validation/rules/VariablesAreInputTypesRule.mjs +32 -0
- package/validation/rules/VariablesInAllowedPositionRule.d.ts +28 -0
- package/validation/rules/VariablesInAllowedPositionRule.js +35 -1
- package/validation/rules/VariablesInAllowedPositionRule.mjs +34 -1
- package/validation/rules/custom/NoDeprecatedCustomRule.d.ts +41 -0
- package/validation/rules/custom/NoDeprecatedCustomRule.js +42 -0
- package/validation/rules/custom/NoDeprecatedCustomRule.mjs +41 -0
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.d.ts +28 -0
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.js +29 -0
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.mjs +28 -0
- package/validation/specifiedRules.d.ts +2 -3
- package/validation/specifiedRules.js +2 -3
- package/validation/specifiedRules.mjs +2 -3
- package/validation/validate.d.ts +70 -9
- package/validation/validate.js +63 -7
- package/validation/validate.mjs +63 -7
- package/version.d.ts +3 -6
- package/version.js +6 -8
- package/version.mjs +5 -8
package/language/kinds.d.ts
CHANGED
|
@@ -1,73 +1,112 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
*/
|
|
1
|
+
/** @category Kinds */
|
|
2
|
+
/** The set of allowed kind values for AST nodes. */
|
|
4
3
|
declare enum Kind {
|
|
5
|
-
/**
|
|
4
|
+
/** AST kind for name nodes. */
|
|
6
5
|
NAME = 'Name',
|
|
7
|
-
/**
|
|
6
|
+
/** AST kind for document nodes. */
|
|
8
7
|
DOCUMENT = 'Document',
|
|
8
|
+
/** AST kind for operation definition nodes. */
|
|
9
9
|
OPERATION_DEFINITION = 'OperationDefinition',
|
|
10
|
+
/** AST kind for variable definition nodes. */
|
|
10
11
|
VARIABLE_DEFINITION = 'VariableDefinition',
|
|
12
|
+
/** AST kind for selection set nodes. */
|
|
11
13
|
SELECTION_SET = 'SelectionSet',
|
|
14
|
+
/** AST kind for field selection nodes. */
|
|
12
15
|
FIELD = 'Field',
|
|
16
|
+
/** AST kind for argument nodes. */
|
|
13
17
|
ARGUMENT = 'Argument',
|
|
14
|
-
/**
|
|
18
|
+
/** AST kind for fragment spread nodes. */
|
|
15
19
|
FRAGMENT_SPREAD = 'FragmentSpread',
|
|
20
|
+
/** AST kind for inline fragment nodes. */
|
|
16
21
|
INLINE_FRAGMENT = 'InlineFragment',
|
|
22
|
+
/** AST kind for fragment definition nodes. */
|
|
17
23
|
FRAGMENT_DEFINITION = 'FragmentDefinition',
|
|
18
|
-
/**
|
|
24
|
+
/** AST kind for variable reference nodes. */
|
|
19
25
|
VARIABLE = 'Variable',
|
|
26
|
+
/** AST kind for integer value nodes. */
|
|
20
27
|
INT = 'IntValue',
|
|
28
|
+
/** AST kind for floating-point value nodes. */
|
|
21
29
|
FLOAT = 'FloatValue',
|
|
30
|
+
/** AST kind for string value nodes. */
|
|
22
31
|
STRING = 'StringValue',
|
|
32
|
+
/** AST kind for boolean value nodes. */
|
|
23
33
|
BOOLEAN = 'BooleanValue',
|
|
34
|
+
/** AST kind for null value nodes. */
|
|
24
35
|
NULL = 'NullValue',
|
|
36
|
+
/** AST kind for enum value nodes. */
|
|
25
37
|
ENUM = 'EnumValue',
|
|
38
|
+
/** AST kind for list value nodes. */
|
|
26
39
|
LIST = 'ListValue',
|
|
40
|
+
/** AST kind for object value nodes. */
|
|
27
41
|
OBJECT = 'ObjectValue',
|
|
42
|
+
/** AST kind for object field nodes. */
|
|
28
43
|
OBJECT_FIELD = 'ObjectField',
|
|
29
|
-
/**
|
|
44
|
+
/** AST kind for directive nodes. */
|
|
30
45
|
DIRECTIVE = 'Directive',
|
|
31
|
-
/**
|
|
46
|
+
/** AST kind for named type reference nodes. */
|
|
32
47
|
NAMED_TYPE = 'NamedType',
|
|
48
|
+
/** AST kind for list type reference nodes. */
|
|
33
49
|
LIST_TYPE = 'ListType',
|
|
50
|
+
/** AST kind for non-null type reference nodes. */
|
|
34
51
|
NON_NULL_TYPE = 'NonNullType',
|
|
35
|
-
/**
|
|
52
|
+
/** AST kind for schema definition nodes. */
|
|
36
53
|
SCHEMA_DEFINITION = 'SchemaDefinition',
|
|
54
|
+
/** AST kind for operation type definition nodes. */
|
|
37
55
|
OPERATION_TYPE_DEFINITION = 'OperationTypeDefinition',
|
|
38
|
-
/**
|
|
56
|
+
/** AST kind for scalar type definition nodes. */
|
|
39
57
|
SCALAR_TYPE_DEFINITION = 'ScalarTypeDefinition',
|
|
58
|
+
/** AST kind for object type definition nodes. */
|
|
40
59
|
OBJECT_TYPE_DEFINITION = 'ObjectTypeDefinition',
|
|
60
|
+
/** AST kind for field definition nodes. */
|
|
41
61
|
FIELD_DEFINITION = 'FieldDefinition',
|
|
62
|
+
/** AST kind for input value definition nodes. */
|
|
42
63
|
INPUT_VALUE_DEFINITION = 'InputValueDefinition',
|
|
64
|
+
/** AST kind for interface type definition nodes. */
|
|
43
65
|
INTERFACE_TYPE_DEFINITION = 'InterfaceTypeDefinition',
|
|
66
|
+
/** AST kind for union type definition nodes. */
|
|
44
67
|
UNION_TYPE_DEFINITION = 'UnionTypeDefinition',
|
|
68
|
+
/** AST kind for enum type definition nodes. */
|
|
45
69
|
ENUM_TYPE_DEFINITION = 'EnumTypeDefinition',
|
|
70
|
+
/** AST kind for enum value definition nodes. */
|
|
46
71
|
ENUM_VALUE_DEFINITION = 'EnumValueDefinition',
|
|
72
|
+
/** AST kind for input object type definition nodes. */
|
|
47
73
|
INPUT_OBJECT_TYPE_DEFINITION = 'InputObjectTypeDefinition',
|
|
48
|
-
/**
|
|
74
|
+
/** AST kind for directive definition nodes. */
|
|
49
75
|
DIRECTIVE_DEFINITION = 'DirectiveDefinition',
|
|
50
|
-
/**
|
|
76
|
+
/** AST kind for schema extension nodes. */
|
|
51
77
|
SCHEMA_EXTENSION = 'SchemaExtension',
|
|
78
|
+
/** AST kind for directive extension nodes. */
|
|
52
79
|
DIRECTIVE_EXTENSION = 'DirectiveExtension',
|
|
53
|
-
/**
|
|
80
|
+
/** AST kind for scalar type extension nodes. */
|
|
54
81
|
SCALAR_TYPE_EXTENSION = 'ScalarTypeExtension',
|
|
82
|
+
/** AST kind for object type extension nodes. */
|
|
55
83
|
OBJECT_TYPE_EXTENSION = 'ObjectTypeExtension',
|
|
84
|
+
/** AST kind for interface type extension nodes. */
|
|
56
85
|
INTERFACE_TYPE_EXTENSION = 'InterfaceTypeExtension',
|
|
86
|
+
/** AST kind for union type extension nodes. */
|
|
57
87
|
UNION_TYPE_EXTENSION = 'UnionTypeExtension',
|
|
88
|
+
/** AST kind for enum type extension nodes. */
|
|
58
89
|
ENUM_TYPE_EXTENSION = 'EnumTypeExtension',
|
|
90
|
+
/** AST kind for input object type extension nodes. */
|
|
59
91
|
INPUT_OBJECT_TYPE_EXTENSION = 'InputObjectTypeExtension',
|
|
60
|
-
/**
|
|
92
|
+
/** AST kind for type coordinate nodes. */
|
|
61
93
|
TYPE_COORDINATE = 'TypeCoordinate',
|
|
94
|
+
/** AST kind for member coordinate nodes. */
|
|
62
95
|
MEMBER_COORDINATE = 'MemberCoordinate',
|
|
96
|
+
/** AST kind for argument coordinate nodes. */
|
|
63
97
|
ARGUMENT_COORDINATE = 'ArgumentCoordinate',
|
|
98
|
+
/** AST kind for directive coordinate nodes. */
|
|
64
99
|
DIRECTIVE_COORDINATE = 'DirectiveCoordinate',
|
|
100
|
+
/** AST kind for directive argument coordinate nodes. */
|
|
65
101
|
DIRECTIVE_ARGUMENT_COORDINATE = 'DirectiveArgumentCoordinate',
|
|
66
102
|
}
|
|
67
103
|
export { Kind };
|
|
68
104
|
/**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
105
|
+
* Deprecated legacy alias for the enum type representing the possible kind
|
|
106
|
+
* values of AST nodes. This alias will be removed in v17. In v17, `Kind` is
|
|
107
|
+
* exported as the single public symbol for both the runtime object and the
|
|
108
|
+
* corresponding TypeScript type.
|
|
109
|
+
* @deprecated Will be removed in v17. In v17, use `Kind` as both the runtime
|
|
110
|
+
* value and the type.
|
|
72
111
|
*/
|
|
73
112
|
export declare type KindEnum = typeof Kind;
|
package/language/kinds.js
CHANGED
|
@@ -5,9 +5,9 @@ Object.defineProperty(exports, '__esModule', {
|
|
|
5
5
|
});
|
|
6
6
|
exports.Kind = void 0;
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
*/
|
|
8
|
+
/** @category Kinds */
|
|
9
|
+
|
|
10
|
+
/** The set of allowed kind values for AST nodes. */
|
|
11
11
|
var Kind;
|
|
12
12
|
exports.Kind = Kind;
|
|
13
13
|
|
|
@@ -63,7 +63,10 @@ exports.Kind = Kind;
|
|
|
63
63
|
Kind['DIRECTIVE_ARGUMENT_COORDINATE'] = 'DirectiveArgumentCoordinate';
|
|
64
64
|
})(Kind || (exports.Kind = Kind = {}));
|
|
65
65
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
66
|
+
* Deprecated legacy alias for the enum type representing the possible kind
|
|
67
|
+
* values of AST nodes. This alias will be removed in v17. In v17, `Kind` is
|
|
68
|
+
* exported as the single public symbol for both the runtime object and the
|
|
69
|
+
* corresponding TypeScript type.
|
|
70
|
+
* @deprecated Will be removed in v17. In v17, use `Kind` as both the runtime
|
|
71
|
+
* value and the type.
|
|
69
72
|
*/
|
package/language/kinds.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
*/
|
|
1
|
+
/** @category Kinds */
|
|
2
|
+
|
|
3
|
+
/** The set of allowed kind values for AST nodes. */
|
|
4
4
|
var Kind;
|
|
5
5
|
|
|
6
6
|
(function (Kind) {
|
|
@@ -57,7 +57,10 @@ var Kind;
|
|
|
57
57
|
|
|
58
58
|
export { Kind };
|
|
59
59
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
60
|
+
* Deprecated legacy alias for the enum type representing the possible kind
|
|
61
|
+
* values of AST nodes. This alias will be removed in v17. In v17, `Kind` is
|
|
62
|
+
* exported as the single public symbol for both the runtime object and the
|
|
63
|
+
* corresponding TypeScript type.
|
|
64
|
+
* @deprecated Will be removed in v17. In v17, use `Kind` as both the runtime
|
|
65
|
+
* value and the type.
|
|
63
66
|
*/
|
package/language/lexer.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** @category Lexing */
|
|
1
2
|
import { Token } from './ast';
|
|
2
3
|
import type { Source } from './source';
|
|
3
4
|
import { TokenKind } from './tokenKind';
|
|
@@ -25,38 +26,70 @@ export interface LexerInterface {
|
|
|
25
26
|
* whenever called.
|
|
26
27
|
*/
|
|
27
28
|
export declare class Lexer implements LexerInterface {
|
|
29
|
+
/** Source document used to derive error locations. */
|
|
28
30
|
source: Source;
|
|
29
|
-
/**
|
|
30
|
-
* The previously focused non-ignored token.
|
|
31
|
-
*/
|
|
31
|
+
/** Most recent non-ignored token returned by the lexer. */
|
|
32
32
|
lastToken: Token;
|
|
33
|
-
/**
|
|
34
|
-
* The currently focused non-ignored token.
|
|
35
|
-
*/
|
|
33
|
+
/** Current non-ignored token at the lexer cursor. */
|
|
36
34
|
token: Token;
|
|
37
|
-
/**
|
|
38
|
-
* The (1-indexed) line containing the current token.
|
|
39
|
-
*/
|
|
35
|
+
/** The (1-indexed) line containing the current token. */
|
|
40
36
|
line: number;
|
|
37
|
+
/** Character offset where the current line starts. */
|
|
38
|
+
lineStart: number;
|
|
41
39
|
/**
|
|
42
|
-
*
|
|
40
|
+
* Creates a Lexer instance.
|
|
41
|
+
* @param source - Source document used to derive error locations.
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* import { Lexer, Source, TokenKind } from 'graphql/language';
|
|
45
|
+
*
|
|
46
|
+
* const lexer = new Lexer(new Source('{ hello }'));
|
|
47
|
+
*
|
|
48
|
+
* lexer.token.kind; // => TokenKind.SOF
|
|
49
|
+
* lexer.advance().kind; // => TokenKind.BRACE_L
|
|
50
|
+
* lexer.advance().value; // => 'hello'
|
|
51
|
+
* lexer.advance().kind; // => TokenKind.BRACE_R
|
|
52
|
+
* ```
|
|
43
53
|
*/
|
|
44
|
-
lineStart: number;
|
|
45
54
|
constructor(source: Source);
|
|
55
|
+
/**
|
|
56
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
57
|
+
* @returns The built-in string tag for this object.
|
|
58
|
+
*/
|
|
46
59
|
get [Symbol.toStringTag](): string;
|
|
47
60
|
/**
|
|
48
61
|
* Advances the token stream to the next non-ignored token.
|
|
62
|
+
* @returns The next non-ignored token.
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* import { Lexer, Source } from 'graphql/language';
|
|
66
|
+
*
|
|
67
|
+
* const lexer = new Lexer(new Source('{ hello }'));
|
|
68
|
+
* const token = lexer.advance();
|
|
69
|
+
*
|
|
70
|
+
* token.kind; // => '{'
|
|
71
|
+
* lexer.token; // => token
|
|
72
|
+
* ```
|
|
49
73
|
*/
|
|
50
74
|
advance(): Token;
|
|
51
75
|
/**
|
|
52
76
|
* Looks ahead and returns the next non-ignored token, but does not change
|
|
53
77
|
* the state of Lexer.
|
|
78
|
+
* @returns The next non-ignored token without advancing the lexer.
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* import { Lexer, Source } from 'graphql/language';
|
|
82
|
+
*
|
|
83
|
+
* const lexer = new Lexer(new Source('{ hello }'));
|
|
84
|
+
* const token = lexer.lookahead();
|
|
85
|
+
*
|
|
86
|
+
* token.kind; // => '{'
|
|
87
|
+
* lexer.token.kind; // => '<SOF>'
|
|
88
|
+
* ```
|
|
54
89
|
*/
|
|
55
90
|
lookahead(): Token;
|
|
56
91
|
}
|
|
57
|
-
/**
|
|
58
|
-
* @internal
|
|
59
|
-
*/
|
|
92
|
+
/** @internal */
|
|
60
93
|
export declare function isPunctuatorTokenKind(kind: TokenKind): boolean;
|
|
61
94
|
/**
|
|
62
95
|
* Prints the code point (or end of file reference) at a given location in a
|
package/language/lexer.js
CHANGED
|
@@ -19,6 +19,8 @@ var _characterClasses = require('./characterClasses.js');
|
|
|
19
19
|
|
|
20
20
|
var _tokenKind = require('./tokenKind.js');
|
|
21
21
|
|
|
22
|
+
/** @category Lexing */
|
|
23
|
+
|
|
22
24
|
/**
|
|
23
25
|
* Given a Source object, creates a Lexer for that source.
|
|
24
26
|
* A Lexer is a stateful stream generator in that every time
|
|
@@ -28,20 +30,30 @@ var _tokenKind = require('./tokenKind.js');
|
|
|
28
30
|
* whenever called.
|
|
29
31
|
*/
|
|
30
32
|
class Lexer {
|
|
31
|
-
/**
|
|
32
|
-
* The previously focused non-ignored token.
|
|
33
|
-
*/
|
|
33
|
+
/** Source document used to derive error locations. */
|
|
34
34
|
|
|
35
|
-
/**
|
|
36
|
-
* The currently focused non-ignored token.
|
|
37
|
-
*/
|
|
35
|
+
/** Most recent non-ignored token returned by the lexer. */
|
|
38
36
|
|
|
39
|
-
/**
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
/** Current non-ignored token at the lexer cursor. */
|
|
38
|
+
|
|
39
|
+
/** The (1-indexed) line containing the current token. */
|
|
40
|
+
|
|
41
|
+
/** Character offset where the current line starts. */
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
|
-
*
|
|
44
|
+
* Creates a Lexer instance.
|
|
45
|
+
* @param source - Source document used to derive error locations.
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* import { Lexer, Source, TokenKind } from 'graphql/language';
|
|
49
|
+
*
|
|
50
|
+
* const lexer = new Lexer(new Source('{ hello }'));
|
|
51
|
+
*
|
|
52
|
+
* lexer.token.kind; // => TokenKind.SOF
|
|
53
|
+
* lexer.advance().kind; // => TokenKind.BRACE_L
|
|
54
|
+
* lexer.advance().value; // => 'hello'
|
|
55
|
+
* lexer.advance().kind; // => TokenKind.BRACE_R
|
|
56
|
+
* ```
|
|
45
57
|
*/
|
|
46
58
|
constructor(source) {
|
|
47
59
|
const startOfFileToken = new _ast.Token(
|
|
@@ -57,12 +69,27 @@ class Lexer {
|
|
|
57
69
|
this.line = 1;
|
|
58
70
|
this.lineStart = 0;
|
|
59
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
74
|
+
* @returns The built-in string tag for this object.
|
|
75
|
+
*/
|
|
60
76
|
|
|
61
77
|
get [Symbol.toStringTag]() {
|
|
62
78
|
return 'Lexer';
|
|
63
79
|
}
|
|
64
80
|
/**
|
|
65
81
|
* Advances the token stream to the next non-ignored token.
|
|
82
|
+
* @returns The next non-ignored token.
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* import { Lexer, Source } from 'graphql/language';
|
|
86
|
+
*
|
|
87
|
+
* const lexer = new Lexer(new Source('{ hello }'));
|
|
88
|
+
* const token = lexer.advance();
|
|
89
|
+
*
|
|
90
|
+
* token.kind; // => '{'
|
|
91
|
+
* lexer.token; // => token
|
|
92
|
+
* ```
|
|
66
93
|
*/
|
|
67
94
|
|
|
68
95
|
advance() {
|
|
@@ -73,6 +100,17 @@ class Lexer {
|
|
|
73
100
|
/**
|
|
74
101
|
* Looks ahead and returns the next non-ignored token, but does not change
|
|
75
102
|
* the state of Lexer.
|
|
103
|
+
* @returns The next non-ignored token without advancing the lexer.
|
|
104
|
+
* @example
|
|
105
|
+
* ```ts
|
|
106
|
+
* import { Lexer, Source } from 'graphql/language';
|
|
107
|
+
*
|
|
108
|
+
* const lexer = new Lexer(new Source('{ hello }'));
|
|
109
|
+
* const token = lexer.lookahead();
|
|
110
|
+
*
|
|
111
|
+
* token.kind; // => '{'
|
|
112
|
+
* lexer.token.kind; // => '<SOF>'
|
|
113
|
+
* ```
|
|
76
114
|
*/
|
|
77
115
|
|
|
78
116
|
lookahead() {
|
|
@@ -97,9 +135,7 @@ class Lexer {
|
|
|
97
135
|
return token;
|
|
98
136
|
}
|
|
99
137
|
}
|
|
100
|
-
/**
|
|
101
|
-
* @internal
|
|
102
|
-
*/
|
|
138
|
+
/** @internal */
|
|
103
139
|
|
|
104
140
|
exports.Lexer = Lexer;
|
|
105
141
|
|
|
@@ -129,6 +165,8 @@ function isPunctuatorTokenKind(kind) {
|
|
|
129
165
|
*
|
|
130
166
|
* SourceCharacter ::
|
|
131
167
|
* - "Any Unicode scalar value"
|
|
168
|
+
*
|
|
169
|
+
* @internal
|
|
132
170
|
*/
|
|
133
171
|
|
|
134
172
|
function isUnicodeScalarValue(code) {
|
|
@@ -143,6 +181,8 @@ function isUnicodeScalarValue(code) {
|
|
|
143
181
|
* include surrogates. A surrogate pair is a valid source character as it
|
|
144
182
|
* encodes a supplementary code point (above U+FFFF), but unpaired surrogate
|
|
145
183
|
* code points are not valid source characters.
|
|
184
|
+
*
|
|
185
|
+
* @internal
|
|
146
186
|
*/
|
|
147
187
|
|
|
148
188
|
function isSupplementaryCodePoint(body, location) {
|
|
@@ -199,6 +239,8 @@ function createToken(lexer, kind, start, end, value) {
|
|
|
199
239
|
* This skips over whitespace until it finds the next lexable token, then lexes
|
|
200
240
|
* punctuators immediately or calls the appropriate helper function for more
|
|
201
241
|
* complicated tokens.
|
|
242
|
+
*
|
|
243
|
+
* @internal
|
|
202
244
|
*/
|
|
203
245
|
|
|
204
246
|
function readNextToken(lexer, start) {
|
|
@@ -446,6 +488,8 @@ function readNextToken(lexer, start) {
|
|
|
446
488
|
*
|
|
447
489
|
* CommentChar :: SourceCharacter but not LineTerminator
|
|
448
490
|
* ```
|
|
491
|
+
*
|
|
492
|
+
* @internal
|
|
449
493
|
*/
|
|
450
494
|
|
|
451
495
|
function readComment(lexer, start) {
|
|
@@ -505,6 +549,8 @@ function readComment(lexer, start) {
|
|
|
505
549
|
*
|
|
506
550
|
* Sign :: one of + -
|
|
507
551
|
* ```
|
|
552
|
+
*
|
|
553
|
+
* @internal
|
|
508
554
|
*/
|
|
509
555
|
|
|
510
556
|
function readNumber(lexer, start, firstCode) {
|
|
@@ -575,6 +621,8 @@ function readNumber(lexer, start, firstCode) {
|
|
|
575
621
|
}
|
|
576
622
|
/**
|
|
577
623
|
* Returns the new position in the source after reading one or more digits.
|
|
624
|
+
*
|
|
625
|
+
* @internal
|
|
578
626
|
*/
|
|
579
627
|
|
|
580
628
|
function readDigits(lexer, start, firstCode) {
|
|
@@ -617,6 +665,8 @@ function readDigits(lexer, start, firstCode) {
|
|
|
617
665
|
*
|
|
618
666
|
* EscapedCharacter :: one of `"` `\` `/` `b` `f` `n` `r` `t`
|
|
619
667
|
* ```
|
|
668
|
+
*
|
|
669
|
+
* @internal
|
|
620
670
|
*/
|
|
621
671
|
|
|
622
672
|
function readString(lexer, start) {
|
|
@@ -765,6 +815,8 @@ function readEscapedUnicodeFixedWidth(lexer, position) {
|
|
|
765
815
|
* will return 57005.
|
|
766
816
|
*
|
|
767
817
|
* Returns a negative number if any char was not a valid hexadecimal digit.
|
|
818
|
+
*
|
|
819
|
+
* @internal
|
|
768
820
|
*/
|
|
769
821
|
|
|
770
822
|
function read16BitHexCode(body, position) {
|
|
@@ -790,6 +842,8 @@ function read16BitHexCode(body, position) {
|
|
|
790
842
|
* - `0` `1` `2` `3` `4` `5` `6` `7` `8` `9`
|
|
791
843
|
* - `A` `B` `C` `D` `E` `F`
|
|
792
844
|
* - `a` `b` `c` `d` `e` `f`
|
|
845
|
+
*
|
|
846
|
+
* @internal
|
|
793
847
|
*/
|
|
794
848
|
|
|
795
849
|
function readHexDigit(code) {
|
|
@@ -812,6 +866,8 @@ function readHexDigit(code) {
|
|
|
812
866
|
* | `n` | U+000A | line feed (new line) |
|
|
813
867
|
* | `r` | U+000D | carriage return |
|
|
814
868
|
* | `t` | U+0009 | horizontal tab |
|
|
869
|
+
*
|
|
870
|
+
* @internal
|
|
815
871
|
*/
|
|
816
872
|
|
|
817
873
|
function readEscapedCharacter(lexer, position) {
|
|
@@ -896,6 +952,8 @@ function readEscapedCharacter(lexer, position) {
|
|
|
896
952
|
* - SourceCharacter but not `"""` or `\"""`
|
|
897
953
|
* - `\"""`
|
|
898
954
|
* ```
|
|
955
|
+
*
|
|
956
|
+
* @internal
|
|
899
957
|
*/
|
|
900
958
|
|
|
901
959
|
function readBlockString(lexer, start) {
|
package/language/lexer.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** @category Lexing */
|
|
1
2
|
import { syntaxError } from '../error/syntaxError.mjs';
|
|
2
3
|
import { Token } from './ast.mjs';
|
|
3
4
|
import { dedentBlockStringLines } from './blockString.mjs';
|
|
@@ -19,20 +20,30 @@ import { TokenKind } from './tokenKind.mjs';
|
|
|
19
20
|
* whenever called.
|
|
20
21
|
*/
|
|
21
22
|
export class Lexer {
|
|
22
|
-
/**
|
|
23
|
-
* The previously focused non-ignored token.
|
|
24
|
-
*/
|
|
23
|
+
/** Source document used to derive error locations. */
|
|
25
24
|
|
|
26
|
-
/**
|
|
27
|
-
* The currently focused non-ignored token.
|
|
28
|
-
*/
|
|
25
|
+
/** Most recent non-ignored token returned by the lexer. */
|
|
29
26
|
|
|
30
|
-
/**
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
/** Current non-ignored token at the lexer cursor. */
|
|
28
|
+
|
|
29
|
+
/** The (1-indexed) line containing the current token. */
|
|
30
|
+
|
|
31
|
+
/** Character offset where the current line starts. */
|
|
33
32
|
|
|
34
33
|
/**
|
|
35
|
-
*
|
|
34
|
+
* Creates a Lexer instance.
|
|
35
|
+
* @param source - Source document used to derive error locations.
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* import { Lexer, Source, TokenKind } from 'graphql/language';
|
|
39
|
+
*
|
|
40
|
+
* const lexer = new Lexer(new Source('{ hello }'));
|
|
41
|
+
*
|
|
42
|
+
* lexer.token.kind; // => TokenKind.SOF
|
|
43
|
+
* lexer.advance().kind; // => TokenKind.BRACE_L
|
|
44
|
+
* lexer.advance().value; // => 'hello'
|
|
45
|
+
* lexer.advance().kind; // => TokenKind.BRACE_R
|
|
46
|
+
* ```
|
|
36
47
|
*/
|
|
37
48
|
constructor(source) {
|
|
38
49
|
const startOfFileToken = new Token(TokenKind.SOF, 0, 0, 0, 0);
|
|
@@ -42,12 +53,27 @@ export class Lexer {
|
|
|
42
53
|
this.line = 1;
|
|
43
54
|
this.lineStart = 0;
|
|
44
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
58
|
+
* @returns The built-in string tag for this object.
|
|
59
|
+
*/
|
|
45
60
|
|
|
46
61
|
get [Symbol.toStringTag]() {
|
|
47
62
|
return 'Lexer';
|
|
48
63
|
}
|
|
49
64
|
/**
|
|
50
65
|
* Advances the token stream to the next non-ignored token.
|
|
66
|
+
* @returns The next non-ignored token.
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* import { Lexer, Source } from 'graphql/language';
|
|
70
|
+
*
|
|
71
|
+
* const lexer = new Lexer(new Source('{ hello }'));
|
|
72
|
+
* const token = lexer.advance();
|
|
73
|
+
*
|
|
74
|
+
* token.kind; // => '{'
|
|
75
|
+
* lexer.token; // => token
|
|
76
|
+
* ```
|
|
51
77
|
*/
|
|
52
78
|
|
|
53
79
|
advance() {
|
|
@@ -58,6 +84,17 @@ export class Lexer {
|
|
|
58
84
|
/**
|
|
59
85
|
* Looks ahead and returns the next non-ignored token, but does not change
|
|
60
86
|
* the state of Lexer.
|
|
87
|
+
* @returns The next non-ignored token without advancing the lexer.
|
|
88
|
+
* @example
|
|
89
|
+
* ```ts
|
|
90
|
+
* import { Lexer, Source } from 'graphql/language';
|
|
91
|
+
*
|
|
92
|
+
* const lexer = new Lexer(new Source('{ hello }'));
|
|
93
|
+
* const token = lexer.lookahead();
|
|
94
|
+
*
|
|
95
|
+
* token.kind; // => '{'
|
|
96
|
+
* lexer.token.kind; // => '<SOF>'
|
|
97
|
+
* ```
|
|
61
98
|
*/
|
|
62
99
|
|
|
63
100
|
lookahead() {
|
|
@@ -82,9 +119,7 @@ export class Lexer {
|
|
|
82
119
|
return token;
|
|
83
120
|
}
|
|
84
121
|
}
|
|
85
|
-
/**
|
|
86
|
-
* @internal
|
|
87
|
-
*/
|
|
122
|
+
/** @internal */
|
|
88
123
|
|
|
89
124
|
export function isPunctuatorTokenKind(kind) {
|
|
90
125
|
return (
|
|
@@ -112,6 +147,8 @@ export function isPunctuatorTokenKind(kind) {
|
|
|
112
147
|
*
|
|
113
148
|
* SourceCharacter ::
|
|
114
149
|
* - "Any Unicode scalar value"
|
|
150
|
+
*
|
|
151
|
+
* @internal
|
|
115
152
|
*/
|
|
116
153
|
|
|
117
154
|
function isUnicodeScalarValue(code) {
|
|
@@ -126,6 +163,8 @@ function isUnicodeScalarValue(code) {
|
|
|
126
163
|
* include surrogates. A surrogate pair is a valid source character as it
|
|
127
164
|
* encodes a supplementary code point (above U+FFFF), but unpaired surrogate
|
|
128
165
|
* code points are not valid source characters.
|
|
166
|
+
*
|
|
167
|
+
* @internal
|
|
129
168
|
*/
|
|
130
169
|
|
|
131
170
|
function isSupplementaryCodePoint(body, location) {
|
|
@@ -182,6 +221,8 @@ export function createToken(lexer, kind, start, end, value) {
|
|
|
182
221
|
* This skips over whitespace until it finds the next lexable token, then lexes
|
|
183
222
|
* punctuators immediately or calls the appropriate helper function for more
|
|
184
223
|
* complicated tokens.
|
|
224
|
+
*
|
|
225
|
+
* @internal
|
|
185
226
|
*/
|
|
186
227
|
|
|
187
228
|
function readNextToken(lexer, start) {
|
|
@@ -359,6 +400,8 @@ function readNextToken(lexer, start) {
|
|
|
359
400
|
*
|
|
360
401
|
* CommentChar :: SourceCharacter but not LineTerminator
|
|
361
402
|
* ```
|
|
403
|
+
*
|
|
404
|
+
* @internal
|
|
362
405
|
*/
|
|
363
406
|
|
|
364
407
|
function readComment(lexer, start) {
|
|
@@ -418,6 +461,8 @@ function readComment(lexer, start) {
|
|
|
418
461
|
*
|
|
419
462
|
* Sign :: one of + -
|
|
420
463
|
* ```
|
|
464
|
+
*
|
|
465
|
+
* @internal
|
|
421
466
|
*/
|
|
422
467
|
|
|
423
468
|
function readNumber(lexer, start, firstCode) {
|
|
@@ -488,6 +533,8 @@ function readNumber(lexer, start, firstCode) {
|
|
|
488
533
|
}
|
|
489
534
|
/**
|
|
490
535
|
* Returns the new position in the source after reading one or more digits.
|
|
536
|
+
*
|
|
537
|
+
* @internal
|
|
491
538
|
*/
|
|
492
539
|
|
|
493
540
|
function readDigits(lexer, start, firstCode) {
|
|
@@ -530,6 +577,8 @@ function readDigits(lexer, start, firstCode) {
|
|
|
530
577
|
*
|
|
531
578
|
* EscapedCharacter :: one of `"` `\` `/` `b` `f` `n` `r` `t`
|
|
532
579
|
* ```
|
|
580
|
+
*
|
|
581
|
+
* @internal
|
|
533
582
|
*/
|
|
534
583
|
|
|
535
584
|
function readString(lexer, start) {
|
|
@@ -668,6 +717,8 @@ function readEscapedUnicodeFixedWidth(lexer, position) {
|
|
|
668
717
|
* will return 57005.
|
|
669
718
|
*
|
|
670
719
|
* Returns a negative number if any char was not a valid hexadecimal digit.
|
|
720
|
+
*
|
|
721
|
+
* @internal
|
|
671
722
|
*/
|
|
672
723
|
|
|
673
724
|
function read16BitHexCode(body, position) {
|
|
@@ -693,6 +744,8 @@ function read16BitHexCode(body, position) {
|
|
|
693
744
|
* - `0` `1` `2` `3` `4` `5` `6` `7` `8` `9`
|
|
694
745
|
* - `A` `B` `C` `D` `E` `F`
|
|
695
746
|
* - `a` `b` `c` `d` `e` `f`
|
|
747
|
+
*
|
|
748
|
+
* @internal
|
|
696
749
|
*/
|
|
697
750
|
|
|
698
751
|
function readHexDigit(code) {
|
|
@@ -715,6 +768,8 @@ function readHexDigit(code) {
|
|
|
715
768
|
* | `n` | U+000A | line feed (new line) |
|
|
716
769
|
* | `r` | U+000D | carriage return |
|
|
717
770
|
* | `t` | U+0009 | horizontal tab |
|
|
771
|
+
*
|
|
772
|
+
* @internal
|
|
718
773
|
*/
|
|
719
774
|
|
|
720
775
|
function readEscapedCharacter(lexer, position) {
|
|
@@ -799,6 +854,8 @@ function readEscapedCharacter(lexer, position) {
|
|
|
799
854
|
* - SourceCharacter but not `"""` or `\"""`
|
|
800
855
|
* - `\"""`
|
|
801
856
|
* ```
|
|
857
|
+
*
|
|
858
|
+
* @internal
|
|
802
859
|
*/
|
|
803
860
|
|
|
804
861
|
function readBlockString(lexer, start) {
|