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/type/schema.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** @category Schema */
|
|
1
2
|
import type { Maybe } from '../jsutils/Maybe';
|
|
2
3
|
import type { ObjMap } from '../jsutils/ObjMap';
|
|
3
4
|
import type { GraphQLError } from '../error/GraphQLError';
|
|
@@ -15,12 +16,46 @@ import type {
|
|
|
15
16
|
import type { GraphQLDirective } from './directives';
|
|
16
17
|
/**
|
|
17
18
|
* Test if the given value is a GraphQL schema.
|
|
19
|
+
* @param schema - Value to inspect.
|
|
20
|
+
* @returns True when the value is a GraphQLSchema.
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
24
|
+
* import { GraphQLString, isSchema } from 'graphql/type';
|
|
25
|
+
*
|
|
26
|
+
* const schema = buildSchema(`
|
|
27
|
+
* type Query {
|
|
28
|
+
* greeting: String
|
|
29
|
+
* }
|
|
30
|
+
* `);
|
|
31
|
+
*
|
|
32
|
+
* isSchema(schema); // => true
|
|
33
|
+
* isSchema(GraphQLString); // => false
|
|
34
|
+
* ```
|
|
18
35
|
*/
|
|
19
36
|
export declare function isSchema(schema: unknown): schema is GraphQLSchema;
|
|
37
|
+
/**
|
|
38
|
+
* Returns the value as a GraphQLSchema, or throws if it is not a schema.
|
|
39
|
+
* @param schema - GraphQL schema to use.
|
|
40
|
+
* @returns The value typed as a GraphQLSchema.
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
44
|
+
* import { assertSchema, GraphQLString } from 'graphql/type';
|
|
45
|
+
*
|
|
46
|
+
* const schema = buildSchema(`
|
|
47
|
+
* type Query {
|
|
48
|
+
* greeting: String
|
|
49
|
+
* }
|
|
50
|
+
* `);
|
|
51
|
+
*
|
|
52
|
+
* assertSchema(schema); // => schema
|
|
53
|
+
* assertSchema(GraphQLString); // throws an error
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
20
56
|
export declare function assertSchema(schema: unknown): GraphQLSchema;
|
|
21
57
|
/**
|
|
22
58
|
* Custom extensions
|
|
23
|
-
*
|
|
24
59
|
* @remarks
|
|
25
60
|
* Use a unique identifier name for your extension, for example the name of
|
|
26
61
|
* your library or project. Do not use a shortened identifier as this increases
|
|
@@ -36,73 +71,96 @@ export interface GraphQLSchemaExtensions {
|
|
|
36
71
|
* A Schema is created by supplying the root types of each type of operation,
|
|
37
72
|
* query and mutation (optional). A schema definition is then supplied to the
|
|
38
73
|
* validator and executor.
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* const MyAppQueryRootType = new GraphQLObjectType({
|
|
77
|
+
* name: 'Query',
|
|
78
|
+
* fields: {
|
|
79
|
+
* greeting: { type: GraphQLString },
|
|
80
|
+
* },
|
|
81
|
+
* });
|
|
39
82
|
*
|
|
40
|
-
*
|
|
83
|
+
* const MyAppMutationRootType = new GraphQLObjectType({
|
|
84
|
+
* name: 'Mutation',
|
|
85
|
+
* fields: {
|
|
86
|
+
* setGreeting: { type: GraphQLString },
|
|
87
|
+
* },
|
|
88
|
+
* });
|
|
41
89
|
*
|
|
42
|
-
* ```ts
|
|
43
90
|
* const MyAppSchema = new GraphQLSchema({
|
|
44
91
|
* query: MyAppQueryRootType,
|
|
45
92
|
* mutation: MyAppMutationRootType,
|
|
46
|
-
* })
|
|
93
|
+
* });
|
|
47
94
|
* ```
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* Example:
|
|
95
|
+
* @example
|
|
96
|
+
* When the schema is constructed, by default only the types that are reachable
|
|
97
|
+
* by traversing the root types are included, other types must be explicitly
|
|
98
|
+
* referenced.
|
|
54
99
|
*
|
|
55
100
|
* ```ts
|
|
56
101
|
* const characterInterface = new GraphQLInterfaceType({
|
|
57
102
|
* name: 'Character',
|
|
58
|
-
*
|
|
103
|
+
* fields: {
|
|
104
|
+
* name: { type: GraphQLString },
|
|
105
|
+
* },
|
|
59
106
|
* });
|
|
60
107
|
*
|
|
61
108
|
* const humanType = new GraphQLObjectType({
|
|
62
109
|
* name: 'Human',
|
|
63
110
|
* interfaces: [characterInterface],
|
|
64
|
-
*
|
|
111
|
+
* fields: {
|
|
112
|
+
* name: { type: GraphQLString },
|
|
113
|
+
* },
|
|
65
114
|
* });
|
|
66
115
|
*
|
|
67
116
|
* const droidType = new GraphQLObjectType({
|
|
68
117
|
* name: 'Droid',
|
|
69
118
|
* interfaces: [characterInterface],
|
|
70
|
-
*
|
|
119
|
+
* fields: {
|
|
120
|
+
* name: { type: GraphQLString },
|
|
121
|
+
* },
|
|
71
122
|
* });
|
|
72
123
|
*
|
|
73
124
|
* const schema = new GraphQLSchema({
|
|
74
125
|
* query: new GraphQLObjectType({
|
|
75
126
|
* name: 'Query',
|
|
76
127
|
* fields: {
|
|
77
|
-
* hero: { type: characterInterface
|
|
78
|
-
* }
|
|
128
|
+
* hero: { type: characterInterface },
|
|
129
|
+
* },
|
|
79
130
|
* }),
|
|
80
|
-
* ...
|
|
81
131
|
* // Since this schema references only the `Character` interface it's
|
|
82
132
|
* // necessary to explicitly list the types that implement it if
|
|
83
133
|
* // you want them to be included in the final schema.
|
|
84
134
|
* types: [humanType, droidType],
|
|
85
|
-
* })
|
|
135
|
+
* });
|
|
86
136
|
* ```
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
137
|
+
* @example
|
|
138
|
+
* If an array of `directives` are provided to GraphQLSchema, that will be the
|
|
139
|
+
* exact list of directives represented and allowed. If `directives` is not
|
|
90
140
|
* provided then a default set of the specified directives (e.g. `@include` and
|
|
91
|
-
* `@skip`) will be used. If you wish to provide *additional* directives to
|
|
92
|
-
* specified directives, you must explicitly declare them.
|
|
141
|
+
* `@skip`) will be used. If you wish to provide *additional* directives to
|
|
142
|
+
* these specified directives, you must explicitly declare them.
|
|
93
143
|
*
|
|
94
144
|
* ```ts
|
|
95
145
|
* const MyAppSchema = new GraphQLSchema({
|
|
96
|
-
*
|
|
97
|
-
* directives: specifiedDirectives.concat([
|
|
98
|
-
* })
|
|
146
|
+
* query: MyAppQueryRootType,
|
|
147
|
+
* directives: specifiedDirectives.concat([myCustomDirective]),
|
|
148
|
+
* });
|
|
99
149
|
* ```
|
|
100
150
|
*/
|
|
101
151
|
export declare class GraphQLSchema {
|
|
152
|
+
/** Human-readable description for this schema element, if provided. */
|
|
102
153
|
description: Maybe<string>;
|
|
154
|
+
/** Extension fields to include in the formatted result. */
|
|
103
155
|
extensions: Readonly<GraphQLSchemaExtensions>;
|
|
156
|
+
/** AST node from which this schema element was built, if available. */
|
|
104
157
|
astNode: Maybe<SchemaDefinitionNode>;
|
|
158
|
+
/** AST extension nodes applied to this schema element. */
|
|
105
159
|
extensionASTNodes: ReadonlyArray<SchemaExtensionNode>;
|
|
160
|
+
/**
|
|
161
|
+
* Cached schema validation errors, if validation has already run.
|
|
162
|
+
* @internal
|
|
163
|
+
*/
|
|
106
164
|
__validationErrors: Maybe<ReadonlyArray<GraphQLError>>;
|
|
107
165
|
private _queryType;
|
|
108
166
|
private _mutationType;
|
|
@@ -111,30 +169,426 @@ export declare class GraphQLSchema {
|
|
|
111
169
|
private _typeMap;
|
|
112
170
|
private _subTypeMap;
|
|
113
171
|
private _implementationsMap;
|
|
172
|
+
/**
|
|
173
|
+
* Creates a GraphQLSchema instance.
|
|
174
|
+
* @param config - Configuration describing this object.
|
|
175
|
+
* @example
|
|
176
|
+
* ```ts
|
|
177
|
+
* // Create a schema with the required query root.
|
|
178
|
+
* import {
|
|
179
|
+
* GraphQLObjectType,
|
|
180
|
+
* GraphQLSchema,
|
|
181
|
+
* GraphQLString,
|
|
182
|
+
* } from 'graphql/type';
|
|
183
|
+
*
|
|
184
|
+
* const Query = new GraphQLObjectType({
|
|
185
|
+
* name: 'Query',
|
|
186
|
+
* fields: {
|
|
187
|
+
* greeting: {
|
|
188
|
+
* type: GraphQLString,
|
|
189
|
+
* resolve: () => 'Hello',
|
|
190
|
+
* },
|
|
191
|
+
* },
|
|
192
|
+
* });
|
|
193
|
+
*
|
|
194
|
+
* const schema = new GraphQLSchema({
|
|
195
|
+
* description: 'The application schema.',
|
|
196
|
+
* query: Query,
|
|
197
|
+
* });
|
|
198
|
+
*
|
|
199
|
+
* schema.getQueryType(); // => Query
|
|
200
|
+
* schema.description; // => 'The application schema.'
|
|
201
|
+
* ```
|
|
202
|
+
* @example
|
|
203
|
+
* ```ts
|
|
204
|
+
* // This variant configures every schema option, including directives and extensions.
|
|
205
|
+
* import { DirectiveLocation, parse } from 'graphql/language';
|
|
206
|
+
* import {
|
|
207
|
+
* GraphQLBoolean,
|
|
208
|
+
* GraphQLDirective,
|
|
209
|
+
* GraphQLObjectType,
|
|
210
|
+
* GraphQLSchema,
|
|
211
|
+
* GraphQLString,
|
|
212
|
+
* } from 'graphql/type';
|
|
213
|
+
*
|
|
214
|
+
* const Query = new GraphQLObjectType({
|
|
215
|
+
* name: 'Query',
|
|
216
|
+
* fields: { greeting: { type: GraphQLString } },
|
|
217
|
+
* });
|
|
218
|
+
* const Mutation = new GraphQLObjectType({
|
|
219
|
+
* name: 'Mutation',
|
|
220
|
+
* fields: { setGreeting: { type: GraphQLString } },
|
|
221
|
+
* });
|
|
222
|
+
* const Subscription = new GraphQLObjectType({
|
|
223
|
+
* name: 'Subscription',
|
|
224
|
+
* fields: { greetingChanged: { type: GraphQLString } },
|
|
225
|
+
* });
|
|
226
|
+
* const AuditEvent = new GraphQLObjectType({
|
|
227
|
+
* name: 'AuditEvent',
|
|
228
|
+
* fields: { message: { type: GraphQLString } },
|
|
229
|
+
* });
|
|
230
|
+
* const authDirective = new GraphQLDirective({
|
|
231
|
+
* name: 'auth',
|
|
232
|
+
* locations: [DirectiveLocation.FIELD_DEFINITION],
|
|
233
|
+
* args: { required: { type: GraphQLBoolean } },
|
|
234
|
+
* });
|
|
235
|
+
* const schemaDocument = parse(`
|
|
236
|
+
* schema {
|
|
237
|
+
* query: Query
|
|
238
|
+
* mutation: Mutation
|
|
239
|
+
* subscription: Subscription
|
|
240
|
+
* }
|
|
241
|
+
*
|
|
242
|
+
* extend schema @auth
|
|
243
|
+
* `);
|
|
244
|
+
*
|
|
245
|
+
* const schema = new GraphQLSchema({
|
|
246
|
+
* description: 'Operations exposed by the application.',
|
|
247
|
+
* query: Query,
|
|
248
|
+
* mutation: Mutation,
|
|
249
|
+
* subscription: Subscription,
|
|
250
|
+
* types: [AuditEvent],
|
|
251
|
+
* directives: [authDirective],
|
|
252
|
+
* extensions: { owner: 'platform' },
|
|
253
|
+
* astNode: schemaDocument.definitions[0],
|
|
254
|
+
* extensionASTNodes: [ schemaDocument.definitions[1] ],
|
|
255
|
+
* assumeValid: true,
|
|
256
|
+
* });
|
|
257
|
+
*
|
|
258
|
+
* schema.getMutationType(); // => Mutation
|
|
259
|
+
* schema.getSubscriptionType(); // => Subscription
|
|
260
|
+
* schema.getType('AuditEvent'); // => AuditEvent
|
|
261
|
+
* schema.getDirective('auth'); // => authDirective
|
|
262
|
+
* schema.extensions; // => { owner: 'platform' }
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
114
265
|
constructor(config: Readonly<GraphQLSchemaConfig>);
|
|
266
|
+
/**
|
|
267
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
268
|
+
* @returns The built-in string tag for this object.
|
|
269
|
+
*/
|
|
115
270
|
get [Symbol.toStringTag](): string;
|
|
271
|
+
/**
|
|
272
|
+
* Returns the root object type for query operations.
|
|
273
|
+
* @returns The query root type, if this schema defines one.
|
|
274
|
+
* @example
|
|
275
|
+
* ```ts
|
|
276
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
277
|
+
*
|
|
278
|
+
* const schema = buildSchema(`
|
|
279
|
+
* type Query {
|
|
280
|
+
* greeting: String
|
|
281
|
+
* }
|
|
282
|
+
* `);
|
|
283
|
+
*
|
|
284
|
+
* schema.getQueryType()?.name; // => 'Query'
|
|
285
|
+
* ```
|
|
286
|
+
*/
|
|
116
287
|
getQueryType(): Maybe<GraphQLObjectType>;
|
|
288
|
+
/**
|
|
289
|
+
* Returns the root object type for mutation operations.
|
|
290
|
+
* @returns The mutation root type, if this schema defines one.
|
|
291
|
+
* @example
|
|
292
|
+
* ```ts
|
|
293
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
294
|
+
*
|
|
295
|
+
* const schema = buildSchema(`
|
|
296
|
+
* type Query {
|
|
297
|
+
* greeting: String
|
|
298
|
+
* }
|
|
299
|
+
*
|
|
300
|
+
* type Mutation {
|
|
301
|
+
* setGreeting(value: String!): String
|
|
302
|
+
* }
|
|
303
|
+
* `);
|
|
304
|
+
*
|
|
305
|
+
* schema.getMutationType()?.name; // => 'Mutation'
|
|
306
|
+
* ```
|
|
307
|
+
*/
|
|
117
308
|
getMutationType(): Maybe<GraphQLObjectType>;
|
|
309
|
+
/**
|
|
310
|
+
* Returns the root object type for subscription operations.
|
|
311
|
+
* @returns The subscription root type, if this schema defines one.
|
|
312
|
+
* @example
|
|
313
|
+
* ```ts
|
|
314
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
315
|
+
*
|
|
316
|
+
* const schema = buildSchema(`
|
|
317
|
+
* type Query {
|
|
318
|
+
* greeting: String
|
|
319
|
+
* }
|
|
320
|
+
*
|
|
321
|
+
* type Subscription {
|
|
322
|
+
* greetings: String
|
|
323
|
+
* }
|
|
324
|
+
* `);
|
|
325
|
+
*
|
|
326
|
+
* schema.getSubscriptionType()?.name; // => 'Subscription'
|
|
327
|
+
* ```
|
|
328
|
+
*/
|
|
118
329
|
getSubscriptionType(): Maybe<GraphQLObjectType>;
|
|
330
|
+
/**
|
|
331
|
+
* Returns the root object type for the requested operation kind.
|
|
332
|
+
* @param operation - Operation kind to resolve.
|
|
333
|
+
* @returns The root object type for the operation kind, if this schema defines one.
|
|
334
|
+
* @example
|
|
335
|
+
* ```ts
|
|
336
|
+
* import { OperationTypeNode } from 'graphql/language';
|
|
337
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
338
|
+
*
|
|
339
|
+
* const schema = buildSchema(`
|
|
340
|
+
* type Query {
|
|
341
|
+
* greeting: String
|
|
342
|
+
* }
|
|
343
|
+
*
|
|
344
|
+
* type Mutation {
|
|
345
|
+
* setGreeting(value: String!): String
|
|
346
|
+
* }
|
|
347
|
+
* `);
|
|
348
|
+
*
|
|
349
|
+
* schema.getRootType(OperationTypeNode.QUERY)?.name; // => 'Query'
|
|
350
|
+
* schema.getRootType(OperationTypeNode.MUTATION)?.name; // => 'Mutation'
|
|
351
|
+
* schema.getRootType(OperationTypeNode.SUBSCRIPTION); // => undefined
|
|
352
|
+
* ```
|
|
353
|
+
*/
|
|
119
354
|
getRootType(operation: OperationTypeNode): Maybe<GraphQLObjectType>;
|
|
355
|
+
/**
|
|
356
|
+
* Returns all named types known to this schema.
|
|
357
|
+
* @returns A map of schema types keyed by type name.
|
|
358
|
+
* @example
|
|
359
|
+
* ```ts
|
|
360
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
361
|
+
*
|
|
362
|
+
* const schema = buildSchema(`
|
|
363
|
+
* type User {
|
|
364
|
+
* name: String
|
|
365
|
+
* }
|
|
366
|
+
*
|
|
367
|
+
* type Query {
|
|
368
|
+
* viewer: User
|
|
369
|
+
* }
|
|
370
|
+
* `);
|
|
371
|
+
*
|
|
372
|
+
* const typeMap = schema.getTypeMap();
|
|
373
|
+
*
|
|
374
|
+
* typeMap.User.name; // => 'User'
|
|
375
|
+
* typeMap.Query.name; // => 'Query'
|
|
376
|
+
* typeMap.String.name; // => 'String'
|
|
377
|
+
* ```
|
|
378
|
+
*/
|
|
120
379
|
getTypeMap(): TypeMap;
|
|
380
|
+
/**
|
|
381
|
+
* Returns the named type with the provided name.
|
|
382
|
+
* @param name - The GraphQL name to look up.
|
|
383
|
+
* @returns The named schema type, if one exists.
|
|
384
|
+
* @example
|
|
385
|
+
* ```ts
|
|
386
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
387
|
+
*
|
|
388
|
+
* const schema = buildSchema(`
|
|
389
|
+
* type User {
|
|
390
|
+
* name: String
|
|
391
|
+
* }
|
|
392
|
+
*
|
|
393
|
+
* type Query {
|
|
394
|
+
* viewer: User
|
|
395
|
+
* }
|
|
396
|
+
* `);
|
|
397
|
+
*
|
|
398
|
+
* schema.getType('User')?.toString(); // => 'User'
|
|
399
|
+
* schema.getType('Missing'); // => undefined
|
|
400
|
+
* ```
|
|
401
|
+
*/
|
|
121
402
|
getType(name: string): GraphQLNamedType | undefined;
|
|
403
|
+
/**
|
|
404
|
+
* Returns object types that may be returned for an abstract type.
|
|
405
|
+
* @param abstractType - Interface or union type to inspect.
|
|
406
|
+
* @returns Object types that may satisfy the abstract type.
|
|
407
|
+
* @example
|
|
408
|
+
* ```ts
|
|
409
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
410
|
+
* import { assertInterfaceType, assertUnionType } from 'graphql/type';
|
|
411
|
+
*
|
|
412
|
+
* const schema = buildSchema(`
|
|
413
|
+
* interface Node {
|
|
414
|
+
* id: ID!
|
|
415
|
+
* }
|
|
416
|
+
*
|
|
417
|
+
* type User implements Node {
|
|
418
|
+
* id: ID!
|
|
419
|
+
* }
|
|
420
|
+
*
|
|
421
|
+
* type Organization implements Node {
|
|
422
|
+
* id: ID!
|
|
423
|
+
* }
|
|
424
|
+
*
|
|
425
|
+
* union SearchResult = User | Organization
|
|
426
|
+
*
|
|
427
|
+
* type Query {
|
|
428
|
+
* node: Node
|
|
429
|
+
* search: [SearchResult]
|
|
430
|
+
* }
|
|
431
|
+
* `);
|
|
432
|
+
*
|
|
433
|
+
* const Node = assertInterfaceType(schema.getType('Node'));
|
|
434
|
+
* const SearchResult = assertUnionType(schema.getType('SearchResult'));
|
|
435
|
+
*
|
|
436
|
+
* schema.getPossibleTypes(Node).map((type) => type.name); // => ['User', 'Organization']
|
|
437
|
+
* schema.getPossibleTypes(SearchResult).map((type) => type.name); // => ['User', 'Organization']
|
|
438
|
+
* ```
|
|
439
|
+
*/
|
|
122
440
|
getPossibleTypes(
|
|
123
441
|
abstractType: GraphQLAbstractType,
|
|
124
442
|
): ReadonlyArray<GraphQLObjectType>;
|
|
443
|
+
/**
|
|
444
|
+
* Returns objects and interfaces that implement an interface type.
|
|
445
|
+
* @param interfaceType - Interface type to inspect.
|
|
446
|
+
* @returns Object and interface implementations of the interface.
|
|
447
|
+
* @example
|
|
448
|
+
* ```ts
|
|
449
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
450
|
+
* import { assertInterfaceType } from 'graphql/type';
|
|
451
|
+
*
|
|
452
|
+
* const schema = buildSchema(`
|
|
453
|
+
* interface Resource {
|
|
454
|
+
* url: String!
|
|
455
|
+
* }
|
|
456
|
+
*
|
|
457
|
+
* interface Image implements Resource {
|
|
458
|
+
* url: String!
|
|
459
|
+
* width: Int
|
|
460
|
+
* }
|
|
461
|
+
*
|
|
462
|
+
* type Photo implements Resource & Image {
|
|
463
|
+
* url: String!
|
|
464
|
+
* width: Int
|
|
465
|
+
* }
|
|
466
|
+
*
|
|
467
|
+
* type Query {
|
|
468
|
+
* resource: Resource
|
|
469
|
+
* }
|
|
470
|
+
* `);
|
|
471
|
+
*
|
|
472
|
+
* const Resource = assertInterfaceType(schema.getType('Resource'));
|
|
473
|
+
* const implementations = schema.getImplementations(Resource);
|
|
474
|
+
*
|
|
475
|
+
* implementations.interfaces.map((type) => type.name); // => ['Image']
|
|
476
|
+
* implementations.objects.map((type) => type.name); // => ['Photo']
|
|
477
|
+
* ```
|
|
478
|
+
*/
|
|
125
479
|
getImplementations(interfaceType: GraphQLInterfaceType): {
|
|
126
480
|
objects: ReadonlyArray<GraphQLObjectType>;
|
|
127
481
|
interfaces: ReadonlyArray<GraphQLInterfaceType>;
|
|
128
482
|
};
|
|
483
|
+
/**
|
|
484
|
+
* Returns whether one type is a possible runtime subtype of an abstract type.
|
|
485
|
+
* @param abstractType - Interface or union type to inspect.
|
|
486
|
+
* @param maybeSubType - Object or interface type to test as a possible subtype.
|
|
487
|
+
* @returns True when the subtype may satisfy the abstract type.
|
|
488
|
+
* @example
|
|
489
|
+
* ```ts
|
|
490
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
491
|
+
* import { assertInterfaceType, assertObjectType } from 'graphql/type';
|
|
492
|
+
*
|
|
493
|
+
* const schema = buildSchema(`
|
|
494
|
+
* interface Node {
|
|
495
|
+
* id: ID!
|
|
496
|
+
* }
|
|
497
|
+
*
|
|
498
|
+
* type User implements Node {
|
|
499
|
+
* id: ID!
|
|
500
|
+
* }
|
|
501
|
+
*
|
|
502
|
+
* type Review {
|
|
503
|
+
* body: String
|
|
504
|
+
* }
|
|
505
|
+
*
|
|
506
|
+
* type Query {
|
|
507
|
+
* node: Node
|
|
508
|
+
* review: Review
|
|
509
|
+
* }
|
|
510
|
+
* `);
|
|
511
|
+
*
|
|
512
|
+
* const Node = assertInterfaceType(schema.getType('Node'));
|
|
513
|
+
* const User = assertObjectType(schema.getType('User'));
|
|
514
|
+
* const Review = assertObjectType(schema.getType('Review'));
|
|
515
|
+
*
|
|
516
|
+
* schema.isSubType(Node, User); // => true
|
|
517
|
+
* schema.isSubType(Node, Review); // => false
|
|
518
|
+
* ```
|
|
519
|
+
*/
|
|
129
520
|
isSubType(
|
|
130
521
|
abstractType: GraphQLAbstractType,
|
|
131
522
|
maybeSubType: GraphQLObjectType | GraphQLInterfaceType,
|
|
132
523
|
): boolean;
|
|
524
|
+
/**
|
|
525
|
+
* Returns directives available in this schema.
|
|
526
|
+
* @returns Directives available in this schema.
|
|
527
|
+
* @example
|
|
528
|
+
* ```ts
|
|
529
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
530
|
+
*
|
|
531
|
+
* const schema = buildSchema(`
|
|
532
|
+
* directive @upper on FIELD_DEFINITION
|
|
533
|
+
*
|
|
534
|
+
* type Query {
|
|
535
|
+
* greeting: String @upper
|
|
536
|
+
* }
|
|
537
|
+
* `);
|
|
538
|
+
*
|
|
539
|
+
* schema.getDirectives().map((directive) => directive.name); // => ['include', 'skip', 'deprecated', 'specifiedBy', 'oneOf', 'upper']
|
|
540
|
+
* ```
|
|
541
|
+
*/
|
|
133
542
|
getDirectives(): ReadonlyArray<GraphQLDirective>;
|
|
543
|
+
/**
|
|
544
|
+
* Returns the current directive definition.
|
|
545
|
+
* @param name - The GraphQL name to look up.
|
|
546
|
+
* @returns The current directive definition, if known.
|
|
547
|
+
* @example
|
|
548
|
+
* ```ts
|
|
549
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
550
|
+
*
|
|
551
|
+
* const schema = buildSchema(`
|
|
552
|
+
* directive @upper on FIELD_DEFINITION
|
|
553
|
+
*
|
|
554
|
+
* type Query {
|
|
555
|
+
* greeting: String @upper
|
|
556
|
+
* }
|
|
557
|
+
* `);
|
|
558
|
+
*
|
|
559
|
+
* schema.getDirective('upper')?.name; // => 'upper'
|
|
560
|
+
* schema.getDirective('missing'); // => undefined
|
|
561
|
+
* ```
|
|
562
|
+
*/
|
|
134
563
|
getDirective(name: string): Maybe<GraphQLDirective>;
|
|
564
|
+
/**
|
|
565
|
+
* Returns a normalized configuration object for this object.
|
|
566
|
+
*
|
|
567
|
+
* The returned config preserves the original `assumeValid` flag so the schema
|
|
568
|
+
* can be recreated with the same validation behavior.
|
|
569
|
+
* @returns A configuration object that can be used to recreate this object.
|
|
570
|
+
* @example
|
|
571
|
+
* ```ts
|
|
572
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
573
|
+
* import { GraphQLSchema } from 'graphql/type';
|
|
574
|
+
*
|
|
575
|
+
* const schema = buildSchema(`
|
|
576
|
+
* type Query {
|
|
577
|
+
* greeting: String
|
|
578
|
+
* }
|
|
579
|
+
* `);
|
|
580
|
+
*
|
|
581
|
+
* const config = schema.toConfig();
|
|
582
|
+
* const schemaCopy = new GraphQLSchema(config);
|
|
583
|
+
*
|
|
584
|
+
* config.query?.name; // => 'Query'
|
|
585
|
+
* schemaCopy.getQueryType()?.name; // => 'Query'
|
|
586
|
+
* ```
|
|
587
|
+
*/
|
|
135
588
|
toConfig(): GraphQLSchemaNormalizedConfig;
|
|
136
589
|
}
|
|
137
590
|
declare type TypeMap = ObjMap<GraphQLNamedType>;
|
|
591
|
+
/** @internal */
|
|
138
592
|
export interface GraphQLSchemaValidationOptions {
|
|
139
593
|
/**
|
|
140
594
|
* When building a schema from a GraphQL service's introspection result, it
|
|
@@ -145,20 +599,28 @@ export interface GraphQLSchemaValidationOptions {
|
|
|
145
599
|
*/
|
|
146
600
|
assumeValid?: boolean;
|
|
147
601
|
}
|
|
602
|
+
/** Configuration used to construct a GraphQLSchema. */
|
|
148
603
|
export interface GraphQLSchemaConfig extends GraphQLSchemaValidationOptions {
|
|
604
|
+
/** Human-readable description for this schema element, if provided. */
|
|
149
605
|
description?: Maybe<string>;
|
|
606
|
+
/** Root object type for query operations. */
|
|
150
607
|
query?: Maybe<GraphQLObjectType>;
|
|
608
|
+
/** Root object type for mutation operations. */
|
|
151
609
|
mutation?: Maybe<GraphQLObjectType>;
|
|
610
|
+
/** Root object type for subscription operations. */
|
|
152
611
|
subscription?: Maybe<GraphQLObjectType>;
|
|
612
|
+
/** Object types that belong to this union type. */
|
|
153
613
|
types?: Maybe<ReadonlyArray<GraphQLNamedType>>;
|
|
614
|
+
/** Directives available in this schema or applied to this AST node. */
|
|
154
615
|
directives?: Maybe<ReadonlyArray<GraphQLDirective>>;
|
|
616
|
+
/** Extension fields to include in the formatted result. */
|
|
155
617
|
extensions?: Maybe<Readonly<GraphQLSchemaExtensions>>;
|
|
618
|
+
/** AST node from which this schema element was built, if available. */
|
|
156
619
|
astNode?: Maybe<SchemaDefinitionNode>;
|
|
620
|
+
/** AST extension nodes applied to this schema element. */
|
|
157
621
|
extensionASTNodes?: Maybe<ReadonlyArray<SchemaExtensionNode>>;
|
|
158
622
|
}
|
|
159
|
-
/**
|
|
160
|
-
* @internal
|
|
161
|
-
*/
|
|
623
|
+
/** @internal */
|
|
162
624
|
export interface GraphQLSchemaNormalizedConfig extends GraphQLSchemaConfig {
|
|
163
625
|
description: Maybe<string>;
|
|
164
626
|
types: ReadonlyArray<GraphQLNamedType>;
|