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.js
CHANGED
|
@@ -26,9 +26,44 @@ var _source = require('./source.js');
|
|
|
26
26
|
|
|
27
27
|
var _tokenKind = require('./tokenKind.js');
|
|
28
28
|
|
|
29
|
+
/** @category Parsing */
|
|
30
|
+
|
|
29
31
|
/**
|
|
30
32
|
* Given a GraphQL source, parses it into a Document.
|
|
31
33
|
* Throws GraphQLError if a syntax error is encountered.
|
|
34
|
+
* @param source - A GraphQL source string or source object.
|
|
35
|
+
* @param options - Optional parser configuration.
|
|
36
|
+
* @returns The parsed GraphQL document AST.
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* // Parse a GraphQL document with the default parser options.
|
|
40
|
+
* import { parse } from 'graphql/language';
|
|
41
|
+
*
|
|
42
|
+
* const document = parse('{ hero { name } }');
|
|
43
|
+
*
|
|
44
|
+
* document.kind; // => 'Document'
|
|
45
|
+
* ```
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* // This variant enables parser options and provides an explicit lexer.
|
|
49
|
+
* import { Lexer, Source, parse } from 'graphql/language';
|
|
50
|
+
*
|
|
51
|
+
* const document = parse('fragment A($var: Boolean) on Query { field }', {
|
|
52
|
+
* allowLegacyFragmentVariables: true,
|
|
53
|
+
* maxTokens: 20,
|
|
54
|
+
* noLocation: true,
|
|
55
|
+
* });
|
|
56
|
+
* const directiveDocument = parse('directive @foo @bar on FIELD', {
|
|
57
|
+
* experimentalDirectivesOnDirectiveDefinitions: true,
|
|
58
|
+
* });
|
|
59
|
+
* const source = new Source('{ hero }');
|
|
60
|
+
* const lexerDocument = parse(source, { lexer: new Lexer(source) });
|
|
61
|
+
*
|
|
62
|
+
* document.definitions[0].kind; // => 'FragmentDefinition'
|
|
63
|
+
* document.loc; // => undefined
|
|
64
|
+
* directiveDocument.definitions[0].kind; // => 'DirectiveDefinition'
|
|
65
|
+
* lexerDocument.definitions[0].kind; // => 'OperationDefinition'
|
|
66
|
+
* ```
|
|
32
67
|
*/
|
|
33
68
|
function parse(source, options) {
|
|
34
69
|
const parser = new Parser(source, options);
|
|
@@ -48,6 +83,17 @@ function parse(source, options) {
|
|
|
48
83
|
* in isolation of complete GraphQL documents.
|
|
49
84
|
*
|
|
50
85
|
* Consider providing the results to the utility function: valueFromAST().
|
|
86
|
+
* @param source - A GraphQL source string or source object containing a value.
|
|
87
|
+
* @param options - Optional parser configuration.
|
|
88
|
+
* @returns The parsed GraphQL value AST.
|
|
89
|
+
* @example
|
|
90
|
+
* ```ts
|
|
91
|
+
* import { parseValue } from 'graphql/language';
|
|
92
|
+
*
|
|
93
|
+
* const value = parseValue('[42]');
|
|
94
|
+
*
|
|
95
|
+
* value.kind; // => 'ListValue'
|
|
96
|
+
* ```
|
|
51
97
|
*/
|
|
52
98
|
|
|
53
99
|
function parseValue(source, options) {
|
|
@@ -60,6 +106,18 @@ function parseValue(source, options) {
|
|
|
60
106
|
/**
|
|
61
107
|
* Similar to parseValue(), but raises a parse error if it encounters a
|
|
62
108
|
* variable. The return type will be a constant value.
|
|
109
|
+
* @param source - A GraphQL source string or source object containing a constant value.
|
|
110
|
+
* @param options - Optional parser configuration.
|
|
111
|
+
* @returns The parsed GraphQL constant value AST.
|
|
112
|
+
* @example
|
|
113
|
+
* ```ts
|
|
114
|
+
* import { parseConstValue } from 'graphql/language';
|
|
115
|
+
*
|
|
116
|
+
* const value = parseConstValue('{ enabled: true }');
|
|
117
|
+
*
|
|
118
|
+
* value.kind; // => 'ObjectValue'
|
|
119
|
+
* parseConstValue('$variable'); // throws an error
|
|
120
|
+
* ```
|
|
63
121
|
*/
|
|
64
122
|
|
|
65
123
|
function parseConstValue(source, options) {
|
|
@@ -78,6 +136,17 @@ function parseConstValue(source, options) {
|
|
|
78
136
|
* in isolation of complete GraphQL documents.
|
|
79
137
|
*
|
|
80
138
|
* Consider providing the results to the utility function: typeFromAST().
|
|
139
|
+
* @param source - A GraphQL source string or source object containing a type reference.
|
|
140
|
+
* @param options - Optional parser configuration.
|
|
141
|
+
* @returns The parsed GraphQL type AST.
|
|
142
|
+
* @example
|
|
143
|
+
* ```ts
|
|
144
|
+
* import { parseType } from 'graphql/language';
|
|
145
|
+
*
|
|
146
|
+
* const type = parseType('[String!]');
|
|
147
|
+
*
|
|
148
|
+
* type.kind; // => 'ListType'
|
|
149
|
+
* ```
|
|
81
150
|
*/
|
|
82
151
|
|
|
83
152
|
function parseType(source, options) {
|
|
@@ -95,6 +164,16 @@ function parseType(source, options) {
|
|
|
95
164
|
* Consider providing the results to the utility function:
|
|
96
165
|
* resolveASTSchemaCoordinate(). Or calling resolveSchemaCoordinate() directly
|
|
97
166
|
* with an unparsed source.
|
|
167
|
+
* @param source - A GraphQL source string or source object containing a schema coordinate.
|
|
168
|
+
* @returns The parsed GraphQL schema coordinate AST.
|
|
169
|
+
* @example
|
|
170
|
+
* ```ts
|
|
171
|
+
* import { parseSchemaCoordinate } from 'graphql/language';
|
|
172
|
+
*
|
|
173
|
+
* const coordinate = parseSchemaCoordinate('Query.hero');
|
|
174
|
+
*
|
|
175
|
+
* coordinate.kind; // => 'MemberCoordinate'
|
|
176
|
+
* ```
|
|
98
177
|
*/
|
|
99
178
|
|
|
100
179
|
function parseSchemaCoordinate(source) {
|
|
@@ -144,6 +223,8 @@ class Parser {
|
|
|
144
223
|
}
|
|
145
224
|
/**
|
|
146
225
|
* Converts a name lex token into a name parse node.
|
|
226
|
+
*
|
|
227
|
+
* @internal
|
|
147
228
|
*/
|
|
148
229
|
|
|
149
230
|
parseName() {
|
|
@@ -156,6 +237,8 @@ class Parser {
|
|
|
156
237
|
|
|
157
238
|
/**
|
|
158
239
|
* Document : Definition+
|
|
240
|
+
*
|
|
241
|
+
* @internal
|
|
159
242
|
*/
|
|
160
243
|
|
|
161
244
|
parseDocument() {
|
|
@@ -190,6 +273,8 @@ class Parser {
|
|
|
190
273
|
* - UnionTypeDefinition
|
|
191
274
|
* - EnumTypeDefinition
|
|
192
275
|
* - InputObjectTypeDefinition
|
|
276
|
+
*
|
|
277
|
+
* @internal
|
|
193
278
|
*/
|
|
194
279
|
|
|
195
280
|
parseDefinition() {
|
|
@@ -268,6 +353,8 @@ class Parser {
|
|
|
268
353
|
* OperationDefinition :
|
|
269
354
|
* - SelectionSet
|
|
270
355
|
* - OperationType Name? VariableDefinitions? Directives? SelectionSet
|
|
356
|
+
*
|
|
357
|
+
* @internal
|
|
271
358
|
*/
|
|
272
359
|
|
|
273
360
|
parseOperationDefinition() {
|
|
@@ -305,6 +392,8 @@ class Parser {
|
|
|
305
392
|
}
|
|
306
393
|
/**
|
|
307
394
|
* OperationType : one of query mutation subscription
|
|
395
|
+
*
|
|
396
|
+
* @internal
|
|
308
397
|
*/
|
|
309
398
|
|
|
310
399
|
parseOperationType() {
|
|
@@ -325,6 +414,8 @@ class Parser {
|
|
|
325
414
|
}
|
|
326
415
|
/**
|
|
327
416
|
* VariableDefinitions : ( VariableDefinition+ )
|
|
417
|
+
*
|
|
418
|
+
* @internal
|
|
328
419
|
*/
|
|
329
420
|
|
|
330
421
|
parseVariableDefinitions() {
|
|
@@ -336,6 +427,8 @@ class Parser {
|
|
|
336
427
|
}
|
|
337
428
|
/**
|
|
338
429
|
* VariableDefinition : Variable : Type DefaultValue? Directives[Const]?
|
|
430
|
+
*
|
|
431
|
+
* @internal
|
|
339
432
|
*/
|
|
340
433
|
|
|
341
434
|
parseVariableDefinition() {
|
|
@@ -354,6 +447,8 @@ class Parser {
|
|
|
354
447
|
}
|
|
355
448
|
/**
|
|
356
449
|
* Variable : $ Name
|
|
450
|
+
*
|
|
451
|
+
* @internal
|
|
357
452
|
*/
|
|
358
453
|
|
|
359
454
|
parseVariable() {
|
|
@@ -368,6 +463,8 @@ class Parser {
|
|
|
368
463
|
* ```
|
|
369
464
|
* SelectionSet : { Selection+ }
|
|
370
465
|
* ```
|
|
466
|
+
*
|
|
467
|
+
* @internal
|
|
371
468
|
*/
|
|
372
469
|
|
|
373
470
|
parseSelectionSet() {
|
|
@@ -385,6 +482,8 @@ class Parser {
|
|
|
385
482
|
* - Field
|
|
386
483
|
* - FragmentSpread
|
|
387
484
|
* - InlineFragment
|
|
485
|
+
*
|
|
486
|
+
* @internal
|
|
388
487
|
*/
|
|
389
488
|
|
|
390
489
|
parseSelection() {
|
|
@@ -396,6 +495,8 @@ class Parser {
|
|
|
396
495
|
* Field : Alias? Name Arguments? Directives? SelectionSet?
|
|
397
496
|
*
|
|
398
497
|
* Alias : Name :
|
|
498
|
+
*
|
|
499
|
+
* @internal
|
|
399
500
|
*/
|
|
400
501
|
|
|
401
502
|
parseField() {
|
|
@@ -424,6 +525,8 @@ class Parser {
|
|
|
424
525
|
}
|
|
425
526
|
/**
|
|
426
527
|
* Arguments[Const] : ( Argument[?Const]+ )
|
|
528
|
+
*
|
|
529
|
+
* @internal
|
|
427
530
|
*/
|
|
428
531
|
|
|
429
532
|
parseArguments(isConst) {
|
|
@@ -436,6 +539,8 @@ class Parser {
|
|
|
436
539
|
}
|
|
437
540
|
/**
|
|
438
541
|
* Argument[Const] : Name : Value[?Const]
|
|
542
|
+
*
|
|
543
|
+
* @internal
|
|
439
544
|
*/
|
|
440
545
|
|
|
441
546
|
parseArgument(isConst = false) {
|
|
@@ -459,6 +564,8 @@ class Parser {
|
|
|
459
564
|
* FragmentSpread : ... FragmentName Directives?
|
|
460
565
|
*
|
|
461
566
|
* InlineFragment : ... TypeCondition? Directives? SelectionSet
|
|
567
|
+
*
|
|
568
|
+
* @internal
|
|
462
569
|
*/
|
|
463
570
|
|
|
464
571
|
parseFragment() {
|
|
@@ -486,6 +593,8 @@ class Parser {
|
|
|
486
593
|
* - fragment FragmentName on TypeCondition Directives? SelectionSet
|
|
487
594
|
*
|
|
488
595
|
* TypeCondition : NamedType
|
|
596
|
+
*
|
|
597
|
+
* @internal
|
|
489
598
|
*/
|
|
490
599
|
|
|
491
600
|
parseFragmentDefinition() {
|
|
@@ -518,6 +627,8 @@ class Parser {
|
|
|
518
627
|
}
|
|
519
628
|
/**
|
|
520
629
|
* FragmentName : Name but not `on`
|
|
630
|
+
*
|
|
631
|
+
* @internal
|
|
521
632
|
*/
|
|
522
633
|
|
|
523
634
|
parseFragmentName() {
|
|
@@ -545,6 +656,8 @@ class Parser {
|
|
|
545
656
|
* NullValue : `null`
|
|
546
657
|
*
|
|
547
658
|
* EnumValue : Name but not `true`, `false` or `null`
|
|
659
|
+
*
|
|
660
|
+
* @internal
|
|
548
661
|
*/
|
|
549
662
|
|
|
550
663
|
parseValueLiteral(isConst) {
|
|
@@ -643,6 +756,8 @@ class Parser {
|
|
|
643
756
|
* ListValue[Const] :
|
|
644
757
|
* - [ ]
|
|
645
758
|
* - [ Value[?Const]+ ]
|
|
759
|
+
*
|
|
760
|
+
* @internal
|
|
646
761
|
*/
|
|
647
762
|
|
|
648
763
|
parseList(isConst) {
|
|
@@ -663,6 +778,8 @@ class Parser {
|
|
|
663
778
|
* - { }
|
|
664
779
|
* - { ObjectField[?Const]+ }
|
|
665
780
|
* ```
|
|
781
|
+
*
|
|
782
|
+
* @internal
|
|
666
783
|
*/
|
|
667
784
|
|
|
668
785
|
parseObject(isConst) {
|
|
@@ -679,6 +796,8 @@ class Parser {
|
|
|
679
796
|
}
|
|
680
797
|
/**
|
|
681
798
|
* ObjectField[Const] : Name : Value[?Const]
|
|
799
|
+
*
|
|
800
|
+
* @internal
|
|
682
801
|
*/
|
|
683
802
|
|
|
684
803
|
parseObjectField(isConst) {
|
|
@@ -694,6 +813,8 @@ class Parser {
|
|
|
694
813
|
|
|
695
814
|
/**
|
|
696
815
|
* Directives[Const] : Directive[?Const]+
|
|
816
|
+
*
|
|
817
|
+
* @internal
|
|
697
818
|
*/
|
|
698
819
|
|
|
699
820
|
parseDirectives(isConst) {
|
|
@@ -713,6 +834,8 @@ class Parser {
|
|
|
713
834
|
* ```
|
|
714
835
|
* Directive[Const] : @ Name Arguments[?Const]?
|
|
715
836
|
* ```
|
|
837
|
+
*
|
|
838
|
+
* @internal
|
|
716
839
|
*/
|
|
717
840
|
|
|
718
841
|
parseDirective(isConst) {
|
|
@@ -730,6 +853,8 @@ class Parser {
|
|
|
730
853
|
* - NamedType
|
|
731
854
|
* - ListType
|
|
732
855
|
* - NonNullType
|
|
856
|
+
*
|
|
857
|
+
* @internal
|
|
733
858
|
*/
|
|
734
859
|
|
|
735
860
|
parseTypeReference() {
|
|
@@ -758,6 +883,8 @@ class Parser {
|
|
|
758
883
|
}
|
|
759
884
|
/**
|
|
760
885
|
* NamedType : Name
|
|
886
|
+
*
|
|
887
|
+
* @internal
|
|
761
888
|
*/
|
|
762
889
|
|
|
763
890
|
parseNamedType() {
|
|
@@ -775,6 +902,8 @@ class Parser {
|
|
|
775
902
|
}
|
|
776
903
|
/**
|
|
777
904
|
* Description : StringValue
|
|
905
|
+
*
|
|
906
|
+
* @internal
|
|
778
907
|
*/
|
|
779
908
|
|
|
780
909
|
parseDescription() {
|
|
@@ -786,6 +915,8 @@ class Parser {
|
|
|
786
915
|
* ```
|
|
787
916
|
* SchemaDefinition : Description? schema Directives[Const]? { OperationTypeDefinition+ }
|
|
788
917
|
* ```
|
|
918
|
+
*
|
|
919
|
+
* @internal
|
|
789
920
|
*/
|
|
790
921
|
|
|
791
922
|
parseSchemaDefinition() {
|
|
@@ -807,6 +938,8 @@ class Parser {
|
|
|
807
938
|
}
|
|
808
939
|
/**
|
|
809
940
|
* OperationTypeDefinition : OperationType : NamedType
|
|
941
|
+
*
|
|
942
|
+
* @internal
|
|
810
943
|
*/
|
|
811
944
|
|
|
812
945
|
parseOperationTypeDefinition() {
|
|
@@ -822,6 +955,8 @@ class Parser {
|
|
|
822
955
|
}
|
|
823
956
|
/**
|
|
824
957
|
* ScalarTypeDefinition : Description? scalar Name Directives[Const]?
|
|
958
|
+
*
|
|
959
|
+
* @internal
|
|
825
960
|
*/
|
|
826
961
|
|
|
827
962
|
parseScalarTypeDefinition() {
|
|
@@ -841,6 +976,8 @@ class Parser {
|
|
|
841
976
|
* ObjectTypeDefinition :
|
|
842
977
|
* Description?
|
|
843
978
|
* type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition?
|
|
979
|
+
*
|
|
980
|
+
* @internal
|
|
844
981
|
*/
|
|
845
982
|
|
|
846
983
|
parseObjectTypeDefinition() {
|
|
@@ -864,6 +1001,8 @@ class Parser {
|
|
|
864
1001
|
* ImplementsInterfaces :
|
|
865
1002
|
* - implements `&`? NamedType
|
|
866
1003
|
* - ImplementsInterfaces & NamedType
|
|
1004
|
+
*
|
|
1005
|
+
* @internal
|
|
867
1006
|
*/
|
|
868
1007
|
|
|
869
1008
|
parseImplementsInterfaces() {
|
|
@@ -875,6 +1014,8 @@ class Parser {
|
|
|
875
1014
|
* ```
|
|
876
1015
|
* FieldsDefinition : { FieldDefinition+ }
|
|
877
1016
|
* ```
|
|
1017
|
+
*
|
|
1018
|
+
* @internal
|
|
878
1019
|
*/
|
|
879
1020
|
|
|
880
1021
|
parseFieldsDefinition() {
|
|
@@ -887,6 +1028,8 @@ class Parser {
|
|
|
887
1028
|
/**
|
|
888
1029
|
* FieldDefinition :
|
|
889
1030
|
* - Description? Name ArgumentsDefinition? : Type Directives[Const]?
|
|
1031
|
+
*
|
|
1032
|
+
* @internal
|
|
890
1033
|
*/
|
|
891
1034
|
|
|
892
1035
|
parseFieldDefinition() {
|
|
@@ -908,6 +1051,8 @@ class Parser {
|
|
|
908
1051
|
}
|
|
909
1052
|
/**
|
|
910
1053
|
* ArgumentsDefinition : ( InputValueDefinition+ )
|
|
1054
|
+
*
|
|
1055
|
+
* @internal
|
|
911
1056
|
*/
|
|
912
1057
|
|
|
913
1058
|
parseArgumentDefs() {
|
|
@@ -920,6 +1065,8 @@ class Parser {
|
|
|
920
1065
|
/**
|
|
921
1066
|
* InputValueDefinition :
|
|
922
1067
|
* - Description? Name : Type DefaultValue? Directives[Const]?
|
|
1068
|
+
*
|
|
1069
|
+
* @internal
|
|
923
1070
|
*/
|
|
924
1071
|
|
|
925
1072
|
parseInputValueDef() {
|
|
@@ -947,6 +1094,8 @@ class Parser {
|
|
|
947
1094
|
/**
|
|
948
1095
|
* InterfaceTypeDefinition :
|
|
949
1096
|
* - Description? interface Name Directives[Const]? FieldsDefinition?
|
|
1097
|
+
*
|
|
1098
|
+
* @internal
|
|
950
1099
|
*/
|
|
951
1100
|
|
|
952
1101
|
parseInterfaceTypeDefinition() {
|
|
@@ -969,6 +1118,8 @@ class Parser {
|
|
|
969
1118
|
/**
|
|
970
1119
|
* UnionTypeDefinition :
|
|
971
1120
|
* - Description? union Name Directives[Const]? UnionMemberTypes?
|
|
1121
|
+
*
|
|
1122
|
+
* @internal
|
|
972
1123
|
*/
|
|
973
1124
|
|
|
974
1125
|
parseUnionTypeDefinition() {
|
|
@@ -990,6 +1141,8 @@ class Parser {
|
|
|
990
1141
|
* UnionMemberTypes :
|
|
991
1142
|
* - = `|`? NamedType
|
|
992
1143
|
* - UnionMemberTypes | NamedType
|
|
1144
|
+
*
|
|
1145
|
+
* @internal
|
|
993
1146
|
*/
|
|
994
1147
|
|
|
995
1148
|
parseUnionMemberTypes() {
|
|
@@ -1000,6 +1153,8 @@ class Parser {
|
|
|
1000
1153
|
/**
|
|
1001
1154
|
* EnumTypeDefinition :
|
|
1002
1155
|
* - Description? enum Name Directives[Const]? EnumValuesDefinition?
|
|
1156
|
+
*
|
|
1157
|
+
* @internal
|
|
1003
1158
|
*/
|
|
1004
1159
|
|
|
1005
1160
|
parseEnumTypeDefinition() {
|
|
@@ -1021,6 +1176,8 @@ class Parser {
|
|
|
1021
1176
|
* ```
|
|
1022
1177
|
* EnumValuesDefinition : { EnumValueDefinition+ }
|
|
1023
1178
|
* ```
|
|
1179
|
+
*
|
|
1180
|
+
* @internal
|
|
1024
1181
|
*/
|
|
1025
1182
|
|
|
1026
1183
|
parseEnumValuesDefinition() {
|
|
@@ -1032,6 +1189,8 @@ class Parser {
|
|
|
1032
1189
|
}
|
|
1033
1190
|
/**
|
|
1034
1191
|
* EnumValueDefinition : Description? EnumValue Directives[Const]?
|
|
1192
|
+
*
|
|
1193
|
+
* @internal
|
|
1035
1194
|
*/
|
|
1036
1195
|
|
|
1037
1196
|
parseEnumValueDefinition() {
|
|
@@ -1048,6 +1207,8 @@ class Parser {
|
|
|
1048
1207
|
}
|
|
1049
1208
|
/**
|
|
1050
1209
|
* EnumValue : Name but not `true`, `false` or `null`
|
|
1210
|
+
*
|
|
1211
|
+
* @internal
|
|
1051
1212
|
*/
|
|
1052
1213
|
|
|
1053
1214
|
parseEnumValueName() {
|
|
@@ -1070,6 +1231,8 @@ class Parser {
|
|
|
1070
1231
|
/**
|
|
1071
1232
|
* InputObjectTypeDefinition :
|
|
1072
1233
|
* - Description? input Name Directives[Const]? InputFieldsDefinition?
|
|
1234
|
+
*
|
|
1235
|
+
* @internal
|
|
1073
1236
|
*/
|
|
1074
1237
|
|
|
1075
1238
|
parseInputObjectTypeDefinition() {
|
|
@@ -1091,6 +1254,8 @@ class Parser {
|
|
|
1091
1254
|
* ```
|
|
1092
1255
|
* InputFieldsDefinition : { InputValueDefinition+ }
|
|
1093
1256
|
* ```
|
|
1257
|
+
*
|
|
1258
|
+
* @internal
|
|
1094
1259
|
*/
|
|
1095
1260
|
|
|
1096
1261
|
parseInputFieldsDefinition() {
|
|
@@ -1113,6 +1278,8 @@ class Parser {
|
|
|
1113
1278
|
* - EnumTypeExtension
|
|
1114
1279
|
* - InputObjectTypeDefinition
|
|
1115
1280
|
* - DirectiveDefinitionExtension
|
|
1281
|
+
*
|
|
1282
|
+
* @internal
|
|
1116
1283
|
*/
|
|
1117
1284
|
|
|
1118
1285
|
parseTypeSystemExtension() {
|
|
@@ -1158,6 +1325,8 @@ class Parser {
|
|
|
1158
1325
|
* - extend schema Directives[Const]? { OperationTypeDefinition+ }
|
|
1159
1326
|
* - extend schema Directives[Const]
|
|
1160
1327
|
* ```
|
|
1328
|
+
*
|
|
1329
|
+
* @internal
|
|
1161
1330
|
*/
|
|
1162
1331
|
|
|
1163
1332
|
parseSchemaExtension() {
|
|
@@ -1184,6 +1353,8 @@ class Parser {
|
|
|
1184
1353
|
/**
|
|
1185
1354
|
* ScalarTypeExtension :
|
|
1186
1355
|
* - extend scalar Name Directives[Const]
|
|
1356
|
+
*
|
|
1357
|
+
* @internal
|
|
1187
1358
|
*/
|
|
1188
1359
|
|
|
1189
1360
|
parseScalarTypeExtension() {
|
|
@@ -1208,6 +1379,8 @@ class Parser {
|
|
|
1208
1379
|
* - extend type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
|
|
1209
1380
|
* - extend type Name ImplementsInterfaces? Directives[Const]
|
|
1210
1381
|
* - extend type Name ImplementsInterfaces
|
|
1382
|
+
*
|
|
1383
|
+
* @internal
|
|
1211
1384
|
*/
|
|
1212
1385
|
|
|
1213
1386
|
parseObjectTypeExtension() {
|
|
@@ -1240,6 +1413,8 @@ class Parser {
|
|
|
1240
1413
|
* - extend interface Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
|
|
1241
1414
|
* - extend interface Name ImplementsInterfaces? Directives[Const]
|
|
1242
1415
|
* - extend interface Name ImplementsInterfaces
|
|
1416
|
+
*
|
|
1417
|
+
* @internal
|
|
1243
1418
|
*/
|
|
1244
1419
|
|
|
1245
1420
|
parseInterfaceTypeExtension() {
|
|
@@ -1271,6 +1446,8 @@ class Parser {
|
|
|
1271
1446
|
* UnionTypeExtension :
|
|
1272
1447
|
* - extend union Name Directives[Const]? UnionMemberTypes
|
|
1273
1448
|
* - extend union Name Directives[Const]
|
|
1449
|
+
*
|
|
1450
|
+
* @internal
|
|
1274
1451
|
*/
|
|
1275
1452
|
|
|
1276
1453
|
parseUnionTypeExtension() {
|
|
@@ -1296,6 +1473,8 @@ class Parser {
|
|
|
1296
1473
|
* EnumTypeExtension :
|
|
1297
1474
|
* - extend enum Name Directives[Const]? EnumValuesDefinition
|
|
1298
1475
|
* - extend enum Name Directives[Const]
|
|
1476
|
+
*
|
|
1477
|
+
* @internal
|
|
1299
1478
|
*/
|
|
1300
1479
|
|
|
1301
1480
|
parseEnumTypeExtension() {
|
|
@@ -1321,6 +1500,8 @@ class Parser {
|
|
|
1321
1500
|
* InputObjectTypeExtension :
|
|
1322
1501
|
* - extend input Name Directives[Const]? InputFieldsDefinition
|
|
1323
1502
|
* - extend input Name Directives[Const]
|
|
1503
|
+
*
|
|
1504
|
+
* @internal
|
|
1324
1505
|
*/
|
|
1325
1506
|
|
|
1326
1507
|
parseInputObjectTypeExtension() {
|
|
@@ -1366,6 +1547,8 @@ class Parser {
|
|
|
1366
1547
|
* DirectiveDefinition :
|
|
1367
1548
|
* - Description? directive @ Name ArgumentsDefinition? `repeatable`? on DirectiveLocations
|
|
1368
1549
|
* ```
|
|
1550
|
+
*
|
|
1551
|
+
* @internal
|
|
1369
1552
|
*/
|
|
1370
1553
|
|
|
1371
1554
|
parseDirectiveDefinition() {
|
|
@@ -1396,6 +1579,8 @@ class Parser {
|
|
|
1396
1579
|
* DirectiveLocations :
|
|
1397
1580
|
* - `|`? DirectiveLocation
|
|
1398
1581
|
* - DirectiveLocations | DirectiveLocation
|
|
1582
|
+
*
|
|
1583
|
+
* @internal
|
|
1399
1584
|
*/
|
|
1400
1585
|
|
|
1401
1586
|
parseDirectiveLocations() {
|
|
@@ -1456,6 +1641,19 @@ class Parser {
|
|
|
1456
1641
|
* - Name . Name ( Name : )
|
|
1457
1642
|
* - \@ Name
|
|
1458
1643
|
* - \@ Name ( Name : )
|
|
1644
|
+
* @returns Parsed schema coordinate AST.
|
|
1645
|
+
* @example
|
|
1646
|
+
* ```ts
|
|
1647
|
+
* import { Parser, Source } from 'graphql/language';
|
|
1648
|
+
*
|
|
1649
|
+
* const typeCoordinate = new Parser(new Source('User.name')).parseSchemaCoordinate();
|
|
1650
|
+
* const directiveCoordinate = new Parser(new Source('@include(if:)')).parseSchemaCoordinate();
|
|
1651
|
+
*
|
|
1652
|
+
* typeCoordinate.name.value; // => 'User'
|
|
1653
|
+
* typeCoordinate.memberName?.value; // => 'name'
|
|
1654
|
+
* directiveCoordinate.name.value; // => 'deprecated'
|
|
1655
|
+
* directiveCoordinate.argumentName?.value; // => 'reason'
|
|
1656
|
+
* ```
|
|
1459
1657
|
*/
|
|
1460
1658
|
|
|
1461
1659
|
parseSchemaCoordinate() {
|
|
@@ -1519,6 +1717,8 @@ class Parser {
|
|
|
1519
1717
|
* Returns a node that, if configured to do so, sets a "loc" field as a
|
|
1520
1718
|
* location object, used to identify the place in the source that created a
|
|
1521
1719
|
* given parsed object.
|
|
1720
|
+
*
|
|
1721
|
+
* @internal
|
|
1522
1722
|
*/
|
|
1523
1723
|
|
|
1524
1724
|
node(startToken, node) {
|
|
@@ -1534,6 +1734,8 @@ class Parser {
|
|
|
1534
1734
|
}
|
|
1535
1735
|
/**
|
|
1536
1736
|
* Determines if the next token is of a given kind
|
|
1737
|
+
*
|
|
1738
|
+
* @internal
|
|
1537
1739
|
*/
|
|
1538
1740
|
|
|
1539
1741
|
peek(kind) {
|
|
@@ -1542,6 +1744,8 @@ class Parser {
|
|
|
1542
1744
|
/**
|
|
1543
1745
|
* If the next token is of the given kind, return that token after advancing the lexer.
|
|
1544
1746
|
* Otherwise, do not change the parser state and throw an error.
|
|
1747
|
+
*
|
|
1748
|
+
* @internal
|
|
1545
1749
|
*/
|
|
1546
1750
|
|
|
1547
1751
|
expectToken(kind) {
|
|
@@ -1561,6 +1765,8 @@ class Parser {
|
|
|
1561
1765
|
/**
|
|
1562
1766
|
* If the next token is of the given kind, return "true" after advancing the lexer.
|
|
1563
1767
|
* Otherwise, do not change the parser state and return "false".
|
|
1768
|
+
*
|
|
1769
|
+
* @internal
|
|
1564
1770
|
*/
|
|
1565
1771
|
|
|
1566
1772
|
expectOptionalToken(kind) {
|
|
@@ -1576,6 +1782,8 @@ class Parser {
|
|
|
1576
1782
|
/**
|
|
1577
1783
|
* If the next token is a given keyword, advance the lexer.
|
|
1578
1784
|
* Otherwise, do not change the parser state and throw an error.
|
|
1785
|
+
*
|
|
1786
|
+
* @internal
|
|
1579
1787
|
*/
|
|
1580
1788
|
|
|
1581
1789
|
expectKeyword(value) {
|
|
@@ -1594,6 +1802,8 @@ class Parser {
|
|
|
1594
1802
|
/**
|
|
1595
1803
|
* If the next token is a given keyword, return "true" after advancing the lexer.
|
|
1596
1804
|
* Otherwise, do not change the parser state and return "false".
|
|
1805
|
+
*
|
|
1806
|
+
* @internal
|
|
1597
1807
|
*/
|
|
1598
1808
|
|
|
1599
1809
|
expectOptionalKeyword(value) {
|
|
@@ -1608,6 +1818,8 @@ class Parser {
|
|
|
1608
1818
|
}
|
|
1609
1819
|
/**
|
|
1610
1820
|
* Helper function for creating an error when an unexpected lexed token is encountered.
|
|
1821
|
+
*
|
|
1822
|
+
* @internal
|
|
1611
1823
|
*/
|
|
1612
1824
|
|
|
1613
1825
|
unexpected(atToken) {
|
|
@@ -1623,6 +1835,8 @@ class Parser {
|
|
|
1623
1835
|
* Returns a possibly empty list of parse nodes, determined by the parseFn.
|
|
1624
1836
|
* This list begins with a lex token of openKind and ends with a lex token of closeKind.
|
|
1625
1837
|
* Advances the parser to the next lex token after the closing token.
|
|
1838
|
+
*
|
|
1839
|
+
* @internal
|
|
1626
1840
|
*/
|
|
1627
1841
|
|
|
1628
1842
|
any(openKind, parseFn, closeKind) {
|
|
@@ -1640,6 +1854,8 @@ class Parser {
|
|
|
1640
1854
|
* It can be empty only if open token is missing otherwise it will always return non-empty list
|
|
1641
1855
|
* that begins with a lex token of openKind and ends with a lex token of closeKind.
|
|
1642
1856
|
* Advances the parser to the next lex token after the closing token.
|
|
1857
|
+
*
|
|
1858
|
+
* @internal
|
|
1643
1859
|
*/
|
|
1644
1860
|
|
|
1645
1861
|
optionalMany(openKind, parseFn, closeKind) {
|
|
@@ -1659,6 +1875,8 @@ class Parser {
|
|
|
1659
1875
|
* Returns a non-empty list of parse nodes, determined by the parseFn.
|
|
1660
1876
|
* This list begins with a lex token of openKind and ends with a lex token of closeKind.
|
|
1661
1877
|
* Advances the parser to the next lex token after the closing token.
|
|
1878
|
+
*
|
|
1879
|
+
* @internal
|
|
1662
1880
|
*/
|
|
1663
1881
|
|
|
1664
1882
|
many(openKind, parseFn, closeKind) {
|
|
@@ -1675,6 +1893,8 @@ class Parser {
|
|
|
1675
1893
|
* Returns a non-empty list of parse nodes, determined by the parseFn.
|
|
1676
1894
|
* This list may begin with a lex token of delimiterKind followed by items separated by lex tokens of tokenKind.
|
|
1677
1895
|
* Advances the parser to the next lex token after last item in the list.
|
|
1896
|
+
*
|
|
1897
|
+
* @internal
|
|
1678
1898
|
*/
|
|
1679
1899
|
|
|
1680
1900
|
delimitedMany(delimiterKind, parseFn) {
|
|
@@ -1708,6 +1928,8 @@ class Parser {
|
|
|
1708
1928
|
}
|
|
1709
1929
|
/**
|
|
1710
1930
|
* A helper function to describe a token as a string for debugging.
|
|
1931
|
+
*
|
|
1932
|
+
* @internal
|
|
1711
1933
|
*/
|
|
1712
1934
|
|
|
1713
1935
|
exports.Parser = Parser;
|
|
@@ -1718,6 +1940,8 @@ function getTokenDesc(token) {
|
|
|
1718
1940
|
}
|
|
1719
1941
|
/**
|
|
1720
1942
|
* A helper function to describe a token kind as a string for debugging.
|
|
1943
|
+
*
|
|
1944
|
+
* @internal
|
|
1721
1945
|
*/
|
|
1722
1946
|
|
|
1723
1947
|
function getTokenKindDesc(kind) {
|