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/parser.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** @category Parsing */
|
|
1
2
|
import { syntaxError } from '../error/syntaxError.mjs';
|
|
2
3
|
import { Location, OperationTypeNode } from './ast.mjs';
|
|
3
4
|
import { DirectiveLocation } from './directiveLocation.mjs';
|
|
@@ -6,13 +7,44 @@ import { isPunctuatorTokenKind, Lexer } from './lexer.mjs';
|
|
|
6
7
|
import { SchemaCoordinateLexer } from './schemaCoordinateLexer.mjs';
|
|
7
8
|
import { isSource, Source } from './source.mjs';
|
|
8
9
|
import { TokenKind } from './tokenKind.mjs';
|
|
9
|
-
/**
|
|
10
|
-
* Configuration options to control parser behavior
|
|
11
|
-
*/
|
|
10
|
+
/** Configuration options to control parser behavior */
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* Given a GraphQL source, parses it into a Document.
|
|
15
14
|
* Throws GraphQLError if a syntax error is encountered.
|
|
15
|
+
* @param source - A GraphQL source string or source object.
|
|
16
|
+
* @param options - Optional parser configuration.
|
|
17
|
+
* @returns The parsed GraphQL document AST.
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* // Parse a GraphQL document with the default parser options.
|
|
21
|
+
* import { parse } from 'graphql/language';
|
|
22
|
+
*
|
|
23
|
+
* const document = parse('{ hero { name } }');
|
|
24
|
+
*
|
|
25
|
+
* document.kind; // => 'Document'
|
|
26
|
+
* ```
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* // This variant enables parser options and provides an explicit lexer.
|
|
30
|
+
* import { Lexer, Source, parse } from 'graphql/language';
|
|
31
|
+
*
|
|
32
|
+
* const document = parse('fragment A($var: Boolean) on Query { field }', {
|
|
33
|
+
* allowLegacyFragmentVariables: true,
|
|
34
|
+
* maxTokens: 20,
|
|
35
|
+
* noLocation: true,
|
|
36
|
+
* });
|
|
37
|
+
* const directiveDocument = parse('directive @foo @bar on FIELD', {
|
|
38
|
+
* experimentalDirectivesOnDirectiveDefinitions: true,
|
|
39
|
+
* });
|
|
40
|
+
* const source = new Source('{ hero }');
|
|
41
|
+
* const lexerDocument = parse(source, { lexer: new Lexer(source) });
|
|
42
|
+
*
|
|
43
|
+
* document.definitions[0].kind; // => 'FragmentDefinition'
|
|
44
|
+
* document.loc; // => undefined
|
|
45
|
+
* directiveDocument.definitions[0].kind; // => 'DirectiveDefinition'
|
|
46
|
+
* lexerDocument.definitions[0].kind; // => 'OperationDefinition'
|
|
47
|
+
* ```
|
|
16
48
|
*/
|
|
17
49
|
export function parse(source, options) {
|
|
18
50
|
const parser = new Parser(source, options);
|
|
@@ -32,6 +64,17 @@ export function parse(source, options) {
|
|
|
32
64
|
* in isolation of complete GraphQL documents.
|
|
33
65
|
*
|
|
34
66
|
* Consider providing the results to the utility function: valueFromAST().
|
|
67
|
+
* @param source - A GraphQL source string or source object containing a value.
|
|
68
|
+
* @param options - Optional parser configuration.
|
|
69
|
+
* @returns The parsed GraphQL value AST.
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* import { parseValue } from 'graphql/language';
|
|
73
|
+
*
|
|
74
|
+
* const value = parseValue('[42]');
|
|
75
|
+
*
|
|
76
|
+
* value.kind; // => 'ListValue'
|
|
77
|
+
* ```
|
|
35
78
|
*/
|
|
36
79
|
|
|
37
80
|
export function parseValue(source, options) {
|
|
@@ -44,6 +87,18 @@ export function parseValue(source, options) {
|
|
|
44
87
|
/**
|
|
45
88
|
* Similar to parseValue(), but raises a parse error if it encounters a
|
|
46
89
|
* variable. The return type will be a constant value.
|
|
90
|
+
* @param source - A GraphQL source string or source object containing a constant value.
|
|
91
|
+
* @param options - Optional parser configuration.
|
|
92
|
+
* @returns The parsed GraphQL constant value AST.
|
|
93
|
+
* @example
|
|
94
|
+
* ```ts
|
|
95
|
+
* import { parseConstValue } from 'graphql/language';
|
|
96
|
+
*
|
|
97
|
+
* const value = parseConstValue('{ enabled: true }');
|
|
98
|
+
*
|
|
99
|
+
* value.kind; // => 'ObjectValue'
|
|
100
|
+
* parseConstValue('$variable'); // throws an error
|
|
101
|
+
* ```
|
|
47
102
|
*/
|
|
48
103
|
|
|
49
104
|
export function parseConstValue(source, options) {
|
|
@@ -62,6 +117,17 @@ export function parseConstValue(source, options) {
|
|
|
62
117
|
* in isolation of complete GraphQL documents.
|
|
63
118
|
*
|
|
64
119
|
* Consider providing the results to the utility function: typeFromAST().
|
|
120
|
+
* @param source - A GraphQL source string or source object containing a type reference.
|
|
121
|
+
* @param options - Optional parser configuration.
|
|
122
|
+
* @returns The parsed GraphQL type AST.
|
|
123
|
+
* @example
|
|
124
|
+
* ```ts
|
|
125
|
+
* import { parseType } from 'graphql/language';
|
|
126
|
+
*
|
|
127
|
+
* const type = parseType('[String!]');
|
|
128
|
+
*
|
|
129
|
+
* type.kind; // => 'ListType'
|
|
130
|
+
* ```
|
|
65
131
|
*/
|
|
66
132
|
|
|
67
133
|
export function parseType(source, options) {
|
|
@@ -79,6 +145,16 @@ export function parseType(source, options) {
|
|
|
79
145
|
* Consider providing the results to the utility function:
|
|
80
146
|
* resolveASTSchemaCoordinate(). Or calling resolveSchemaCoordinate() directly
|
|
81
147
|
* with an unparsed source.
|
|
148
|
+
* @param source - A GraphQL source string or source object containing a schema coordinate.
|
|
149
|
+
* @returns The parsed GraphQL schema coordinate AST.
|
|
150
|
+
* @example
|
|
151
|
+
* ```ts
|
|
152
|
+
* import { parseSchemaCoordinate } from 'graphql/language';
|
|
153
|
+
*
|
|
154
|
+
* const coordinate = parseSchemaCoordinate('Query.hero');
|
|
155
|
+
*
|
|
156
|
+
* coordinate.kind; // => 'MemberCoordinate'
|
|
157
|
+
* ```
|
|
82
158
|
*/
|
|
83
159
|
|
|
84
160
|
export function parseSchemaCoordinate(source) {
|
|
@@ -124,6 +200,8 @@ export class Parser {
|
|
|
124
200
|
}
|
|
125
201
|
/**
|
|
126
202
|
* Converts a name lex token into a name parse node.
|
|
203
|
+
*
|
|
204
|
+
* @internal
|
|
127
205
|
*/
|
|
128
206
|
|
|
129
207
|
parseName() {
|
|
@@ -136,6 +214,8 @@ export class Parser {
|
|
|
136
214
|
|
|
137
215
|
/**
|
|
138
216
|
* Document : Definition+
|
|
217
|
+
*
|
|
218
|
+
* @internal
|
|
139
219
|
*/
|
|
140
220
|
|
|
141
221
|
parseDocument() {
|
|
@@ -170,6 +250,8 @@ export class Parser {
|
|
|
170
250
|
* - UnionTypeDefinition
|
|
171
251
|
* - EnumTypeDefinition
|
|
172
252
|
* - InputObjectTypeDefinition
|
|
253
|
+
*
|
|
254
|
+
* @internal
|
|
173
255
|
*/
|
|
174
256
|
|
|
175
257
|
parseDefinition() {
|
|
@@ -248,6 +330,8 @@ export class Parser {
|
|
|
248
330
|
* OperationDefinition :
|
|
249
331
|
* - SelectionSet
|
|
250
332
|
* - OperationType Name? VariableDefinitions? Directives? SelectionSet
|
|
333
|
+
*
|
|
334
|
+
* @internal
|
|
251
335
|
*/
|
|
252
336
|
|
|
253
337
|
parseOperationDefinition() {
|
|
@@ -285,6 +369,8 @@ export class Parser {
|
|
|
285
369
|
}
|
|
286
370
|
/**
|
|
287
371
|
* OperationType : one of query mutation subscription
|
|
372
|
+
*
|
|
373
|
+
* @internal
|
|
288
374
|
*/
|
|
289
375
|
|
|
290
376
|
parseOperationType() {
|
|
@@ -305,6 +391,8 @@ export class Parser {
|
|
|
305
391
|
}
|
|
306
392
|
/**
|
|
307
393
|
* VariableDefinitions : ( VariableDefinition+ )
|
|
394
|
+
*
|
|
395
|
+
* @internal
|
|
308
396
|
*/
|
|
309
397
|
|
|
310
398
|
parseVariableDefinitions() {
|
|
@@ -316,6 +404,8 @@ export class Parser {
|
|
|
316
404
|
}
|
|
317
405
|
/**
|
|
318
406
|
* VariableDefinition : Variable : Type DefaultValue? Directives[Const]?
|
|
407
|
+
*
|
|
408
|
+
* @internal
|
|
319
409
|
*/
|
|
320
410
|
|
|
321
411
|
parseVariableDefinition() {
|
|
@@ -332,6 +422,8 @@ export class Parser {
|
|
|
332
422
|
}
|
|
333
423
|
/**
|
|
334
424
|
* Variable : $ Name
|
|
425
|
+
*
|
|
426
|
+
* @internal
|
|
335
427
|
*/
|
|
336
428
|
|
|
337
429
|
parseVariable() {
|
|
@@ -346,6 +438,8 @@ export class Parser {
|
|
|
346
438
|
* ```
|
|
347
439
|
* SelectionSet : { Selection+ }
|
|
348
440
|
* ```
|
|
441
|
+
*
|
|
442
|
+
* @internal
|
|
349
443
|
*/
|
|
350
444
|
|
|
351
445
|
parseSelectionSet() {
|
|
@@ -363,6 +457,8 @@ export class Parser {
|
|
|
363
457
|
* - Field
|
|
364
458
|
* - FragmentSpread
|
|
365
459
|
* - InlineFragment
|
|
460
|
+
*
|
|
461
|
+
* @internal
|
|
366
462
|
*/
|
|
367
463
|
|
|
368
464
|
parseSelection() {
|
|
@@ -374,6 +470,8 @@ export class Parser {
|
|
|
374
470
|
* Field : Alias? Name Arguments? Directives? SelectionSet?
|
|
375
471
|
*
|
|
376
472
|
* Alias : Name :
|
|
473
|
+
*
|
|
474
|
+
* @internal
|
|
377
475
|
*/
|
|
378
476
|
|
|
379
477
|
parseField() {
|
|
@@ -402,6 +500,8 @@ export class Parser {
|
|
|
402
500
|
}
|
|
403
501
|
/**
|
|
404
502
|
* Arguments[Const] : ( Argument[?Const]+ )
|
|
503
|
+
*
|
|
504
|
+
* @internal
|
|
405
505
|
*/
|
|
406
506
|
|
|
407
507
|
parseArguments(isConst) {
|
|
@@ -410,6 +510,8 @@ export class Parser {
|
|
|
410
510
|
}
|
|
411
511
|
/**
|
|
412
512
|
* Argument[Const] : Name : Value[?Const]
|
|
513
|
+
*
|
|
514
|
+
* @internal
|
|
413
515
|
*/
|
|
414
516
|
|
|
415
517
|
parseArgument(isConst = false) {
|
|
@@ -433,6 +535,8 @@ export class Parser {
|
|
|
433
535
|
* FragmentSpread : ... FragmentName Directives?
|
|
434
536
|
*
|
|
435
537
|
* InlineFragment : ... TypeCondition? Directives? SelectionSet
|
|
538
|
+
*
|
|
539
|
+
* @internal
|
|
436
540
|
*/
|
|
437
541
|
|
|
438
542
|
parseFragment() {
|
|
@@ -460,6 +564,8 @@ export class Parser {
|
|
|
460
564
|
* - fragment FragmentName on TypeCondition Directives? SelectionSet
|
|
461
565
|
*
|
|
462
566
|
* TypeCondition : NamedType
|
|
567
|
+
*
|
|
568
|
+
* @internal
|
|
463
569
|
*/
|
|
464
570
|
|
|
465
571
|
parseFragmentDefinition() {
|
|
@@ -492,6 +598,8 @@ export class Parser {
|
|
|
492
598
|
}
|
|
493
599
|
/**
|
|
494
600
|
* FragmentName : Name but not `on`
|
|
601
|
+
*
|
|
602
|
+
* @internal
|
|
495
603
|
*/
|
|
496
604
|
|
|
497
605
|
parseFragmentName() {
|
|
@@ -519,6 +627,8 @@ export class Parser {
|
|
|
519
627
|
* NullValue : `null`
|
|
520
628
|
*
|
|
521
629
|
* EnumValue : Name but not `true`, `false` or `null`
|
|
630
|
+
*
|
|
631
|
+
* @internal
|
|
522
632
|
*/
|
|
523
633
|
|
|
524
634
|
parseValueLiteral(isConst) {
|
|
@@ -617,6 +727,8 @@ export class Parser {
|
|
|
617
727
|
* ListValue[Const] :
|
|
618
728
|
* - [ ]
|
|
619
729
|
* - [ Value[?Const]+ ]
|
|
730
|
+
*
|
|
731
|
+
* @internal
|
|
620
732
|
*/
|
|
621
733
|
|
|
622
734
|
parseList(isConst) {
|
|
@@ -633,6 +745,8 @@ export class Parser {
|
|
|
633
745
|
* - { }
|
|
634
746
|
* - { ObjectField[?Const]+ }
|
|
635
747
|
* ```
|
|
748
|
+
*
|
|
749
|
+
* @internal
|
|
636
750
|
*/
|
|
637
751
|
|
|
638
752
|
parseObject(isConst) {
|
|
@@ -645,6 +759,8 @@ export class Parser {
|
|
|
645
759
|
}
|
|
646
760
|
/**
|
|
647
761
|
* ObjectField[Const] : Name : Value[?Const]
|
|
762
|
+
*
|
|
763
|
+
* @internal
|
|
648
764
|
*/
|
|
649
765
|
|
|
650
766
|
parseObjectField(isConst) {
|
|
@@ -660,6 +776,8 @@ export class Parser {
|
|
|
660
776
|
|
|
661
777
|
/**
|
|
662
778
|
* Directives[Const] : Directive[?Const]+
|
|
779
|
+
*
|
|
780
|
+
* @internal
|
|
663
781
|
*/
|
|
664
782
|
|
|
665
783
|
parseDirectives(isConst) {
|
|
@@ -679,6 +797,8 @@ export class Parser {
|
|
|
679
797
|
* ```
|
|
680
798
|
* Directive[Const] : @ Name Arguments[?Const]?
|
|
681
799
|
* ```
|
|
800
|
+
*
|
|
801
|
+
* @internal
|
|
682
802
|
*/
|
|
683
803
|
|
|
684
804
|
parseDirective(isConst) {
|
|
@@ -696,6 +816,8 @@ export class Parser {
|
|
|
696
816
|
* - NamedType
|
|
697
817
|
* - ListType
|
|
698
818
|
* - NonNullType
|
|
819
|
+
*
|
|
820
|
+
* @internal
|
|
699
821
|
*/
|
|
700
822
|
|
|
701
823
|
parseTypeReference() {
|
|
@@ -724,6 +846,8 @@ export class Parser {
|
|
|
724
846
|
}
|
|
725
847
|
/**
|
|
726
848
|
* NamedType : Name
|
|
849
|
+
*
|
|
850
|
+
* @internal
|
|
727
851
|
*/
|
|
728
852
|
|
|
729
853
|
parseNamedType() {
|
|
@@ -738,6 +862,8 @@ export class Parser {
|
|
|
738
862
|
}
|
|
739
863
|
/**
|
|
740
864
|
* Description : StringValue
|
|
865
|
+
*
|
|
866
|
+
* @internal
|
|
741
867
|
*/
|
|
742
868
|
|
|
743
869
|
parseDescription() {
|
|
@@ -749,6 +875,8 @@ export class Parser {
|
|
|
749
875
|
* ```
|
|
750
876
|
* SchemaDefinition : Description? schema Directives[Const]? { OperationTypeDefinition+ }
|
|
751
877
|
* ```
|
|
878
|
+
*
|
|
879
|
+
* @internal
|
|
752
880
|
*/
|
|
753
881
|
|
|
754
882
|
parseSchemaDefinition() {
|
|
@@ -770,6 +898,8 @@ export class Parser {
|
|
|
770
898
|
}
|
|
771
899
|
/**
|
|
772
900
|
* OperationTypeDefinition : OperationType : NamedType
|
|
901
|
+
*
|
|
902
|
+
* @internal
|
|
773
903
|
*/
|
|
774
904
|
|
|
775
905
|
parseOperationTypeDefinition() {
|
|
@@ -785,6 +915,8 @@ export class Parser {
|
|
|
785
915
|
}
|
|
786
916
|
/**
|
|
787
917
|
* ScalarTypeDefinition : Description? scalar Name Directives[Const]?
|
|
918
|
+
*
|
|
919
|
+
* @internal
|
|
788
920
|
*/
|
|
789
921
|
|
|
790
922
|
parseScalarTypeDefinition() {
|
|
@@ -804,6 +936,8 @@ export class Parser {
|
|
|
804
936
|
* ObjectTypeDefinition :
|
|
805
937
|
* Description?
|
|
806
938
|
* type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition?
|
|
939
|
+
*
|
|
940
|
+
* @internal
|
|
807
941
|
*/
|
|
808
942
|
|
|
809
943
|
parseObjectTypeDefinition() {
|
|
@@ -827,6 +961,8 @@ export class Parser {
|
|
|
827
961
|
* ImplementsInterfaces :
|
|
828
962
|
* - implements `&`? NamedType
|
|
829
963
|
* - ImplementsInterfaces & NamedType
|
|
964
|
+
*
|
|
965
|
+
* @internal
|
|
830
966
|
*/
|
|
831
967
|
|
|
832
968
|
parseImplementsInterfaces() {
|
|
@@ -838,6 +974,8 @@ export class Parser {
|
|
|
838
974
|
* ```
|
|
839
975
|
* FieldsDefinition : { FieldDefinition+ }
|
|
840
976
|
* ```
|
|
977
|
+
*
|
|
978
|
+
* @internal
|
|
841
979
|
*/
|
|
842
980
|
|
|
843
981
|
parseFieldsDefinition() {
|
|
@@ -850,6 +988,8 @@ export class Parser {
|
|
|
850
988
|
/**
|
|
851
989
|
* FieldDefinition :
|
|
852
990
|
* - Description? Name ArgumentsDefinition? : Type Directives[Const]?
|
|
991
|
+
*
|
|
992
|
+
* @internal
|
|
853
993
|
*/
|
|
854
994
|
|
|
855
995
|
parseFieldDefinition() {
|
|
@@ -871,6 +1011,8 @@ export class Parser {
|
|
|
871
1011
|
}
|
|
872
1012
|
/**
|
|
873
1013
|
* ArgumentsDefinition : ( InputValueDefinition+ )
|
|
1014
|
+
*
|
|
1015
|
+
* @internal
|
|
874
1016
|
*/
|
|
875
1017
|
|
|
876
1018
|
parseArgumentDefs() {
|
|
@@ -883,6 +1025,8 @@ export class Parser {
|
|
|
883
1025
|
/**
|
|
884
1026
|
* InputValueDefinition :
|
|
885
1027
|
* - Description? Name : Type DefaultValue? Directives[Const]?
|
|
1028
|
+
*
|
|
1029
|
+
* @internal
|
|
886
1030
|
*/
|
|
887
1031
|
|
|
888
1032
|
parseInputValueDef() {
|
|
@@ -910,6 +1054,8 @@ export class Parser {
|
|
|
910
1054
|
/**
|
|
911
1055
|
* InterfaceTypeDefinition :
|
|
912
1056
|
* - Description? interface Name Directives[Const]? FieldsDefinition?
|
|
1057
|
+
*
|
|
1058
|
+
* @internal
|
|
913
1059
|
*/
|
|
914
1060
|
|
|
915
1061
|
parseInterfaceTypeDefinition() {
|
|
@@ -932,6 +1078,8 @@ export class Parser {
|
|
|
932
1078
|
/**
|
|
933
1079
|
* UnionTypeDefinition :
|
|
934
1080
|
* - Description? union Name Directives[Const]? UnionMemberTypes?
|
|
1081
|
+
*
|
|
1082
|
+
* @internal
|
|
935
1083
|
*/
|
|
936
1084
|
|
|
937
1085
|
parseUnionTypeDefinition() {
|
|
@@ -953,6 +1101,8 @@ export class Parser {
|
|
|
953
1101
|
* UnionMemberTypes :
|
|
954
1102
|
* - = `|`? NamedType
|
|
955
1103
|
* - UnionMemberTypes | NamedType
|
|
1104
|
+
*
|
|
1105
|
+
* @internal
|
|
956
1106
|
*/
|
|
957
1107
|
|
|
958
1108
|
parseUnionMemberTypes() {
|
|
@@ -963,6 +1113,8 @@ export class Parser {
|
|
|
963
1113
|
/**
|
|
964
1114
|
* EnumTypeDefinition :
|
|
965
1115
|
* - Description? enum Name Directives[Const]? EnumValuesDefinition?
|
|
1116
|
+
*
|
|
1117
|
+
* @internal
|
|
966
1118
|
*/
|
|
967
1119
|
|
|
968
1120
|
parseEnumTypeDefinition() {
|
|
@@ -984,6 +1136,8 @@ export class Parser {
|
|
|
984
1136
|
* ```
|
|
985
1137
|
* EnumValuesDefinition : { EnumValueDefinition+ }
|
|
986
1138
|
* ```
|
|
1139
|
+
*
|
|
1140
|
+
* @internal
|
|
987
1141
|
*/
|
|
988
1142
|
|
|
989
1143
|
parseEnumValuesDefinition() {
|
|
@@ -995,6 +1149,8 @@ export class Parser {
|
|
|
995
1149
|
}
|
|
996
1150
|
/**
|
|
997
1151
|
* EnumValueDefinition : Description? EnumValue Directives[Const]?
|
|
1152
|
+
*
|
|
1153
|
+
* @internal
|
|
998
1154
|
*/
|
|
999
1155
|
|
|
1000
1156
|
parseEnumValueDefinition() {
|
|
@@ -1011,6 +1167,8 @@ export class Parser {
|
|
|
1011
1167
|
}
|
|
1012
1168
|
/**
|
|
1013
1169
|
* EnumValue : Name but not `true`, `false` or `null`
|
|
1170
|
+
*
|
|
1171
|
+
* @internal
|
|
1014
1172
|
*/
|
|
1015
1173
|
|
|
1016
1174
|
parseEnumValueName() {
|
|
@@ -1033,6 +1191,8 @@ export class Parser {
|
|
|
1033
1191
|
/**
|
|
1034
1192
|
* InputObjectTypeDefinition :
|
|
1035
1193
|
* - Description? input Name Directives[Const]? InputFieldsDefinition?
|
|
1194
|
+
*
|
|
1195
|
+
* @internal
|
|
1036
1196
|
*/
|
|
1037
1197
|
|
|
1038
1198
|
parseInputObjectTypeDefinition() {
|
|
@@ -1054,6 +1214,8 @@ export class Parser {
|
|
|
1054
1214
|
* ```
|
|
1055
1215
|
* InputFieldsDefinition : { InputValueDefinition+ }
|
|
1056
1216
|
* ```
|
|
1217
|
+
*
|
|
1218
|
+
* @internal
|
|
1057
1219
|
*/
|
|
1058
1220
|
|
|
1059
1221
|
parseInputFieldsDefinition() {
|
|
@@ -1076,6 +1238,8 @@ export class Parser {
|
|
|
1076
1238
|
* - EnumTypeExtension
|
|
1077
1239
|
* - InputObjectTypeDefinition
|
|
1078
1240
|
* - DirectiveDefinitionExtension
|
|
1241
|
+
*
|
|
1242
|
+
* @internal
|
|
1079
1243
|
*/
|
|
1080
1244
|
|
|
1081
1245
|
parseTypeSystemExtension() {
|
|
@@ -1121,6 +1285,8 @@ export class Parser {
|
|
|
1121
1285
|
* - extend schema Directives[Const]? { OperationTypeDefinition+ }
|
|
1122
1286
|
* - extend schema Directives[Const]
|
|
1123
1287
|
* ```
|
|
1288
|
+
*
|
|
1289
|
+
* @internal
|
|
1124
1290
|
*/
|
|
1125
1291
|
|
|
1126
1292
|
parseSchemaExtension() {
|
|
@@ -1147,6 +1313,8 @@ export class Parser {
|
|
|
1147
1313
|
/**
|
|
1148
1314
|
* ScalarTypeExtension :
|
|
1149
1315
|
* - extend scalar Name Directives[Const]
|
|
1316
|
+
*
|
|
1317
|
+
* @internal
|
|
1150
1318
|
*/
|
|
1151
1319
|
|
|
1152
1320
|
parseScalarTypeExtension() {
|
|
@@ -1171,6 +1339,8 @@ export class Parser {
|
|
|
1171
1339
|
* - extend type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
|
|
1172
1340
|
* - extend type Name ImplementsInterfaces? Directives[Const]
|
|
1173
1341
|
* - extend type Name ImplementsInterfaces
|
|
1342
|
+
*
|
|
1343
|
+
* @internal
|
|
1174
1344
|
*/
|
|
1175
1345
|
|
|
1176
1346
|
parseObjectTypeExtension() {
|
|
@@ -1203,6 +1373,8 @@ export class Parser {
|
|
|
1203
1373
|
* - extend interface Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
|
|
1204
1374
|
* - extend interface Name ImplementsInterfaces? Directives[Const]
|
|
1205
1375
|
* - extend interface Name ImplementsInterfaces
|
|
1376
|
+
*
|
|
1377
|
+
* @internal
|
|
1206
1378
|
*/
|
|
1207
1379
|
|
|
1208
1380
|
parseInterfaceTypeExtension() {
|
|
@@ -1234,6 +1406,8 @@ export class Parser {
|
|
|
1234
1406
|
* UnionTypeExtension :
|
|
1235
1407
|
* - extend union Name Directives[Const]? UnionMemberTypes
|
|
1236
1408
|
* - extend union Name Directives[Const]
|
|
1409
|
+
*
|
|
1410
|
+
* @internal
|
|
1237
1411
|
*/
|
|
1238
1412
|
|
|
1239
1413
|
parseUnionTypeExtension() {
|
|
@@ -1259,6 +1433,8 @@ export class Parser {
|
|
|
1259
1433
|
* EnumTypeExtension :
|
|
1260
1434
|
* - extend enum Name Directives[Const]? EnumValuesDefinition
|
|
1261
1435
|
* - extend enum Name Directives[Const]
|
|
1436
|
+
*
|
|
1437
|
+
* @internal
|
|
1262
1438
|
*/
|
|
1263
1439
|
|
|
1264
1440
|
parseEnumTypeExtension() {
|
|
@@ -1284,6 +1460,8 @@ export class Parser {
|
|
|
1284
1460
|
* InputObjectTypeExtension :
|
|
1285
1461
|
* - extend input Name Directives[Const]? InputFieldsDefinition
|
|
1286
1462
|
* - extend input Name Directives[Const]
|
|
1463
|
+
*
|
|
1464
|
+
* @internal
|
|
1287
1465
|
*/
|
|
1288
1466
|
|
|
1289
1467
|
parseInputObjectTypeExtension() {
|
|
@@ -1329,6 +1507,8 @@ export class Parser {
|
|
|
1329
1507
|
* DirectiveDefinition :
|
|
1330
1508
|
* - Description? directive @ Name ArgumentsDefinition? `repeatable`? on DirectiveLocations
|
|
1331
1509
|
* ```
|
|
1510
|
+
*
|
|
1511
|
+
* @internal
|
|
1332
1512
|
*/
|
|
1333
1513
|
|
|
1334
1514
|
parseDirectiveDefinition() {
|
|
@@ -1359,6 +1539,8 @@ export class Parser {
|
|
|
1359
1539
|
* DirectiveLocations :
|
|
1360
1540
|
* - `|`? DirectiveLocation
|
|
1361
1541
|
* - DirectiveLocations | DirectiveLocation
|
|
1542
|
+
*
|
|
1543
|
+
* @internal
|
|
1362
1544
|
*/
|
|
1363
1545
|
|
|
1364
1546
|
parseDirectiveLocations() {
|
|
@@ -1411,6 +1593,19 @@ export class Parser {
|
|
|
1411
1593
|
* - Name . Name ( Name : )
|
|
1412
1594
|
* - \@ Name
|
|
1413
1595
|
* - \@ Name ( Name : )
|
|
1596
|
+
* @returns Parsed schema coordinate AST.
|
|
1597
|
+
* @example
|
|
1598
|
+
* ```ts
|
|
1599
|
+
* import { Parser, Source } from 'graphql/language';
|
|
1600
|
+
*
|
|
1601
|
+
* const typeCoordinate = new Parser(new Source('User.name')).parseSchemaCoordinate();
|
|
1602
|
+
* const directiveCoordinate = new Parser(new Source('@include(if:)')).parseSchemaCoordinate();
|
|
1603
|
+
*
|
|
1604
|
+
* typeCoordinate.name.value; // => 'User'
|
|
1605
|
+
* typeCoordinate.memberName?.value; // => 'name'
|
|
1606
|
+
* directiveCoordinate.name.value; // => 'deprecated'
|
|
1607
|
+
* directiveCoordinate.argumentName?.value; // => 'reason'
|
|
1608
|
+
* ```
|
|
1414
1609
|
*/
|
|
1415
1610
|
|
|
1416
1611
|
parseSchemaCoordinate() {
|
|
@@ -1474,6 +1669,8 @@ export class Parser {
|
|
|
1474
1669
|
* Returns a node that, if configured to do so, sets a "loc" field as a
|
|
1475
1670
|
* location object, used to identify the place in the source that created a
|
|
1476
1671
|
* given parsed object.
|
|
1672
|
+
*
|
|
1673
|
+
* @internal
|
|
1477
1674
|
*/
|
|
1478
1675
|
|
|
1479
1676
|
node(startToken, node) {
|
|
@@ -1489,6 +1686,8 @@ export class Parser {
|
|
|
1489
1686
|
}
|
|
1490
1687
|
/**
|
|
1491
1688
|
* Determines if the next token is of a given kind
|
|
1689
|
+
*
|
|
1690
|
+
* @internal
|
|
1492
1691
|
*/
|
|
1493
1692
|
|
|
1494
1693
|
peek(kind) {
|
|
@@ -1497,6 +1696,8 @@ export class Parser {
|
|
|
1497
1696
|
/**
|
|
1498
1697
|
* If the next token is of the given kind, return that token after advancing the lexer.
|
|
1499
1698
|
* Otherwise, do not change the parser state and throw an error.
|
|
1699
|
+
*
|
|
1700
|
+
* @internal
|
|
1500
1701
|
*/
|
|
1501
1702
|
|
|
1502
1703
|
expectToken(kind) {
|
|
@@ -1516,6 +1717,8 @@ export class Parser {
|
|
|
1516
1717
|
/**
|
|
1517
1718
|
* If the next token is of the given kind, return "true" after advancing the lexer.
|
|
1518
1719
|
* Otherwise, do not change the parser state and return "false".
|
|
1720
|
+
*
|
|
1721
|
+
* @internal
|
|
1519
1722
|
*/
|
|
1520
1723
|
|
|
1521
1724
|
expectOptionalToken(kind) {
|
|
@@ -1531,6 +1734,8 @@ export class Parser {
|
|
|
1531
1734
|
/**
|
|
1532
1735
|
* If the next token is a given keyword, advance the lexer.
|
|
1533
1736
|
* Otherwise, do not change the parser state and throw an error.
|
|
1737
|
+
*
|
|
1738
|
+
* @internal
|
|
1534
1739
|
*/
|
|
1535
1740
|
|
|
1536
1741
|
expectKeyword(value) {
|
|
@@ -1549,6 +1754,8 @@ export class Parser {
|
|
|
1549
1754
|
/**
|
|
1550
1755
|
* If the next token is a given keyword, return "true" after advancing the lexer.
|
|
1551
1756
|
* Otherwise, do not change the parser state and return "false".
|
|
1757
|
+
*
|
|
1758
|
+
* @internal
|
|
1552
1759
|
*/
|
|
1553
1760
|
|
|
1554
1761
|
expectOptionalKeyword(value) {
|
|
@@ -1563,6 +1770,8 @@ export class Parser {
|
|
|
1563
1770
|
}
|
|
1564
1771
|
/**
|
|
1565
1772
|
* Helper function for creating an error when an unexpected lexed token is encountered.
|
|
1773
|
+
*
|
|
1774
|
+
* @internal
|
|
1566
1775
|
*/
|
|
1567
1776
|
|
|
1568
1777
|
unexpected(atToken) {
|
|
@@ -1578,6 +1787,8 @@ export class Parser {
|
|
|
1578
1787
|
* Returns a possibly empty list of parse nodes, determined by the parseFn.
|
|
1579
1788
|
* This list begins with a lex token of openKind and ends with a lex token of closeKind.
|
|
1580
1789
|
* Advances the parser to the next lex token after the closing token.
|
|
1790
|
+
*
|
|
1791
|
+
* @internal
|
|
1581
1792
|
*/
|
|
1582
1793
|
|
|
1583
1794
|
any(openKind, parseFn, closeKind) {
|
|
@@ -1595,6 +1806,8 @@ export class Parser {
|
|
|
1595
1806
|
* It can be empty only if open token is missing otherwise it will always return non-empty list
|
|
1596
1807
|
* that begins with a lex token of openKind and ends with a lex token of closeKind.
|
|
1597
1808
|
* Advances the parser to the next lex token after the closing token.
|
|
1809
|
+
*
|
|
1810
|
+
* @internal
|
|
1598
1811
|
*/
|
|
1599
1812
|
|
|
1600
1813
|
optionalMany(openKind, parseFn, closeKind) {
|
|
@@ -1614,6 +1827,8 @@ export class Parser {
|
|
|
1614
1827
|
* Returns a non-empty list of parse nodes, determined by the parseFn.
|
|
1615
1828
|
* This list begins with a lex token of openKind and ends with a lex token of closeKind.
|
|
1616
1829
|
* Advances the parser to the next lex token after the closing token.
|
|
1830
|
+
*
|
|
1831
|
+
* @internal
|
|
1617
1832
|
*/
|
|
1618
1833
|
|
|
1619
1834
|
many(openKind, parseFn, closeKind) {
|
|
@@ -1630,6 +1845,8 @@ export class Parser {
|
|
|
1630
1845
|
* Returns a non-empty list of parse nodes, determined by the parseFn.
|
|
1631
1846
|
* This list may begin with a lex token of delimiterKind followed by items separated by lex tokens of tokenKind.
|
|
1632
1847
|
* Advances the parser to the next lex token after last item in the list.
|
|
1848
|
+
*
|
|
1849
|
+
* @internal
|
|
1633
1850
|
*/
|
|
1634
1851
|
|
|
1635
1852
|
delimitedMany(delimiterKind, parseFn) {
|
|
@@ -1663,6 +1880,8 @@ export class Parser {
|
|
|
1663
1880
|
}
|
|
1664
1881
|
/**
|
|
1665
1882
|
* A helper function to describe a token as a string for debugging.
|
|
1883
|
+
*
|
|
1884
|
+
* @internal
|
|
1666
1885
|
*/
|
|
1667
1886
|
|
|
1668
1887
|
function getTokenDesc(token) {
|
|
@@ -1671,6 +1890,8 @@ function getTokenDesc(token) {
|
|
|
1671
1890
|
}
|
|
1672
1891
|
/**
|
|
1673
1892
|
* A helper function to describe a token kind as a string for debugging.
|
|
1893
|
+
*
|
|
1894
|
+
* @internal
|
|
1674
1895
|
*/
|
|
1675
1896
|
|
|
1676
1897
|
function getTokenKindDesc(kind) {
|