graphql 16.13.2 → 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 +12 -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 +422 -55
- package/language/ast.js +103 -39
- package/language/ast.mjs +103 -39
- package/language/blockString.d.ts +1 -3
- package/language/blockString.js +1 -3
- package/language/blockString.mjs +1 -3
- package/language/directiveLocation.d.ts +29 -8
- package/language/directiveLocation.js +10 -6
- package/language/directiveLocation.mjs +10 -6
- package/language/index.d.ts +7 -0
- package/language/index.mjs +6 -0
- package/language/kinds.d.ts +58 -18
- package/language/kinds.js +10 -6
- package/language/kinds.mjs +10 -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 +248 -11
- package/language/parser.js +257 -0
- package/language/parser.mjs +257 -3
- package/language/predicates.d.ts +169 -0
- package/language/predicates.js +173 -1
- package/language/predicates.mjs +185 -1
- 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 +32 -1
- package/language/printer.mjs +31 -1
- 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 +202 -19
- package/type/directives.js +206 -20
- package/type/directives.mjs +206 -20
- package/type/index.d.ts +6 -0
- package/type/index.mjs +6 -0
- package/type/introspection.d.ts +36 -0
- package/type/introspection.js +57 -1
- package/type/introspection.mjs +65 -1
- 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 +69 -6
- package/utilities/buildASTSchema.mjs +69 -6
- package/utilities/buildClientSchema.d.ts +15 -0
- package/utilities/buildClientSchema.js +17 -0
- package/utilities/buildClientSchema.mjs +16 -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 +121 -6
- package/utilities/extendSchema.mjs +120 -6
- package/utilities/findBreakingChanges.d.ts +95 -0
- package/utilities/findBreakingChanges.js +68 -0
- package/utilities/findBreakingChanges.mjs +70 -0
- package/utilities/getIntrospectionQuery.d.ts +148 -0
- package/utilities/getIntrospectionQuery.js +72 -38
- package/utilities/getIntrospectionQuery.mjs +72 -38
- 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 +56 -0
- package/utilities/introspectionFromSchema.mjs +55 -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 +67 -0
- package/utilities/printSchema.mjs +68 -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 +51 -2
- package/utilities/valueFromAST.mjs +50 -2
- 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 +33 -0
- package/validation/rules/KnownDirectivesRule.mjs +32 -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 +41 -0
- package/validation/rules/UniqueDirectivesPerLocationRule.mjs +40 -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 +7 -9
- package/version.mjs +6 -9
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
/** @category Introspection */
|
|
1
2
|
import type { Maybe } from '../jsutils/Maybe';
|
|
2
3
|
import type { DirectiveLocation } from '../language/directiveLocation';
|
|
4
|
+
/** Options controlling which fields are included in the introspection query. */
|
|
3
5
|
export interface IntrospectionOptions {
|
|
4
6
|
/**
|
|
5
7
|
* Whether to include descriptions in the introspection result.
|
|
@@ -26,34 +28,94 @@ export interface IntrospectionOptions {
|
|
|
26
28
|
* Default: false
|
|
27
29
|
*/
|
|
28
30
|
inputValueDeprecation?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Whether target GraphQL server supports deprecation of directives.
|
|
33
|
+
* Default: false
|
|
34
|
+
*/
|
|
35
|
+
experimentalDirectiveDeprecation?: boolean;
|
|
29
36
|
/**
|
|
30
37
|
* Whether target GraphQL server supports `@oneOf` input objects.
|
|
31
38
|
* Default: false
|
|
32
39
|
*/
|
|
33
40
|
oneOf?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* How deep to recurse into nested types, larger values will result in more
|
|
43
|
+
* accurate results, but have a higher load on the server.
|
|
44
|
+
* Some servers might restrict the maximum query depth or complexity.
|
|
45
|
+
* If that's the case, try decreasing this value.
|
|
46
|
+
*
|
|
47
|
+
* Default: 9
|
|
48
|
+
*/
|
|
49
|
+
typeDepth?: number;
|
|
34
50
|
}
|
|
35
51
|
/**
|
|
36
52
|
* Produce the GraphQL query recommended for a full schema introspection.
|
|
37
53
|
* Accepts optional IntrospectionOptions.
|
|
54
|
+
* @param options - Optional configuration for this operation.
|
|
55
|
+
* @returns The resolved introspection query.
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* // Generate the default introspection query.
|
|
59
|
+
* import { getIntrospectionQuery } from 'graphql/utilities';
|
|
60
|
+
*
|
|
61
|
+
* const query = getIntrospectionQuery();
|
|
62
|
+
*
|
|
63
|
+
* query; // matches /__schema/
|
|
64
|
+
* query; // matches /description/
|
|
65
|
+
* query; // does not match /specifiedByURL/
|
|
66
|
+
* ```
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* // This variant customizes optional introspection fields and nesting depth.
|
|
70
|
+
* import { getIntrospectionQuery } from 'graphql/utilities';
|
|
71
|
+
*
|
|
72
|
+
* const query = getIntrospectionQuery({
|
|
73
|
+
* descriptions: false,
|
|
74
|
+
* specifiedByUrl: true,
|
|
75
|
+
* directiveIsRepeatable: true,
|
|
76
|
+
* schemaDescription: true,
|
|
77
|
+
* inputValueDeprecation: true,
|
|
78
|
+
* experimentalDirectiveDeprecation: true,
|
|
79
|
+
* oneOf: true,
|
|
80
|
+
* typeDepth: 3,
|
|
81
|
+
* });
|
|
82
|
+
*
|
|
83
|
+
* query; // does not match /description/
|
|
84
|
+
* query; // matches /specifiedByURL/
|
|
85
|
+
* query; // matches /isRepeatable/
|
|
86
|
+
* query; // matches /includeDeprecated: true/
|
|
87
|
+
* query; // matches /isOneOf/
|
|
88
|
+
* (query.match(/ofType/g)?.length ?? 0) > 0; // => true
|
|
89
|
+
* ```
|
|
38
90
|
*/
|
|
39
91
|
export declare function getIntrospectionQuery(
|
|
40
92
|
options?: IntrospectionOptions,
|
|
41
93
|
): string;
|
|
94
|
+
/** The result shape returned by a full introspection query. */
|
|
42
95
|
export interface IntrospectionQuery {
|
|
96
|
+
/** The schema. */
|
|
43
97
|
readonly __schema: IntrospectionSchema;
|
|
44
98
|
}
|
|
99
|
+
/** The introspection representation of a GraphQL schema. */
|
|
45
100
|
export interface IntrospectionSchema {
|
|
101
|
+
/** Human-readable description for this schema element, if provided. */
|
|
46
102
|
readonly description?: Maybe<string>;
|
|
103
|
+
/** The root object type used for query operations. */
|
|
47
104
|
readonly queryType: IntrospectionNamedTypeRef<IntrospectionObjectType>;
|
|
105
|
+
/** The root object type used for mutation operations, if supported. */
|
|
48
106
|
readonly mutationType: Maybe<
|
|
49
107
|
IntrospectionNamedTypeRef<IntrospectionObjectType>
|
|
50
108
|
>;
|
|
109
|
+
/** The root object type used for subscription operations, if supported. */
|
|
51
110
|
readonly subscriptionType: Maybe<
|
|
52
111
|
IntrospectionNamedTypeRef<IntrospectionObjectType>
|
|
53
112
|
>;
|
|
113
|
+
/** Object types that belong to this union type. */
|
|
54
114
|
readonly types: ReadonlyArray<IntrospectionType>;
|
|
115
|
+
/** Directives available in this schema or applied to this AST node. */
|
|
55
116
|
readonly directives: ReadonlyArray<IntrospectionDirective>;
|
|
56
117
|
}
|
|
118
|
+
/** Any introspection representation of a GraphQL type. */
|
|
57
119
|
export declare type IntrospectionType =
|
|
58
120
|
| IntrospectionScalarType
|
|
59
121
|
| IntrospectionObjectType
|
|
@@ -61,82 +123,132 @@ export declare type IntrospectionType =
|
|
|
61
123
|
| IntrospectionUnionType
|
|
62
124
|
| IntrospectionEnumType
|
|
63
125
|
| IntrospectionInputObjectType;
|
|
126
|
+
/** An introspection type that can appear in output position. */
|
|
64
127
|
export declare type IntrospectionOutputType =
|
|
65
128
|
| IntrospectionScalarType
|
|
66
129
|
| IntrospectionObjectType
|
|
67
130
|
| IntrospectionInterfaceType
|
|
68
131
|
| IntrospectionUnionType
|
|
69
132
|
| IntrospectionEnumType;
|
|
133
|
+
/** An introspection type that can appear in input position. */
|
|
70
134
|
export declare type IntrospectionInputType =
|
|
71
135
|
| IntrospectionScalarType
|
|
72
136
|
| IntrospectionEnumType
|
|
73
137
|
| IntrospectionInputObjectType;
|
|
138
|
+
/** The introspection representation of a scalar type. */
|
|
74
139
|
export interface IntrospectionScalarType {
|
|
140
|
+
/** The introspection kind discriminator for this type reference or type. */
|
|
75
141
|
readonly kind: 'SCALAR';
|
|
142
|
+
/** The GraphQL name for this schema element. */
|
|
76
143
|
readonly name: string;
|
|
144
|
+
/** Human-readable description for this schema element, if provided. */
|
|
77
145
|
readonly description?: Maybe<string>;
|
|
146
|
+
/** URL identifying the behavior specified for this custom scalar. */
|
|
78
147
|
readonly specifiedByURL?: Maybe<string>;
|
|
79
148
|
}
|
|
149
|
+
/** The introspection representation of an object type. */
|
|
80
150
|
export interface IntrospectionObjectType {
|
|
151
|
+
/** The introspection kind discriminator for this type reference or type. */
|
|
81
152
|
readonly kind: 'OBJECT';
|
|
153
|
+
/** The GraphQL name for this schema element. */
|
|
82
154
|
readonly name: string;
|
|
155
|
+
/** Human-readable description for this schema element, if provided. */
|
|
83
156
|
readonly description?: Maybe<string>;
|
|
157
|
+
/** Fields declared by this object, interface, input object, or literal. */
|
|
84
158
|
readonly fields: ReadonlyArray<IntrospectionField>;
|
|
159
|
+
/** Interfaces implemented by this object or interface type. */
|
|
85
160
|
readonly interfaces: ReadonlyArray<
|
|
86
161
|
IntrospectionNamedTypeRef<IntrospectionInterfaceType>
|
|
87
162
|
>;
|
|
88
163
|
}
|
|
164
|
+
/** The introspection representation of an interface type. */
|
|
89
165
|
export interface IntrospectionInterfaceType {
|
|
166
|
+
/** The introspection kind discriminator for this type reference or type. */
|
|
90
167
|
readonly kind: 'INTERFACE';
|
|
168
|
+
/** The GraphQL name for this schema element. */
|
|
91
169
|
readonly name: string;
|
|
170
|
+
/** Human-readable description for this schema element, if provided. */
|
|
92
171
|
readonly description?: Maybe<string>;
|
|
172
|
+
/** Fields declared by this object, interface, input object, or literal. */
|
|
93
173
|
readonly fields: ReadonlyArray<IntrospectionField>;
|
|
174
|
+
/** Interfaces implemented by this object or interface type. */
|
|
94
175
|
readonly interfaces: ReadonlyArray<
|
|
95
176
|
IntrospectionNamedTypeRef<IntrospectionInterfaceType>
|
|
96
177
|
>;
|
|
178
|
+
/** Object types that may be returned for this abstract type. */
|
|
97
179
|
readonly possibleTypes: ReadonlyArray<
|
|
98
180
|
IntrospectionNamedTypeRef<IntrospectionObjectType>
|
|
99
181
|
>;
|
|
100
182
|
}
|
|
183
|
+
/** The introspection representation of a union type. */
|
|
101
184
|
export interface IntrospectionUnionType {
|
|
185
|
+
/** The introspection kind discriminator for this type reference or type. */
|
|
102
186
|
readonly kind: 'UNION';
|
|
187
|
+
/** The GraphQL name for this schema element. */
|
|
103
188
|
readonly name: string;
|
|
189
|
+
/** Human-readable description for this schema element, if provided. */
|
|
104
190
|
readonly description?: Maybe<string>;
|
|
191
|
+
/** Object types that may be returned for this abstract type. */
|
|
105
192
|
readonly possibleTypes: ReadonlyArray<
|
|
106
193
|
IntrospectionNamedTypeRef<IntrospectionObjectType>
|
|
107
194
|
>;
|
|
108
195
|
}
|
|
196
|
+
/** The introspection representation of an enum type. */
|
|
109
197
|
export interface IntrospectionEnumType {
|
|
198
|
+
/** The introspection kind discriminator for this type reference or type. */
|
|
110
199
|
readonly kind: 'ENUM';
|
|
200
|
+
/** The GraphQL name for this schema element. */
|
|
111
201
|
readonly name: string;
|
|
202
|
+
/** Human-readable description for this schema element, if provided. */
|
|
112
203
|
readonly description?: Maybe<string>;
|
|
204
|
+
/** Values declared by this enum type. */
|
|
113
205
|
readonly enumValues: ReadonlyArray<IntrospectionEnumValue>;
|
|
114
206
|
}
|
|
207
|
+
/** The introspection representation of an input object type. */
|
|
115
208
|
export interface IntrospectionInputObjectType {
|
|
209
|
+
/** The introspection kind discriminator for this type reference or type. */
|
|
116
210
|
readonly kind: 'INPUT_OBJECT';
|
|
211
|
+
/** The GraphQL name for this schema element. */
|
|
117
212
|
readonly name: string;
|
|
213
|
+
/** Human-readable description for this schema element, if provided. */
|
|
118
214
|
readonly description?: Maybe<string>;
|
|
215
|
+
/** Input fields declared by this input object type. */
|
|
119
216
|
readonly inputFields: ReadonlyArray<IntrospectionInputValue>;
|
|
217
|
+
/** Whether this input object uses the experimental OneOf input object semantics. */
|
|
120
218
|
readonly isOneOf: boolean;
|
|
121
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* The introspection representation of a list type reference.
|
|
222
|
+
* @typeParam T - The introspection type reference wrapped by this list type reference.
|
|
223
|
+
*/
|
|
122
224
|
export interface IntrospectionListTypeRef<
|
|
123
225
|
T extends IntrospectionTypeRef = IntrospectionTypeRef,
|
|
124
226
|
> {
|
|
227
|
+
/** The introspection kind discriminator for this type reference or type. */
|
|
125
228
|
readonly kind: 'LIST';
|
|
229
|
+
/** The type wrapped by this list or non-null type. */
|
|
126
230
|
readonly ofType: T;
|
|
127
231
|
}
|
|
232
|
+
/**
|
|
233
|
+
* The introspection representation of a non-null type reference.
|
|
234
|
+
* @typeParam T - The introspection type reference wrapped by this non-null type reference.
|
|
235
|
+
*/
|
|
128
236
|
export interface IntrospectionNonNullTypeRef<
|
|
129
237
|
T extends IntrospectionTypeRef = IntrospectionTypeRef,
|
|
130
238
|
> {
|
|
239
|
+
/** The introspection kind discriminator for this type reference or type. */
|
|
131
240
|
readonly kind: 'NON_NULL';
|
|
241
|
+
/** The type wrapped by this list or non-null type. */
|
|
132
242
|
readonly ofType: T;
|
|
133
243
|
}
|
|
244
|
+
/** Any introspection representation of a type reference. */
|
|
134
245
|
export declare type IntrospectionTypeRef =
|
|
135
246
|
| IntrospectionNamedTypeRef
|
|
136
247
|
| IntrospectionListTypeRef
|
|
137
248
|
| IntrospectionNonNullTypeRef<
|
|
138
249
|
IntrospectionNamedTypeRef | IntrospectionListTypeRef
|
|
139
250
|
>;
|
|
251
|
+
/** An introspection type reference that can appear in output position. */
|
|
140
252
|
export declare type IntrospectionOutputTypeRef =
|
|
141
253
|
| IntrospectionNamedTypeRef<IntrospectionOutputType>
|
|
142
254
|
| IntrospectionListTypeRef<IntrospectionOutputTypeRef>
|
|
@@ -144,6 +256,7 @@ export declare type IntrospectionOutputTypeRef =
|
|
|
144
256
|
| IntrospectionNamedTypeRef<IntrospectionOutputType>
|
|
145
257
|
| IntrospectionListTypeRef<IntrospectionOutputTypeRef>
|
|
146
258
|
>;
|
|
259
|
+
/** An introspection type reference that can appear in input position. */
|
|
147
260
|
export declare type IntrospectionInputTypeRef =
|
|
148
261
|
| IntrospectionNamedTypeRef<IntrospectionInputType>
|
|
149
262
|
| IntrospectionListTypeRef<IntrospectionInputTypeRef>
|
|
@@ -151,38 +264,73 @@ export declare type IntrospectionInputTypeRef =
|
|
|
151
264
|
| IntrospectionNamedTypeRef<IntrospectionInputType>
|
|
152
265
|
| IntrospectionListTypeRef<IntrospectionInputTypeRef>
|
|
153
266
|
>;
|
|
267
|
+
/**
|
|
268
|
+
* The introspection representation of a named type reference.
|
|
269
|
+
* @typeParam T - The introspection type represented by this named type reference.
|
|
270
|
+
*/
|
|
154
271
|
export interface IntrospectionNamedTypeRef<
|
|
155
272
|
T extends IntrospectionType = IntrospectionType,
|
|
156
273
|
> {
|
|
274
|
+
/** The introspection kind discriminator for this type reference or type. */
|
|
157
275
|
readonly kind: T['kind'];
|
|
276
|
+
/** The GraphQL name for this schema element. */
|
|
158
277
|
readonly name: string;
|
|
159
278
|
}
|
|
279
|
+
/** The introspection representation of a field. */
|
|
160
280
|
export interface IntrospectionField {
|
|
281
|
+
/** The GraphQL name for this schema element. */
|
|
161
282
|
readonly name: string;
|
|
283
|
+
/** Human-readable description for this schema element, if provided. */
|
|
162
284
|
readonly description?: Maybe<string>;
|
|
285
|
+
/** Arguments accepted by this field or directive. */
|
|
163
286
|
readonly args: ReadonlyArray<IntrospectionInputValue>;
|
|
287
|
+
/** The GraphQL type reference or runtime type for this element. */
|
|
164
288
|
readonly type: IntrospectionOutputTypeRef;
|
|
289
|
+
/** Whether this field, argument, enum value, or input value is deprecated. */
|
|
165
290
|
readonly isDeprecated: boolean;
|
|
291
|
+
/** Reason this element is deprecated, if one was provided. */
|
|
166
292
|
readonly deprecationReason: Maybe<string>;
|
|
167
293
|
}
|
|
294
|
+
/** The introspection representation of an argument or input field. */
|
|
168
295
|
export interface IntrospectionInputValue {
|
|
296
|
+
/** The GraphQL name for this schema element. */
|
|
169
297
|
readonly name: string;
|
|
298
|
+
/** Human-readable description for this schema element, if provided. */
|
|
170
299
|
readonly description?: Maybe<string>;
|
|
300
|
+
/** The GraphQL type reference or runtime type for this element. */
|
|
171
301
|
readonly type: IntrospectionInputTypeRef;
|
|
302
|
+
/** Default value used when no explicit value is supplied. */
|
|
172
303
|
readonly defaultValue: Maybe<string>;
|
|
304
|
+
/** Whether this field, argument, enum value, or input value is deprecated. */
|
|
173
305
|
readonly isDeprecated?: boolean;
|
|
306
|
+
/** Reason this element is deprecated, if one was provided. */
|
|
174
307
|
readonly deprecationReason?: Maybe<string>;
|
|
175
308
|
}
|
|
309
|
+
/** The introspection representation of an enum value. */
|
|
176
310
|
export interface IntrospectionEnumValue {
|
|
311
|
+
/** The GraphQL name for this schema element. */
|
|
177
312
|
readonly name: string;
|
|
313
|
+
/** Human-readable description for this schema element, if provided. */
|
|
178
314
|
readonly description?: Maybe<string>;
|
|
315
|
+
/** Whether this field, argument, enum value, or input value is deprecated. */
|
|
179
316
|
readonly isDeprecated: boolean;
|
|
317
|
+
/** Reason this element is deprecated, if one was provided. */
|
|
180
318
|
readonly deprecationReason: Maybe<string>;
|
|
181
319
|
}
|
|
320
|
+
/** The introspection representation of a directive. */
|
|
182
321
|
export interface IntrospectionDirective {
|
|
322
|
+
/** The GraphQL name for this schema element. */
|
|
183
323
|
readonly name: string;
|
|
324
|
+
/** Human-readable description for this schema element, if provided. */
|
|
184
325
|
readonly description?: Maybe<string>;
|
|
326
|
+
/** Whether this directive may appear more than once at the same location. */
|
|
185
327
|
readonly isRepeatable?: boolean;
|
|
328
|
+
/** Whether this field, argument, enum value, or input value is deprecated. */
|
|
329
|
+
readonly isDeprecated?: boolean;
|
|
330
|
+
/** Reason this element is deprecated, if one was provided. */
|
|
331
|
+
readonly deprecationReason?: Maybe<string>;
|
|
332
|
+
/** Locations where this directive may be applied. */
|
|
186
333
|
readonly locations: ReadonlyArray<DirectiveLocation>;
|
|
334
|
+
/** Arguments accepted by this field or directive. */
|
|
187
335
|
readonly args: ReadonlyArray<IntrospectionInputValue>;
|
|
188
336
|
}
|
|
@@ -5,9 +5,49 @@ Object.defineProperty(exports, '__esModule', {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getIntrospectionQuery = getIntrospectionQuery;
|
|
7
7
|
|
|
8
|
+
/** @category Introspection */
|
|
9
|
+
|
|
10
|
+
/** Options controlling which fields are included in the introspection query. */
|
|
11
|
+
|
|
8
12
|
/**
|
|
9
13
|
* Produce the GraphQL query recommended for a full schema introspection.
|
|
10
14
|
* Accepts optional IntrospectionOptions.
|
|
15
|
+
* @param options - Optional configuration for this operation.
|
|
16
|
+
* @returns The resolved introspection query.
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* // Generate the default introspection query.
|
|
20
|
+
* import { getIntrospectionQuery } from 'graphql/utilities';
|
|
21
|
+
*
|
|
22
|
+
* const query = getIntrospectionQuery();
|
|
23
|
+
*
|
|
24
|
+
* query; // matches /__schema/
|
|
25
|
+
* query; // matches /description/
|
|
26
|
+
* query; // does not match /specifiedByURL/
|
|
27
|
+
* ```
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* // This variant customizes optional introspection fields and nesting depth.
|
|
31
|
+
* import { getIntrospectionQuery } from 'graphql/utilities';
|
|
32
|
+
*
|
|
33
|
+
* const query = getIntrospectionQuery({
|
|
34
|
+
* descriptions: false,
|
|
35
|
+
* specifiedByUrl: true,
|
|
36
|
+
* directiveIsRepeatable: true,
|
|
37
|
+
* schemaDescription: true,
|
|
38
|
+
* inputValueDeprecation: true,
|
|
39
|
+
* experimentalDirectiveDeprecation: true,
|
|
40
|
+
* oneOf: true,
|
|
41
|
+
* typeDepth: 3,
|
|
42
|
+
* });
|
|
43
|
+
*
|
|
44
|
+
* query; // does not match /description/
|
|
45
|
+
* query; // matches /specifiedByURL/
|
|
46
|
+
* query; // matches /isRepeatable/
|
|
47
|
+
* query; // matches /includeDeprecated: true/
|
|
48
|
+
* query; // matches /isOneOf/
|
|
49
|
+
* (query.match(/ofType/g)?.length ?? 0) > 0; // => true
|
|
50
|
+
* ```
|
|
11
51
|
*/
|
|
12
52
|
function getIntrospectionQuery(options) {
|
|
13
53
|
const optionsWithDefault = {
|
|
@@ -16,7 +56,9 @@ function getIntrospectionQuery(options) {
|
|
|
16
56
|
directiveIsRepeatable: false,
|
|
17
57
|
schemaDescription: false,
|
|
18
58
|
inputValueDeprecation: false,
|
|
59
|
+
experimentalDirectiveDeprecation: false,
|
|
19
60
|
oneOf: false,
|
|
61
|
+
typeDepth: 9,
|
|
20
62
|
...options,
|
|
21
63
|
};
|
|
22
64
|
const descriptions = optionsWithDefault.descriptions ? 'description' : '';
|
|
@@ -34,7 +76,30 @@ function getIntrospectionQuery(options) {
|
|
|
34
76
|
return optionsWithDefault.inputValueDeprecation ? str : '';
|
|
35
77
|
}
|
|
36
78
|
|
|
79
|
+
function experimentalDirectiveDeprecation(str) {
|
|
80
|
+
return optionsWithDefault.experimentalDirectiveDeprecation ? str : '';
|
|
81
|
+
}
|
|
82
|
+
|
|
37
83
|
const oneOf = optionsWithDefault.oneOf ? 'isOneOf' : '';
|
|
84
|
+
|
|
85
|
+
function ofType(level, indent) {
|
|
86
|
+
if (level <= 0) {
|
|
87
|
+
return '';
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (level > 100) {
|
|
91
|
+
throw new Error(
|
|
92
|
+
'Please set typeDepth to a reasonable value between 0 and 100; the default is 9.',
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return `
|
|
97
|
+
${indent}ofType {
|
|
98
|
+
${indent} name
|
|
99
|
+
${indent} kind${ofType(level - 1, indent + ' ')}
|
|
100
|
+
${indent}}`;
|
|
101
|
+
}
|
|
102
|
+
|
|
38
103
|
return `
|
|
39
104
|
query IntrospectionQuery {
|
|
40
105
|
__schema {
|
|
@@ -45,10 +110,14 @@ function getIntrospectionQuery(options) {
|
|
|
45
110
|
types {
|
|
46
111
|
...FullType
|
|
47
112
|
}
|
|
48
|
-
directives
|
|
113
|
+
directives${experimentalDirectiveDeprecation(
|
|
114
|
+
'(includeDeprecated: true)',
|
|
115
|
+
)} {
|
|
49
116
|
name
|
|
50
117
|
${descriptions}
|
|
51
118
|
${directiveIsRepeatable}
|
|
119
|
+
${experimentalDirectiveDeprecation('isDeprecated')}
|
|
120
|
+
${experimentalDirectiveDeprecation('deprecationReason')}
|
|
52
121
|
locations
|
|
53
122
|
args${inputDeprecation('(includeDeprecated: true)')} {
|
|
54
123
|
...InputValue
|
|
@@ -103,43 +172,8 @@ function getIntrospectionQuery(options) {
|
|
|
103
172
|
|
|
104
173
|
fragment TypeRef on __Type {
|
|
105
174
|
kind
|
|
106
|
-
name
|
|
107
|
-
ofType {
|
|
108
|
-
kind
|
|
109
|
-
name
|
|
110
|
-
ofType {
|
|
111
|
-
kind
|
|
112
|
-
name
|
|
113
|
-
ofType {
|
|
114
|
-
kind
|
|
115
|
-
name
|
|
116
|
-
ofType {
|
|
117
|
-
kind
|
|
118
|
-
name
|
|
119
|
-
ofType {
|
|
120
|
-
kind
|
|
121
|
-
name
|
|
122
|
-
ofType {
|
|
123
|
-
kind
|
|
124
|
-
name
|
|
125
|
-
ofType {
|
|
126
|
-
kind
|
|
127
|
-
name
|
|
128
|
-
ofType {
|
|
129
|
-
kind
|
|
130
|
-
name
|
|
131
|
-
ofType {
|
|
132
|
-
kind
|
|
133
|
-
name
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
175
|
+
name${ofType(optionsWithDefault.typeDepth, ' ')}
|
|
143
176
|
}
|
|
144
177
|
`;
|
|
145
178
|
}
|
|
179
|
+
/** The result shape returned by a full introspection query. */
|
|
@@ -1,6 +1,46 @@
|
|
|
1
|
+
/** @category Introspection */
|
|
2
|
+
|
|
3
|
+
/** Options controlling which fields are included in the introspection query. */
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
6
|
* Produce the GraphQL query recommended for a full schema introspection.
|
|
3
7
|
* Accepts optional IntrospectionOptions.
|
|
8
|
+
* @param options - Optional configuration for this operation.
|
|
9
|
+
* @returns The resolved introspection query.
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* // Generate the default introspection query.
|
|
13
|
+
* import { getIntrospectionQuery } from 'graphql/utilities';
|
|
14
|
+
*
|
|
15
|
+
* const query = getIntrospectionQuery();
|
|
16
|
+
*
|
|
17
|
+
* query; // matches /__schema/
|
|
18
|
+
* query; // matches /description/
|
|
19
|
+
* query; // does not match /specifiedByURL/
|
|
20
|
+
* ```
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* // This variant customizes optional introspection fields and nesting depth.
|
|
24
|
+
* import { getIntrospectionQuery } from 'graphql/utilities';
|
|
25
|
+
*
|
|
26
|
+
* const query = getIntrospectionQuery({
|
|
27
|
+
* descriptions: false,
|
|
28
|
+
* specifiedByUrl: true,
|
|
29
|
+
* directiveIsRepeatable: true,
|
|
30
|
+
* schemaDescription: true,
|
|
31
|
+
* inputValueDeprecation: true,
|
|
32
|
+
* experimentalDirectiveDeprecation: true,
|
|
33
|
+
* oneOf: true,
|
|
34
|
+
* typeDepth: 3,
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* query; // does not match /description/
|
|
38
|
+
* query; // matches /specifiedByURL/
|
|
39
|
+
* query; // matches /isRepeatable/
|
|
40
|
+
* query; // matches /includeDeprecated: true/
|
|
41
|
+
* query; // matches /isOneOf/
|
|
42
|
+
* (query.match(/ofType/g)?.length ?? 0) > 0; // => true
|
|
43
|
+
* ```
|
|
4
44
|
*/
|
|
5
45
|
export function getIntrospectionQuery(options) {
|
|
6
46
|
const optionsWithDefault = {
|
|
@@ -9,7 +49,9 @@ export function getIntrospectionQuery(options) {
|
|
|
9
49
|
directiveIsRepeatable: false,
|
|
10
50
|
schemaDescription: false,
|
|
11
51
|
inputValueDeprecation: false,
|
|
52
|
+
experimentalDirectiveDeprecation: false,
|
|
12
53
|
oneOf: false,
|
|
54
|
+
typeDepth: 9,
|
|
13
55
|
...options,
|
|
14
56
|
};
|
|
15
57
|
const descriptions = optionsWithDefault.descriptions ? 'description' : '';
|
|
@@ -27,7 +69,30 @@ export function getIntrospectionQuery(options) {
|
|
|
27
69
|
return optionsWithDefault.inputValueDeprecation ? str : '';
|
|
28
70
|
}
|
|
29
71
|
|
|
72
|
+
function experimentalDirectiveDeprecation(str) {
|
|
73
|
+
return optionsWithDefault.experimentalDirectiveDeprecation ? str : '';
|
|
74
|
+
}
|
|
75
|
+
|
|
30
76
|
const oneOf = optionsWithDefault.oneOf ? 'isOneOf' : '';
|
|
77
|
+
|
|
78
|
+
function ofType(level, indent) {
|
|
79
|
+
if (level <= 0) {
|
|
80
|
+
return '';
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (level > 100) {
|
|
84
|
+
throw new Error(
|
|
85
|
+
'Please set typeDepth to a reasonable value between 0 and 100; the default is 9.',
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return `
|
|
90
|
+
${indent}ofType {
|
|
91
|
+
${indent} name
|
|
92
|
+
${indent} kind${ofType(level - 1, indent + ' ')}
|
|
93
|
+
${indent}}`;
|
|
94
|
+
}
|
|
95
|
+
|
|
31
96
|
return `
|
|
32
97
|
query IntrospectionQuery {
|
|
33
98
|
__schema {
|
|
@@ -38,10 +103,14 @@ export function getIntrospectionQuery(options) {
|
|
|
38
103
|
types {
|
|
39
104
|
...FullType
|
|
40
105
|
}
|
|
41
|
-
directives
|
|
106
|
+
directives${experimentalDirectiveDeprecation(
|
|
107
|
+
'(includeDeprecated: true)',
|
|
108
|
+
)} {
|
|
42
109
|
name
|
|
43
110
|
${descriptions}
|
|
44
111
|
${directiveIsRepeatable}
|
|
112
|
+
${experimentalDirectiveDeprecation('isDeprecated')}
|
|
113
|
+
${experimentalDirectiveDeprecation('deprecationReason')}
|
|
45
114
|
locations
|
|
46
115
|
args${inputDeprecation('(includeDeprecated: true)')} {
|
|
47
116
|
...InputValue
|
|
@@ -96,43 +165,8 @@ export function getIntrospectionQuery(options) {
|
|
|
96
165
|
|
|
97
166
|
fragment TypeRef on __Type {
|
|
98
167
|
kind
|
|
99
|
-
name
|
|
100
|
-
ofType {
|
|
101
|
-
kind
|
|
102
|
-
name
|
|
103
|
-
ofType {
|
|
104
|
-
kind
|
|
105
|
-
name
|
|
106
|
-
ofType {
|
|
107
|
-
kind
|
|
108
|
-
name
|
|
109
|
-
ofType {
|
|
110
|
-
kind
|
|
111
|
-
name
|
|
112
|
-
ofType {
|
|
113
|
-
kind
|
|
114
|
-
name
|
|
115
|
-
ofType {
|
|
116
|
-
kind
|
|
117
|
-
name
|
|
118
|
-
ofType {
|
|
119
|
-
kind
|
|
120
|
-
name
|
|
121
|
-
ofType {
|
|
122
|
-
kind
|
|
123
|
-
name
|
|
124
|
-
ofType {
|
|
125
|
-
kind
|
|
126
|
-
name
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
168
|
+
name${ofType(optionsWithDefault.typeDepth, ' ')}
|
|
136
169
|
}
|
|
137
170
|
`;
|
|
138
171
|
}
|
|
172
|
+
/** The result shape returned by a full introspection query. */
|
|
@@ -1,9 +1,24 @@
|
|
|
1
|
+
/** @category Operations */
|
|
1
2
|
import type { Maybe } from '../jsutils/Maybe';
|
|
2
3
|
import type { DocumentNode, OperationDefinitionNode } from '../language/ast';
|
|
3
4
|
/**
|
|
4
5
|
* Returns an operation AST given a document AST and optionally an operation
|
|
5
6
|
* name. If a name is not provided, an operation is only returned if only one is
|
|
6
7
|
* provided in the document.
|
|
8
|
+
* @param documentAST - The parsed GraphQL document AST.
|
|
9
|
+
* @param operationName - The optional operation name to select.
|
|
10
|
+
* @returns The resolved operation ast.
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { parse } from 'graphql/language';
|
|
14
|
+
* import { getOperationAST } from 'graphql/utilities';
|
|
15
|
+
*
|
|
16
|
+
* const document = parse('query GetName { name }');
|
|
17
|
+
* const operation = getOperationAST(document, 'GetName');
|
|
18
|
+
*
|
|
19
|
+
* operation.name.value; // => 'GetName'
|
|
20
|
+
* getOperationAST(document, 'Missing'); // => undefined
|
|
21
|
+
* ```
|
|
7
22
|
*/
|
|
8
23
|
export declare function getOperationAST(
|
|
9
24
|
documentAST: DocumentNode,
|
|
@@ -7,10 +7,26 @@ exports.getOperationAST = getOperationAST;
|
|
|
7
7
|
|
|
8
8
|
var _kinds = require('../language/kinds.js');
|
|
9
9
|
|
|
10
|
+
/** @category Operations */
|
|
11
|
+
|
|
10
12
|
/**
|
|
11
13
|
* Returns an operation AST given a document AST and optionally an operation
|
|
12
14
|
* name. If a name is not provided, an operation is only returned if only one is
|
|
13
15
|
* provided in the document.
|
|
16
|
+
* @param documentAST - The parsed GraphQL document AST.
|
|
17
|
+
* @param operationName - The optional operation name to select.
|
|
18
|
+
* @returns The resolved operation ast.
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { parse } from 'graphql/language';
|
|
22
|
+
* import { getOperationAST } from 'graphql/utilities';
|
|
23
|
+
*
|
|
24
|
+
* const document = parse('query GetName { name }');
|
|
25
|
+
* const operation = getOperationAST(document, 'GetName');
|
|
26
|
+
*
|
|
27
|
+
* operation.name.value; // => 'GetName'
|
|
28
|
+
* getOperationAST(document, 'Missing'); // => undefined
|
|
29
|
+
* ```
|
|
14
30
|
*/
|
|
15
31
|
function getOperationAST(documentAST, operationName) {
|
|
16
32
|
let operation = null;
|
|
@@ -1,8 +1,23 @@
|
|
|
1
|
+
/** @category Operations */
|
|
1
2
|
import { Kind } from '../language/kinds.mjs';
|
|
2
3
|
/**
|
|
3
4
|
* Returns an operation AST given a document AST and optionally an operation
|
|
4
5
|
* name. If a name is not provided, an operation is only returned if only one is
|
|
5
6
|
* provided in the document.
|
|
7
|
+
* @param documentAST - The parsed GraphQL document AST.
|
|
8
|
+
* @param operationName - The optional operation name to select.
|
|
9
|
+
* @returns The resolved operation ast.
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { parse } from 'graphql/language';
|
|
13
|
+
* import { getOperationAST } from 'graphql/utilities';
|
|
14
|
+
*
|
|
15
|
+
* const document = parse('query GetName { name }');
|
|
16
|
+
* const operation = getOperationAST(document, 'GetName');
|
|
17
|
+
*
|
|
18
|
+
* operation.name.value; // => 'GetName'
|
|
19
|
+
* getOperationAST(document, 'Missing'); // => undefined
|
|
20
|
+
* ```
|
|
6
21
|
*/
|
|
7
22
|
|
|
8
23
|
export function getOperationAST(documentAST, operationName) {
|