graphql 17.0.0-beta.0 → 17.0.0-beta.2
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/__dev__/devMode.d.ts +1 -1
- package/__dev__/error/GraphQLError.d.ts +1 -1
- package/__dev__/error/ensureGraphQLError.d.ts +1 -1
- package/__dev__/error/index.d.ts +1 -1
- package/__dev__/error/locatedError.d.ts +1 -1
- package/__dev__/error/syntaxError.d.ts +1 -1
- package/__dev__/execution/AbortedGraphQLExecutionError.d.ts +1 -1
- package/__dev__/execution/AsyncWorkTracker.d.ts +1 -1
- package/__dev__/execution/ExecutionArgs.d.mts +1 -0
- package/__dev__/execution/ExecutionArgs.d.ts +1 -0
- package/__dev__/execution/ExecutionArgs.js +3 -0
- package/__dev__/execution/ExecutionArgs.mjs +3 -0
- package/__dev__/execution/Executor.d.ts +1 -1
- package/__dev__/execution/ExecutorThrowingOnIncremental.d.ts +1 -1
- package/__dev__/execution/buildResolveInfo.d.mts +1 -0
- package/__dev__/execution/buildResolveInfo.d.ts +1 -0
- package/__dev__/execution/buildResolveInfo.js +3 -0
- package/__dev__/execution/buildResolveInfo.mjs +3 -0
- package/__dev__/execution/cancellablePromise.d.ts +1 -1
- package/__dev__/execution/collectFields.d.ts +1 -1
- package/__dev__/execution/collectIteratorPromises.d.ts +1 -1
- package/__dev__/execution/createSharedExecutionContext.d.ts +1 -1
- package/__dev__/execution/execute.d.ts +1 -1
- package/__dev__/execution/getStreamUsage.d.ts +1 -1
- package/__dev__/execution/getVariableSignature.d.ts +1 -1
- package/__dev__/execution/hooks.d.ts +1 -1
- package/__dev__/execution/incremental/Computation.d.ts +1 -1
- package/__dev__/execution/incremental/IncrementalExecutor.d.ts +1 -1
- package/__dev__/execution/incremental/IncrementalPublisher.d.ts +1 -1
- package/__dev__/execution/incremental/Queue.d.ts +1 -1
- package/__dev__/execution/incremental/WorkQueue.d.ts +1 -1
- package/__dev__/execution/incremental/buildExecutionPlan.d.ts +1 -1
- package/__dev__/execution/index.d.ts +1 -1
- package/__dev__/execution/legacyIncremental/BranchingIncrementalExecutor.d.mts +1 -0
- package/__dev__/execution/legacyIncremental/BranchingIncrementalExecutor.d.ts +1 -0
- package/__dev__/execution/legacyIncremental/BranchingIncrementalExecutor.js +3 -0
- package/__dev__/execution/legacyIncremental/BranchingIncrementalExecutor.mjs +3 -0
- package/__dev__/execution/legacyIncremental/BranchingIncrementalPublisher.d.mts +1 -0
- package/__dev__/execution/legacyIncremental/BranchingIncrementalPublisher.d.ts +1 -0
- package/__dev__/execution/legacyIncremental/BranchingIncrementalPublisher.js +3 -0
- package/__dev__/execution/legacyIncremental/BranchingIncrementalPublisher.mjs +3 -0
- package/__dev__/execution/legacyIncremental/legacyExecuteIncrementally.d.mts +1 -0
- package/__dev__/execution/legacyIncremental/legacyExecuteIncrementally.d.ts +1 -0
- package/__dev__/execution/legacyIncremental/legacyExecuteIncrementally.js +3 -0
- package/__dev__/execution/legacyIncremental/legacyExecuteIncrementally.mjs +3 -0
- package/__dev__/execution/mapAsyncIterable.d.ts +1 -1
- package/__dev__/execution/returnIteratorCatchingErrors.d.ts +1 -1
- package/__dev__/execution/values.d.ts +1 -1
- package/__dev__/execution/withConcurrentAbruptClose.d.ts +1 -1
- package/__dev__/graphql.d.ts +1 -1
- package/__dev__/harness.d.ts +1 -1
- package/__dev__/index.d.ts +1 -1
- package/__dev__/jsutils/AccumulatorMap.d.ts +1 -1
- package/__dev__/jsutils/Maybe.d.ts +1 -1
- package/__dev__/jsutils/ObjMap.d.ts +1 -1
- package/__dev__/jsutils/Path.d.ts +1 -1
- package/__dev__/jsutils/PromiseOrValue.d.ts +1 -1
- package/__dev__/jsutils/capitalize.d.ts +1 -1
- package/__dev__/jsutils/devAssert.d.ts +1 -1
- package/__dev__/jsutils/didYouMean.d.ts +1 -1
- package/__dev__/jsutils/formatList.d.ts +1 -1
- package/__dev__/jsutils/getBySet.d.ts +1 -1
- package/__dev__/jsutils/groupBy.d.ts +1 -1
- package/__dev__/jsutils/identityFunc.d.ts +1 -1
- package/__dev__/jsutils/inspect.d.ts +1 -1
- package/__dev__/jsutils/instanceOf.d.ts +1 -1
- package/__dev__/jsutils/invariant.d.ts +1 -1
- package/__dev__/jsutils/isAsyncIterable.d.ts +1 -1
- package/__dev__/jsutils/isIterableObject.d.ts +1 -1
- package/__dev__/jsutils/isObjectLike.d.ts +1 -1
- package/__dev__/jsutils/isPromise.d.ts +1 -1
- package/__dev__/jsutils/isSameSet.d.ts +1 -1
- package/__dev__/jsutils/keyMap.d.ts +1 -1
- package/__dev__/jsutils/keyValMap.d.ts +1 -1
- package/__dev__/jsutils/mapValue.d.ts +1 -1
- package/__dev__/jsutils/memoize1.d.ts +1 -1
- package/__dev__/jsutils/memoize2.d.ts +1 -1
- package/__dev__/jsutils/memoize3.d.ts +1 -1
- package/__dev__/jsutils/naturalCompare.d.ts +1 -1
- package/__dev__/jsutils/printPathArray.d.ts +1 -1
- package/__dev__/jsutils/promiseForObject.d.ts +1 -1
- package/__dev__/jsutils/promiseReduce.d.ts +1 -1
- package/__dev__/jsutils/promiseWithResolvers.d.ts +1 -1
- package/__dev__/jsutils/suggestionList.d.ts +1 -1
- package/__dev__/jsutils/toError.d.ts +1 -1
- package/__dev__/jsutils/toObjMap.d.ts +1 -1
- package/__dev__/language/KindTypeMap.d.ts +1 -1
- package/__dev__/language/ast.d.ts +1 -1
- package/__dev__/language/blockString.d.ts +1 -1
- package/__dev__/language/characterClasses.d.ts +1 -1
- package/__dev__/language/directiveLocation.d.ts +1 -1
- package/__dev__/language/index.d.ts +1 -1
- package/__dev__/language/kinds.d.ts +1 -1
- package/__dev__/language/kinds_.d.ts +1 -1
- package/__dev__/language/lexer.d.ts +1 -1
- package/__dev__/language/location.d.ts +1 -1
- package/__dev__/language/parser.d.ts +1 -1
- package/__dev__/language/predicates.d.ts +1 -1
- package/__dev__/language/printLocation.d.ts +1 -1
- package/__dev__/language/printString.d.ts +1 -1
- package/__dev__/language/printer.d.ts +1 -1
- package/__dev__/language/schemaCoordinateLexer.d.ts +1 -1
- package/__dev__/language/source.d.ts +1 -1
- package/__dev__/language/tokenKind.d.ts +1 -1
- package/__dev__/language/visitor.d.ts +1 -1
- package/__dev__/type/assertName.d.ts +1 -1
- package/__dev__/type/definition.d.ts +1 -1
- package/__dev__/type/directives.d.ts +1 -1
- package/__dev__/type/index.d.ts +1 -1
- package/__dev__/type/introspection.d.ts +1 -1
- package/__dev__/type/scalars.d.ts +1 -1
- package/__dev__/type/schema.d.ts +1 -1
- package/__dev__/type/validate.d.ts +1 -1
- package/__dev__/utilities/TypeInfo.d.ts +1 -1
- package/__dev__/utilities/astFromValue.d.ts +1 -1
- package/__dev__/utilities/buildASTSchema.d.ts +1 -1
- package/__dev__/utilities/buildClientSchema.d.ts +1 -1
- package/__dev__/utilities/coerceInputValue.d.ts +1 -1
- package/__dev__/utilities/concatAST.d.ts +1 -1
- package/__dev__/utilities/extendSchema.d.ts +1 -1
- package/__dev__/utilities/findSchemaChanges.d.ts +1 -1
- package/__dev__/utilities/getDefaultValueAST.d.ts +1 -1
- package/__dev__/utilities/getIntrospectionQuery.d.ts +1 -1
- package/__dev__/utilities/getOperationAST.d.ts +1 -1
- package/__dev__/utilities/index.d.ts +1 -1
- package/__dev__/utilities/introspectionFromSchema.d.ts +1 -1
- package/__dev__/utilities/lexicographicSortSchema.d.ts +1 -1
- package/__dev__/utilities/mapSchemaConfig.d.ts +1 -1
- package/__dev__/utilities/printSchema.d.ts +1 -1
- package/__dev__/utilities/replaceVariables.d.ts +1 -1
- package/__dev__/utilities/resolveSchemaCoordinate.d.ts +1 -1
- package/__dev__/utilities/separateOperations.d.ts +1 -1
- package/__dev__/utilities/sortValueNode.d.ts +1 -1
- package/__dev__/utilities/stripIgnoredCharacters.d.ts +1 -1
- package/__dev__/utilities/typeComparators.d.ts +1 -1
- package/__dev__/utilities/typeFromAST.d.ts +1 -1
- package/__dev__/utilities/typedQueryDocumentNode.d.ts +1 -1
- package/__dev__/utilities/validateInputValue.d.ts +1 -1
- package/__dev__/utilities/valueFromAST.d.ts +1 -1
- package/__dev__/utilities/valueFromASTUntyped.d.ts +1 -1
- package/__dev__/utilities/valueToLiteral.d.ts +1 -1
- package/__dev__/validation/ValidationContext.d.ts +1 -1
- package/__dev__/validation/index.d.ts +1 -1
- package/__dev__/validation/rules/DeferStreamDirectiveLabelRule.d.ts +1 -1
- package/__dev__/validation/rules/DeferStreamDirectiveOnRootFieldRule.d.ts +1 -1
- package/__dev__/validation/rules/DeferStreamDirectiveOnValidOperationsRule.d.ts +1 -1
- package/__dev__/validation/rules/ExecutableDefinitionsRule.d.ts +1 -1
- package/__dev__/validation/rules/FieldsOnCorrectTypeRule.d.ts +1 -1
- package/__dev__/validation/rules/FragmentsOnCompositeTypesRule.d.ts +1 -1
- package/__dev__/validation/rules/KnownArgumentNamesRule.d.ts +1 -1
- package/__dev__/validation/rules/KnownDirectivesRule.d.ts +1 -1
- package/__dev__/validation/rules/KnownFragmentNamesRule.d.ts +1 -1
- package/__dev__/validation/rules/KnownOperationTypesRule.d.ts +1 -1
- package/__dev__/validation/rules/KnownTypeNamesRule.d.ts +1 -1
- package/__dev__/validation/rules/LoneAnonymousOperationRule.d.ts +1 -1
- package/__dev__/validation/rules/LoneSchemaDefinitionRule.d.ts +1 -1
- package/__dev__/validation/rules/MaxIntrospectionDepthRule.d.ts +1 -1
- package/__dev__/validation/rules/NoFragmentCyclesRule.d.ts +1 -1
- package/__dev__/validation/rules/NoUndefinedVariablesRule.d.ts +1 -1
- package/__dev__/validation/rules/NoUnusedFragmentsRule.d.ts +1 -1
- package/__dev__/validation/rules/NoUnusedVariablesRule.d.ts +1 -1
- package/__dev__/validation/rules/OverlappingFieldsCanBeMergedRule.d.ts +1 -1
- package/__dev__/validation/rules/PossibleFragmentSpreadsRule.d.ts +1 -1
- package/__dev__/validation/rules/PossibleTypeExtensionsRule.d.ts +1 -1
- package/__dev__/validation/rules/ProvidedRequiredArgumentsRule.d.ts +1 -1
- package/__dev__/validation/rules/ScalarLeafsRule.d.ts +1 -1
- package/__dev__/validation/rules/SingleFieldSubscriptionsRule.d.ts +1 -1
- package/__dev__/validation/rules/StreamDirectiveOnListFieldRule.d.ts +1 -1
- package/__dev__/validation/rules/UniqueArgumentDefinitionNamesRule.d.ts +1 -1
- package/__dev__/validation/rules/UniqueArgumentNamesRule.d.ts +1 -1
- package/__dev__/validation/rules/UniqueDirectiveNamesRule.d.ts +1 -1
- package/__dev__/validation/rules/UniqueDirectivesPerLocationRule.d.ts +1 -1
- package/__dev__/validation/rules/UniqueEnumValueNamesRule.d.ts +1 -1
- package/__dev__/validation/rules/UniqueFieldDefinitionNamesRule.d.ts +1 -1
- package/__dev__/validation/rules/UniqueFragmentNamesRule.d.ts +1 -1
- package/__dev__/validation/rules/UniqueInputFieldNamesRule.d.ts +1 -1
- package/__dev__/validation/rules/UniqueOperationNamesRule.d.ts +1 -1
- package/__dev__/validation/rules/UniqueOperationTypesRule.d.ts +1 -1
- package/__dev__/validation/rules/UniqueTypeNamesRule.d.ts +1 -1
- package/__dev__/validation/rules/UniqueVariableNamesRule.d.ts +1 -1
- package/__dev__/validation/rules/ValuesOfCorrectTypeRule.d.ts +1 -1
- package/__dev__/validation/rules/VariablesAreInputTypesRule.d.ts +1 -1
- package/__dev__/validation/rules/VariablesInAllowedPositionRule.d.ts +1 -1
- package/__dev__/validation/rules/custom/NoDeprecatedCustomRule.d.ts +1 -1
- package/__dev__/validation/rules/custom/NoSchemaIntrospectionCustomRule.d.ts +1 -1
- package/__dev__/validation/specifiedRules.d.ts +1 -1
- package/__dev__/validation/validate.d.ts +1 -1
- package/__dev__/version.d.ts +1 -1
- package/devMode.d.mts +29 -0
- package/devMode.d.ts +29 -0
- package/devMode.js +2 -2
- package/devMode.js.map +1 -1
- package/devMode.mjs.map +1 -1
- package/error/GraphQLError.d.mts +98 -14
- package/error/GraphQLError.d.ts +98 -14
- package/error/GraphQLError.js +18 -28
- package/error/GraphQLError.js.map +1 -1
- package/error/GraphQLError.mjs +11 -21
- package/error/GraphQLError.mjs.map +1 -1
- package/error/ensureGraphQLError.d.mts +3 -1
- package/error/ensureGraphQLError.d.ts +3 -1
- package/error/ensureGraphQLError.js +5 -8
- package/error/ensureGraphQLError.js.map +1 -1
- package/error/ensureGraphQLError.mjs +0 -3
- package/error/ensureGraphQLError.mjs.map +1 -1
- package/error/index.d.mts +10 -4
- package/error/index.d.ts +10 -4
- package/error/index.js +6 -6
- package/error/index.js.map +1 -1
- package/error/index.mjs.map +1 -1
- package/error/locatedError.d.mts +23 -3
- package/error/locatedError.d.ts +23 -3
- package/error/locatedError.js +4 -10
- package/error/locatedError.js.map +1 -1
- package/error/locatedError.mjs +0 -6
- package/error/locatedError.mjs.map +1 -1
- package/error/syntaxError.d.mts +17 -2
- package/error/syntaxError.d.ts +17 -2
- package/error/syntaxError.js +2 -6
- package/error/syntaxError.js.map +1 -1
- package/error/syntaxError.mjs +0 -4
- package/error/syntaxError.mjs.map +1 -1
- package/execution/AbortedGraphQLExecutionError.d.mts +28 -1
- package/execution/AbortedGraphQLExecutionError.d.ts +28 -1
- package/execution/AbortedGraphQLExecutionError.js.map +1 -1
- package/execution/AbortedGraphQLExecutionError.mjs.map +1 -1
- package/execution/AsyncWorkTracker.d.mts +1 -1
- package/execution/AsyncWorkTracker.d.ts +1 -1
- package/execution/AsyncWorkTracker.js +3 -7
- package/execution/AsyncWorkTracker.js.map +1 -1
- package/execution/AsyncWorkTracker.mjs +1 -5
- package/execution/AsyncWorkTracker.mjs.map +1 -1
- package/execution/ExecutionArgs.d.mts +101 -0
- package/execution/ExecutionArgs.d.ts +101 -0
- package/execution/ExecutionArgs.js +3 -0
- package/execution/ExecutionArgs.js.map +1 -0
- package/execution/ExecutionArgs.mjs +2 -0
- package/execution/ExecutionArgs.mjs.map +1 -0
- package/execution/Executor.d.mts +55 -52
- package/execution/Executor.d.ts +55 -52
- package/execution/Executor.js +84 -206
- package/execution/Executor.js.map +1 -1
- package/execution/Executor.mjs +3 -125
- package/execution/Executor.mjs.map +1 -1
- package/execution/ExecutorThrowingOnIncremental.d.mts +6 -6
- package/execution/ExecutorThrowingOnIncremental.d.ts +6 -6
- package/execution/ExecutorThrowingOnIncremental.js +11 -13
- package/execution/ExecutorThrowingOnIncremental.js.map +1 -1
- package/execution/ExecutorThrowingOnIncremental.mjs +0 -2
- package/execution/ExecutorThrowingOnIncremental.mjs.map +1 -1
- package/execution/buildResolveInfo.d.mts +16 -0
- package/execution/buildResolveInfo.d.ts +16 -0
- package/execution/buildResolveInfo.js +21 -0
- package/execution/buildResolveInfo.js.map +1 -0
- package/execution/buildResolveInfo.mjs +18 -0
- package/execution/buildResolveInfo.mjs.map +1 -0
- package/execution/cancellablePromise.d.mts +3 -0
- package/execution/cancellablePromise.d.ts +3 -0
- package/execution/cancellablePromise.js +2 -2
- package/execution/cancellablePromise.js.map +1 -1
- package/execution/cancellablePromise.mjs.map +1 -1
- package/execution/collectFields.d.mts +15 -9
- package/execution/collectFields.d.ts +15 -9
- package/execution/collectFields.js +19 -60
- package/execution/collectFields.js.map +1 -1
- package/execution/collectFields.mjs +0 -41
- package/execution/collectFields.mjs.map +1 -1
- package/execution/collectIteratorPromises.d.mts +2 -0
- package/execution/collectIteratorPromises.d.ts +2 -0
- package/execution/collectIteratorPromises.js +2 -7
- package/execution/collectIteratorPromises.js.map +1 -1
- package/execution/collectIteratorPromises.mjs +0 -5
- package/execution/collectIteratorPromises.mjs.map +1 -1
- package/execution/createSharedExecutionContext.d.mts +3 -2
- package/execution/createSharedExecutionContext.d.ts +3 -2
- package/execution/createSharedExecutionContext.js +2 -2
- package/execution/createSharedExecutionContext.js.map +1 -1
- package/execution/createSharedExecutionContext.mjs.map +1 -1
- package/execution/execute.d.mts +412 -47
- package/execution/execute.d.ts +412 -47
- package/execution/execute.js +73 -254
- package/execution/execute.js.map +1 -1
- package/execution/execute.mjs +12 -193
- package/execution/execute.mjs.map +1 -1
- package/execution/getStreamUsage.d.mts +5 -2
- package/execution/getStreamUsage.d.ts +5 -2
- package/execution/getStreamUsage.js +9 -16
- package/execution/getStreamUsage.js.map +1 -1
- package/execution/getStreamUsage.mjs +0 -7
- package/execution/getStreamUsage.mjs.map +1 -1
- package/execution/getVariableSignature.d.mts +7 -4
- package/execution/getVariableSignature.d.ts +7 -4
- package/execution/getVariableSignature.js +8 -10
- package/execution/getVariableSignature.js.map +1 -1
- package/execution/getVariableSignature.mjs +0 -2
- package/execution/getVariableSignature.mjs.map +1 -1
- package/execution/hooks.d.mts +4 -8
- package/execution/hooks.d.ts +4 -8
- package/execution/hooks.js +0 -1
- package/execution/hooks.js.map +1 -1
- package/execution/hooks.mjs +0 -1
- package/execution/hooks.mjs.map +1 -1
- package/execution/incremental/Computation.d.mts +2 -2
- package/execution/incremental/Computation.d.ts +2 -2
- package/execution/incremental/Computation.js +2 -3
- package/execution/incremental/Computation.js.map +1 -1
- package/execution/incremental/Computation.mjs +0 -1
- package/execution/incremental/Computation.mjs.map +1 -1
- package/execution/incremental/IncrementalExecutor.d.mts +137 -22
- package/execution/incremental/IncrementalExecutor.d.ts +137 -22
- package/execution/incremental/IncrementalExecutor.js +47 -77
- package/execution/incremental/IncrementalExecutor.js.map +1 -1
- package/execution/incremental/IncrementalExecutor.mjs +2 -32
- package/execution/incremental/IncrementalExecutor.mjs.map +1 -1
- package/execution/incremental/IncrementalPublisher.d.mts +4 -6
- package/execution/incremental/IncrementalPublisher.d.ts +4 -6
- package/execution/incremental/IncrementalPublisher.js +12 -18
- package/execution/incremental/IncrementalPublisher.js.map +1 -1
- package/execution/incremental/IncrementalPublisher.mjs +0 -6
- package/execution/incremental/IncrementalPublisher.mjs.map +1 -1
- package/execution/incremental/Queue.d.mts +1 -1
- package/execution/incremental/Queue.d.ts +1 -1
- package/execution/incremental/Queue.js +22 -79
- package/execution/incremental/Queue.js.map +1 -1
- package/execution/incremental/Queue.mjs +8 -64
- package/execution/incremental/Queue.mjs.map +1 -1
- package/execution/incremental/WorkQueue.d.mts +10 -2
- package/execution/incremental/WorkQueue.d.ts +10 -2
- package/execution/incremental/WorkQueue.js +7 -22
- package/execution/incremental/WorkQueue.js.map +1 -1
- package/execution/incremental/WorkQueue.mjs +0 -15
- package/execution/incremental/WorkQueue.mjs.map +1 -1
- package/execution/incremental/buildExecutionPlan.d.mts +4 -1
- package/execution/incremental/buildExecutionPlan.d.ts +4 -1
- package/execution/incremental/buildExecutionPlan.js +4 -4
- package/execution/incremental/buildExecutionPlan.js.map +1 -1
- package/execution/incremental/buildExecutionPlan.mjs.map +1 -1
- package/execution/index.d.mts +17 -8
- package/execution/index.d.ts +17 -8
- package/execution/index.js +26 -22
- package/execution/index.js.map +1 -1
- package/execution/index.mjs +2 -1
- package/execution/index.mjs.map +1 -1
- package/execution/legacyIncremental/BranchingIncrementalExecutor.d.mts +175 -0
- package/execution/legacyIncremental/BranchingIncrementalExecutor.d.ts +175 -0
- package/execution/legacyIncremental/BranchingIncrementalExecutor.js +69 -0
- package/execution/legacyIncremental/BranchingIncrementalExecutor.js.map +1 -0
- package/execution/legacyIncremental/BranchingIncrementalExecutor.mjs +65 -0
- package/execution/legacyIncremental/BranchingIncrementalExecutor.mjs.map +1 -0
- package/execution/legacyIncremental/BranchingIncrementalPublisher.d.mts +12 -0
- package/execution/legacyIncremental/BranchingIncrementalPublisher.d.ts +12 -0
- package/execution/legacyIncremental/BranchingIncrementalPublisher.js +131 -0
- package/execution/legacyIncremental/BranchingIncrementalPublisher.js.map +1 -0
- package/execution/legacyIncremental/BranchingIncrementalPublisher.mjs +127 -0
- package/execution/legacyIncremental/BranchingIncrementalPublisher.mjs.map +1 -0
- package/execution/legacyIncremental/legacyExecuteIncrementally.d.mts +165 -0
- package/execution/legacyIncremental/legacyExecuteIncrementally.d.ts +165 -0
- package/execution/legacyIncremental/legacyExecuteIncrementally.js +17 -0
- package/execution/legacyIncremental/legacyExecuteIncrementally.js.map +1 -0
- package/execution/legacyIncremental/legacyExecuteIncrementally.mjs +13 -0
- package/execution/legacyIncremental/legacyExecuteIncrementally.mjs.map +1 -0
- package/execution/mapAsyncIterable.d.mts +3 -1
- package/execution/mapAsyncIterable.d.ts +3 -1
- package/execution/mapAsyncIterable.js +4 -9
- package/execution/mapAsyncIterable.js.map +1 -1
- package/execution/mapAsyncIterable.mjs +0 -5
- package/execution/mapAsyncIterable.mjs.map +1 -1
- package/execution/returnIteratorCatchingErrors.d.mts +1 -0
- package/execution/returnIteratorCatchingErrors.d.ts +1 -0
- package/execution/returnIteratorCatchingErrors.js +1 -2
- package/execution/returnIteratorCatchingErrors.js.map +1 -1
- package/execution/returnIteratorCatchingErrors.mjs +1 -2
- package/execution/returnIteratorCatchingErrors.mjs.map +1 -1
- package/execution/values.d.mts +196 -14
- package/execution/values.d.ts +196 -14
- package/execution/values.js +45 -86
- package/execution/values.js.map +1 -1
- package/execution/values.mjs +14 -55
- package/execution/values.mjs.map +1 -1
- package/execution/withConcurrentAbruptClose.d.mts +3 -1
- package/execution/withConcurrentAbruptClose.d.ts +3 -1
- package/execution/withConcurrentAbruptClose.js +3 -17
- package/execution/withConcurrentAbruptClose.js.map +1 -1
- package/execution/withConcurrentAbruptClose.mjs +1 -15
- package/execution/withConcurrentAbruptClose.mjs.map +1 -1
- package/graphql.d.mts +198 -50
- package/graphql.d.ts +198 -50
- package/graphql.js +11 -23
- package/graphql.js.map +1 -1
- package/graphql.mjs +0 -12
- package/graphql.mjs.map +1 -1
- package/harness.d.mts +21 -4
- package/harness.d.ts +21 -4
- package/harness.js +7 -7
- package/harness.js.map +1 -1
- package/harness.mjs.map +1 -1
- package/index.d.mts +41 -39
- package/index.d.ts +41 -39
- package/index.js +260 -346
- package/index.js.map +1 -1
- package/index.mjs +5 -149
- package/index.mjs.map +1 -1
- package/jsutils/AccumulatorMap.d.mts +2 -0
- package/jsutils/AccumulatorMap.d.ts +2 -0
- package/jsutils/AccumulatorMap.js +0 -4
- package/jsutils/AccumulatorMap.js.map +1 -1
- package/jsutils/AccumulatorMap.mjs +0 -4
- package/jsutils/AccumulatorMap.mjs.map +1 -1
- package/jsutils/Maybe.d.mts +5 -1
- package/jsutils/Maybe.d.ts +5 -1
- package/jsutils/Maybe.js.map +1 -1
- package/jsutils/Maybe.mjs.map +1 -1
- package/jsutils/ObjMap.d.mts +6 -0
- package/jsutils/ObjMap.d.ts +6 -0
- package/jsutils/ObjMap.js.map +1 -1
- package/jsutils/ObjMap.mjs.map +1 -1
- package/jsutils/Path.d.mts +31 -1
- package/jsutils/Path.d.ts +31 -1
- package/jsutils/Path.js +0 -6
- package/jsutils/Path.js.map +1 -1
- package/jsutils/Path.mjs +0 -6
- package/jsutils/Path.mjs.map +1 -1
- package/jsutils/PromiseOrValue.d.mts +1 -0
- package/jsutils/PromiseOrValue.d.ts +1 -0
- package/jsutils/PromiseOrValue.js.map +1 -1
- package/jsutils/PromiseOrValue.mjs.map +1 -1
- package/jsutils/capitalize.d.mts +2 -0
- package/jsutils/capitalize.d.ts +2 -0
- package/jsutils/capitalize.js +0 -3
- package/jsutils/capitalize.js.map +1 -1
- package/jsutils/capitalize.mjs +0 -3
- package/jsutils/capitalize.mjs.map +1 -1
- package/jsutils/devAssert.d.mts +1 -0
- package/jsutils/devAssert.d.ts +1 -0
- package/jsutils/devAssert.js.map +1 -1
- package/jsutils/devAssert.mjs.map +1 -1
- package/jsutils/didYouMean.d.mts +4 -1
- package/jsutils/didYouMean.d.ts +4 -1
- package/jsutils/didYouMean.js +2 -2
- package/jsutils/didYouMean.js.map +1 -1
- package/jsutils/didYouMean.mjs.map +1 -1
- package/jsutils/formatList.d.mts +6 -2
- package/jsutils/formatList.d.ts +6 -2
- package/jsutils/formatList.js +2 -8
- package/jsutils/formatList.js.map +1 -1
- package/jsutils/formatList.mjs +0 -6
- package/jsutils/formatList.mjs.map +1 -1
- package/jsutils/getBySet.d.mts +1 -0
- package/jsutils/getBySet.d.ts +1 -0
- package/jsutils/getBySet.js +2 -2
- package/jsutils/getBySet.js.map +1 -1
- package/jsutils/getBySet.mjs.map +1 -1
- package/jsutils/groupBy.d.mts +2 -0
- package/jsutils/groupBy.d.ts +2 -0
- package/jsutils/groupBy.js +2 -5
- package/jsutils/groupBy.js.map +1 -1
- package/jsutils/groupBy.mjs +0 -3
- package/jsutils/groupBy.mjs.map +1 -1
- package/jsutils/identityFunc.d.mts +2 -0
- package/jsutils/identityFunc.d.ts +2 -0
- package/jsutils/identityFunc.js +0 -3
- package/jsutils/identityFunc.js.map +1 -1
- package/jsutils/identityFunc.mjs +0 -3
- package/jsutils/identityFunc.mjs.map +1 -1
- package/jsutils/inspect.d.mts +2 -0
- package/jsutils/inspect.d.ts +2 -0
- package/jsutils/inspect.js +0 -4
- package/jsutils/inspect.js.map +1 -1
- package/jsutils/inspect.mjs +0 -4
- package/jsutils/inspect.mjs.map +1 -1
- package/jsutils/instanceOf.d.mts +2 -0
- package/jsutils/instanceOf.d.ts +2 -0
- package/jsutils/instanceOf.js +3 -14
- package/jsutils/instanceOf.js.map +1 -1
- package/jsutils/instanceOf.mjs +1 -12
- package/jsutils/instanceOf.mjs.map +1 -1
- package/jsutils/invariant.d.mts +1 -0
- package/jsutils/invariant.d.ts +1 -0
- package/jsutils/invariant.js.map +1 -1
- package/jsutils/invariant.mjs.map +1 -1
- package/jsutils/isAsyncIterable.d.mts +2 -0
- package/jsutils/isAsyncIterable.d.ts +2 -0
- package/jsutils/isAsyncIterable.js +0 -4
- package/jsutils/isAsyncIterable.js.map +1 -1
- package/jsutils/isAsyncIterable.mjs +0 -4
- package/jsutils/isAsyncIterable.mjs.map +1 -1
- package/jsutils/isIterableObject.d.mts +6 -5
- package/jsutils/isIterableObject.d.ts +6 -5
- package/jsutils/isIterableObject.js +0 -17
- package/jsutils/isIterableObject.js.map +1 -1
- package/jsutils/isIterableObject.mjs +0 -17
- package/jsutils/isIterableObject.mjs.map +1 -1
- package/jsutils/isObjectLike.d.mts +2 -0
- package/jsutils/isObjectLike.d.ts +2 -0
- package/jsutils/isObjectLike.js +0 -4
- package/jsutils/isObjectLike.js.map +1 -1
- package/jsutils/isObjectLike.mjs +0 -4
- package/jsutils/isObjectLike.mjs.map +1 -1
- package/jsutils/isPromise.d.mts +3 -0
- package/jsutils/isPromise.d.ts +3 -0
- package/jsutils/isPromise.js +0 -4
- package/jsutils/isPromise.js.map +1 -1
- package/jsutils/isPromise.mjs +0 -4
- package/jsutils/isPromise.mjs.map +1 -1
- package/jsutils/isSameSet.d.mts +1 -0
- package/jsutils/isSameSet.d.ts +1 -0
- package/jsutils/isSameSet.js.map +1 -1
- package/jsutils/isSameSet.mjs.map +1 -1
- package/jsutils/keyMap.d.mts +8 -15
- package/jsutils/keyMap.d.ts +8 -15
- package/jsutils/keyMap.js +0 -27
- package/jsutils/keyMap.js.map +1 -1
- package/jsutils/keyMap.mjs +0 -27
- package/jsutils/keyMap.mjs.map +1 -1
- package/jsutils/keyValMap.d.mts +10 -7
- package/jsutils/keyValMap.d.ts +10 -7
- package/jsutils/keyValMap.js +0 -17
- package/jsutils/keyValMap.js.map +1 -1
- package/jsutils/keyValMap.mjs +0 -17
- package/jsutils/keyValMap.mjs.map +1 -1
- package/jsutils/mapValue.d.mts +3 -1
- package/jsutils/mapValue.d.ts +3 -1
- package/jsutils/mapValue.js +0 -4
- package/jsutils/mapValue.js.map +1 -1
- package/jsutils/mapValue.mjs +0 -4
- package/jsutils/mapValue.mjs.map +1 -1
- package/jsutils/memoize1.d.mts +2 -0
- package/jsutils/memoize1.d.ts +2 -0
- package/jsutils/memoize1.js +0 -3
- package/jsutils/memoize1.js.map +1 -1
- package/jsutils/memoize1.mjs +0 -3
- package/jsutils/memoize1.mjs.map +1 -1
- package/jsutils/memoize2.d.mts +2 -0
- package/jsutils/memoize2.d.ts +2 -0
- package/jsutils/memoize2.js +0 -3
- package/jsutils/memoize2.js.map +1 -1
- package/jsutils/memoize2.mjs +0 -3
- package/jsutils/memoize2.mjs.map +1 -1
- package/jsutils/memoize3.d.mts +2 -0
- package/jsutils/memoize3.d.ts +2 -0
- package/jsutils/memoize3.js +0 -3
- package/jsutils/memoize3.js.map +1 -1
- package/jsutils/memoize3.mjs +0 -3
- package/jsutils/memoize3.mjs.map +1 -1
- package/jsutils/naturalCompare.d.mts +1 -0
- package/jsutils/naturalCompare.d.ts +1 -0
- package/jsutils/naturalCompare.js +0 -7
- package/jsutils/naturalCompare.js.map +1 -1
- package/jsutils/naturalCompare.mjs +0 -7
- package/jsutils/naturalCompare.mjs.map +1 -1
- package/jsutils/printPathArray.d.mts +2 -0
- package/jsutils/printPathArray.d.ts +2 -0
- package/jsutils/printPathArray.js +0 -3
- package/jsutils/printPathArray.js.map +1 -1
- package/jsutils/printPathArray.mjs +0 -3
- package/jsutils/printPathArray.mjs.map +1 -1
- package/jsutils/promiseForObject.d.mts +4 -2
- package/jsutils/promiseForObject.d.ts +4 -2
- package/jsutils/promiseForObject.js +0 -7
- package/jsutils/promiseForObject.js.map +1 -1
- package/jsutils/promiseForObject.mjs +0 -7
- package/jsutils/promiseForObject.mjs.map +1 -1
- package/jsutils/promiseReduce.d.mts +3 -1
- package/jsutils/promiseReduce.d.ts +3 -1
- package/jsutils/promiseReduce.js +2 -9
- package/jsutils/promiseReduce.js.map +1 -1
- package/jsutils/promiseReduce.mjs +0 -7
- package/jsutils/promiseReduce.mjs.map +1 -1
- package/jsutils/promiseWithResolvers.d.mts +3 -1
- package/jsutils/promiseWithResolvers.d.ts +3 -1
- package/jsutils/promiseWithResolvers.js +0 -5
- package/jsutils/promiseWithResolvers.js.map +1 -1
- package/jsutils/promiseWithResolvers.mjs +0 -5
- package/jsutils/promiseWithResolvers.mjs.map +1 -1
- package/jsutils/suggestionList.d.mts +2 -0
- package/jsutils/suggestionList.d.ts +2 -0
- package/jsutils/suggestionList.js +3 -26
- package/jsutils/suggestionList.js.map +1 -1
- package/jsutils/suggestionList.mjs +1 -24
- package/jsutils/suggestionList.mjs.map +1 -1
- package/jsutils/toError.d.mts +2 -0
- package/jsutils/toError.d.ts +2 -0
- package/jsutils/toError.js +2 -5
- package/jsutils/toError.js.map +1 -1
- package/jsutils/toError.mjs +0 -3
- package/jsutils/toError.mjs.map +1 -1
- package/jsutils/toObjMap.d.mts +4 -2
- package/jsutils/toObjMap.d.ts +4 -2
- package/jsutils/toObjMap.js.map +1 -1
- package/jsutils/toObjMap.mjs.map +1 -1
- package/language/KindTypeMap.d.mts +2 -1
- package/language/KindTypeMap.d.ts +2 -1
- package/language/KindTypeMap.js.map +1 -1
- package/language/KindTypeMap.mjs.map +1 -1
- package/language/ast.d.mts +425 -58
- package/language/ast.d.ts +425 -58
- package/language/ast.js +8 -21
- package/language/ast.js.map +1 -1
- package/language/ast.mjs +8 -21
- package/language/ast.mjs.map +1 -1
- package/language/blockString.d.mts +1 -3
- package/language/blockString.d.ts +1 -3
- package/language/blockString.js +15 -41
- package/language/blockString.js.map +1 -1
- package/language/blockString.mjs +11 -37
- package/language/blockString.mjs.map +1 -1
- package/language/characterClasses.js +2 -45
- package/language/characterClasses.js.map +1 -1
- package/language/characterClasses.mjs +2 -45
- package/language/characterClasses.mjs.map +1 -1
- package/language/directiveLocation.d.mts +26 -6
- package/language/directiveLocation.d.ts +26 -6
- package/language/directiveLocation.js +2 -6
- package/language/directiveLocation.js.map +1 -1
- package/language/directiveLocation.mjs +2 -6
- package/language/directiveLocation.mjs.map +1 -1
- package/language/index.d.mts +22 -16
- package/language/index.d.ts +22 -16
- package/language/index.js +45 -49
- package/language/index.js.map +1 -1
- package/language/index.mjs +0 -4
- package/language/index.mjs.map +1 -1
- package/language/kinds.d.mts +5 -2
- package/language/kinds.d.ts +5 -2
- package/language/kinds.js.map +1 -1
- package/language/kinds.mjs.map +1 -1
- package/language/kinds_.d.mts +102 -12
- package/language/kinds_.d.ts +102 -12
- package/language/kinds_.js +2 -14
- package/language/kinds_.js.map +1 -1
- package/language/kinds_.mjs +1 -13
- package/language/kinds_.mjs.map +1 -1
- package/language/lexer.d.mts +51 -18
- package/language/lexer.d.ts +51 -18
- package/language/lexer.js +102 -343
- package/language/lexer.js.map +1 -1
- package/language/lexer.mjs +37 -278
- package/language/lexer.mjs.map +1 -1
- package/language/location.d.mts +17 -4
- package/language/location.d.ts +17 -4
- package/language/location.js +2 -6
- package/language/location.js.map +1 -1
- package/language/location.mjs +0 -4
- package/language/location.mjs.map +1 -1
- package/language/parser.d.mts +243 -15
- package/language/parser.d.ts +243 -15
- package/language/parser.js +183 -528
- package/language/parser.js.map +1 -1
- package/language/parser.mjs +26 -371
- package/language/parser.mjs.map +1 -1
- package/language/predicates.d.mts +182 -1
- package/language/predicates.d.ts +182 -1
- package/language/predicates.js +45 -49
- package/language/predicates.js.map +1 -1
- package/language/predicates.mjs +3 -7
- package/language/predicates.mjs.map +1 -1
- package/language/printLocation.d.mts +31 -3
- package/language/printLocation.d.ts +31 -3
- package/language/printLocation.js +2 -10
- package/language/printLocation.js.map +1 -1
- package/language/printLocation.mjs +0 -8
- package/language/printLocation.mjs.map +1 -1
- package/language/printString.d.mts +2 -0
- package/language/printString.d.ts +2 -0
- package/language/printString.js +5 -11
- package/language/printString.js.map +1 -1
- package/language/printString.mjs +5 -11
- package/language/printString.mjs.map +1 -1
- package/language/printer.d.mts +13 -1
- package/language/printer.d.ts +13 -1
- package/language/printer.js +10 -31
- package/language/printer.js.map +1 -1
- package/language/printer.mjs +5 -26
- package/language/printer.mjs.map +1 -1
- package/language/schemaCoordinateLexer.d.mts +17 -3
- package/language/schemaCoordinateLexer.d.ts +17 -3
- package/language/schemaCoordinateLexer.js +21 -51
- package/language/schemaCoordinateLexer.js.map +1 -1
- package/language/schemaCoordinateLexer.mjs +5 -35
- package/language/schemaCoordinateLexer.mjs.map +1 -1
- package/language/source.d.mts +28 -1
- package/language/source.d.ts +28 -1
- package/language/source.js +5 -17
- package/language/source.js.map +1 -1
- package/language/source.mjs +0 -12
- package/language/source.mjs.map +1 -1
- package/language/tokenKind.d.mts +5 -0
- package/language/tokenKind.d.ts +5 -0
- package/language/tokenKind.js +0 -4
- package/language/tokenKind.js.map +1 -1
- package/language/tokenKind.mjs +0 -4
- package/language/tokenKind.mjs.map +1 -1
- package/language/visitor.d.mts +184 -74
- package/language/visitor.d.ts +184 -74
- package/language/visitor.js +10 -25
- package/language/visitor.js.map +1 -1
- package/language/visitor.mjs +0 -15
- package/language/visitor.mjs.map +1 -1
- package/package.json +2 -2
- package/type/assertName.d.mts +18 -1
- package/type/assertName.d.ts +18 -1
- package/type/assertName.js +8 -16
- package/type/assertName.js.map +1 -1
- package/type/assertName.mjs +0 -8
- package/type/assertName.mjs.map +1 -1
- package/type/definition.d.mts +3268 -138
- package/type/definition.d.ts +3268 -138
- package/type/definition.js +99 -346
- package/type/definition.js.map +1 -1
- package/type/definition.mjs +5 -252
- package/type/definition.mjs.map +1 -1
- package/type/directives.d.mts +220 -26
- package/type/directives.d.ts +220 -26
- package/type/directives.js +51 -83
- package/type/directives.js.map +1 -1
- package/type/directives.mjs +5 -37
- package/type/directives.mjs.map +1 -1
- package/type/index.d.mts +18 -12
- package/type/index.d.ts +18 -12
- package/type/index.js +106 -129
- package/type/index.js.map +1 -1
- package/type/index.mjs +5 -48
- package/type/index.mjs.map +1 -1
- package/type/introspection.d.mts +38 -2
- package/type/introspection.d.ts +38 -2
- package/type/introspection.js +122 -107
- package/type/introspection.js.map +1 -1
- package/type/introspection.mjs +24 -9
- package/type/introspection.mjs.map +1 -1
- package/type/scalars.d.mts +31 -4
- package/type/scalars.d.ts +31 -4
- package/type/scalars.js +61 -76
- package/type/scalars.js.map +1 -1
- package/type/scalars.mjs +0 -15
- package/type/scalars.mjs.map +1 -1
- package/type/schema.d.mts +514 -38
- package/type/schema.d.ts +514 -38
- package/type/schema.js +32 -129
- package/type/schema.js.map +1 -1
- package/type/schema.mjs +0 -97
- package/type/schema.mjs.map +1 -1
- package/type/validate.d.mts +36 -7
- package/type/validate.d.ts +36 -7
- package/type/validate.js +83 -195
- package/type/validate.js.map +1 -1
- package/type/validate.mjs +1 -113
- package/type/validate.mjs.map +1 -1
- package/utilities/TypeInfo.d.mts +570 -7
- package/utilities/TypeInfo.d.ts +570 -7
- package/utilities/TypeInfo.js +62 -85
- package/utilities/TypeInfo.js.map +1 -1
- package/utilities/TypeInfo.mjs +2 -25
- package/utilities/TypeInfo.mjs.map +1 -1
- package/utilities/astFromValue.d.mts +39 -6
- package/utilities/astFromValue.d.ts +39 -6
- package/utilities/astFromValue.js +30 -74
- package/utilities/astFromValue.js.map +1 -1
- package/utilities/astFromValue.mjs +0 -44
- package/utilities/astFromValue.mjs.map +1 -1
- package/utilities/buildASTSchema.d.mts +71 -11
- package/utilities/buildASTSchema.d.ts +71 -11
- package/utilities/buildASTSchema.js +11 -31
- package/utilities/buildASTSchema.js.map +1 -1
- package/utilities/buildASTSchema.mjs +1 -21
- package/utilities/buildASTSchema.mjs.map +1 -1
- package/utilities/buildClientSchema.d.mts +20 -5
- package/utilities/buildClientSchema.d.ts +20 -5
- package/utilities/buildClientSchema.js +53 -83
- package/utilities/buildClientSchema.js.map +1 -1
- package/utilities/buildClientSchema.mjs +1 -30
- package/utilities/buildClientSchema.mjs.map +1 -1
- package/utilities/coerceInputValue.d.mts +88 -6
- package/utilities/coerceInputValue.d.ts +88 -6
- package/utilities/coerceInputValue.js +52 -81
- package/utilities/coerceInputValue.js.map +1 -1
- package/utilities/coerceInputValue.mjs +21 -50
- package/utilities/coerceInputValue.mjs.map +1 -1
- package/utilities/concatAST.d.mts +13 -1
- package/utilities/concatAST.d.ts +13 -1
- package/utilities/concatAST.js +2 -7
- package/utilities/concatAST.js.map +1 -1
- package/utilities/concatAST.mjs +0 -5
- package/utilities/concatAST.mjs.map +1 -1
- package/utilities/extendSchema.d.mts +61 -6
- package/utilities/extendSchema.d.ts +61 -6
- package/utilities/extendSchema.js +92 -126
- package/utilities/extendSchema.js.map +1 -1
- package/utilities/extendSchema.mjs +27 -61
- package/utilities/extendSchema.mjs.map +1 -1
- package/utilities/findSchemaChanges.d.mts +100 -2
- package/utilities/findSchemaChanges.d.ts +100 -2
- package/utilities/findSchemaChanges.js +41 -75
- package/utilities/findSchemaChanges.js.map +1 -1
- package/utilities/findSchemaChanges.mjs +3 -37
- package/utilities/findSchemaChanges.mjs.map +1 -1
- package/utilities/getDefaultValueAST.d.mts +3 -2
- package/utilities/getDefaultValueAST.d.ts +3 -2
- package/utilities/getDefaultValueAST.js +7 -7
- package/utilities/getDefaultValueAST.js.map +1 -1
- package/utilities/getDefaultValueAST.mjs.map +1 -1
- package/utilities/getIntrospectionQuery.d.mts +151 -3
- package/utilities/getIntrospectionQuery.d.ts +151 -3
- package/utilities/getIntrospectionQuery.js +22 -42
- package/utilities/getIntrospectionQuery.js.map +1 -1
- package/utilities/getIntrospectionQuery.mjs +22 -42
- package/utilities/getIntrospectionQuery.mjs.map +1 -1
- package/utilities/getOperationAST.d.mts +17 -2
- package/utilities/getOperationAST.d.ts +17 -2
- package/utilities/getOperationAST.js +2 -10
- package/utilities/getOperationAST.js.map +1 -1
- package/utilities/getOperationAST.mjs +0 -8
- package/utilities/getOperationAST.mjs.map +1 -1
- package/utilities/index.d.mts +45 -30
- package/utilities/index.d.ts +45 -30
- package/utilities/index.js +61 -88
- package/utilities/index.js.map +1 -1
- package/utilities/index.mjs +4 -37
- package/utilities/index.mjs.map +1 -1
- package/utilities/introspectionFromSchema.d.mts +56 -2
- package/utilities/introspectionFromSchema.d.ts +56 -2
- package/utilities/introspectionFromSchema.js +8 -16
- package/utilities/introspectionFromSchema.js.map +1 -1
- package/utilities/introspectionFromSchema.mjs +1 -9
- package/utilities/introspectionFromSchema.mjs.map +1 -1
- package/utilities/lexicographicSortSchema.d.mts +36 -1
- package/utilities/lexicographicSortSchema.d.ts +36 -1
- package/utilities/lexicographicSortSchema.js +14 -19
- package/utilities/lexicographicSortSchema.js.map +1 -1
- package/utilities/lexicographicSortSchema.mjs +0 -5
- package/utilities/lexicographicSortSchema.mjs.map +1 -1
- package/utilities/mapSchemaConfig.d.mts +9 -6
- package/utilities/mapSchemaConfig.d.ts +9 -6
- package/utilities/mapSchemaConfig.js +28 -40
- package/utilities/mapSchemaConfig.js.map +1 -1
- package/utilities/mapSchemaConfig.mjs +0 -12
- package/utilities/mapSchemaConfig.mjs.map +1 -1
- package/utilities/printSchema.d.mts +87 -3
- package/utilities/printSchema.d.ts +87 -3
- package/utilities/printSchema.js +30 -59
- package/utilities/printSchema.js.map +1 -1
- package/utilities/printSchema.mjs +1 -30
- package/utilities/printSchema.mjs.map +1 -1
- package/utilities/replaceVariables.d.mts +40 -4
- package/utilities/replaceVariables.d.ts +40 -4
- package/utilities/replaceVariables.js +9 -17
- package/utilities/replaceVariables.js.map +1 -1
- package/utilities/replaceVariables.mjs +0 -8
- package/utilities/replaceVariables.mjs.map +1 -1
- package/utilities/resolveSchemaCoordinate.d.mts +67 -5
- package/utilities/resolveSchemaCoordinate.d.ts +67 -5
- package/utilities/resolveSchemaCoordinate.js +23 -79
- package/utilities/resolveSchemaCoordinate.js.map +1 -1
- package/utilities/resolveSchemaCoordinate.mjs +0 -56
- package/utilities/resolveSchemaCoordinate.mjs.map +1 -1
- package/utilities/separateOperations.d.mts +32 -2
- package/utilities/separateOperations.d.ts +32 -2
- package/utilities/separateOperations.js +7 -22
- package/utilities/separateOperations.js.map +1 -1
- package/utilities/separateOperations.mjs +0 -15
- package/utilities/separateOperations.mjs.map +1 -1
- package/utilities/sortValueNode.d.mts +1 -1
- package/utilities/sortValueNode.d.ts +1 -1
- package/utilities/sortValueNode.js +12 -19
- package/utilities/sortValueNode.js.map +1 -1
- package/utilities/sortValueNode.mjs +0 -7
- package/utilities/sortValueNode.mjs.map +1 -1
- package/utilities/stripIgnoredCharacters.d.mts +14 -7
- package/utilities/stripIgnoredCharacters.d.ts +14 -7
- package/utilities/stripIgnoredCharacters.js +11 -76
- package/utilities/stripIgnoredCharacters.js.map +1 -1
- package/utilities/stripIgnoredCharacters.mjs +0 -65
- package/utilities/stripIgnoredCharacters.mjs.map +1 -1
- package/utilities/typeComparators.d.mts +86 -2
- package/utilities/typeComparators.d.ts +86 -2
- package/utilities/typeComparators.js +14 -47
- package/utilities/typeComparators.js.map +1 -1
- package/utilities/typeComparators.mjs +0 -33
- package/utilities/typeComparators.mjs.map +1 -1
- package/utilities/typeFromAST.d.mts +90 -4
- package/utilities/typeFromAST.d.ts +90 -4
- package/utilities/typeFromAST.js +7 -7
- package/utilities/typeFromAST.js.map +1 -1
- package/utilities/typeFromAST.mjs.map +1 -1
- package/utilities/typedQueryDocumentNode.d.mts +5 -1
- package/utilities/typedQueryDocumentNode.d.ts +5 -1
- package/utilities/typedQueryDocumentNode.js.map +1 -1
- package/utilities/typedQueryDocumentNode.mjs.map +1 -1
- package/utilities/validateInputValue.d.mts +129 -6
- package/utilities/validateInputValue.d.ts +129 -6
- package/utilities/validateInputValue.js +60 -80
- package/utilities/validateInputValue.js.map +1 -1
- package/utilities/validateInputValue.mjs +0 -20
- package/utilities/validateInputValue.mjs.map +1 -1
- package/utilities/valueFromAST.d.mts +45 -4
- package/utilities/valueFromAST.d.ts +45 -4
- package/utilities/valueFromAST.js +32 -72
- package/utilities/valueFromAST.js.map +1 -1
- package/utilities/valueFromAST.mjs +13 -53
- package/utilities/valueFromAST.mjs.map +1 -1
- package/utilities/valueFromASTUntyped.d.mts +18 -5
- package/utilities/valueFromASTUntyped.d.ts +18 -5
- package/utilities/valueFromASTUntyped.js +12 -28
- package/utilities/valueFromASTUntyped.js.map +1 -1
- package/utilities/valueFromASTUntyped.mjs +0 -16
- package/utilities/valueFromASTUntyped.mjs.map +1 -1
- package/utilities/valueToLiteral.d.mts +32 -3
- package/utilities/valueToLiteral.d.ts +32 -3
- package/utilities/valueToLiteral.js +37 -70
- package/utilities/valueToLiteral.js.map +1 -1
- package/utilities/valueToLiteral.mjs +7 -40
- package/utilities/valueToLiteral.mjs.map +1 -1
- package/validation/ValidationContext.d.mts +499 -9
- package/validation/ValidationContext.d.ts +499 -9
- package/validation/ValidationContext.js +9 -16
- package/validation/ValidationContext.js.map +1 -1
- package/validation/ValidationContext.mjs +1 -8
- package/validation/ValidationContext.mjs.map +1 -1
- package/validation/index.d.mts +53 -46
- package/validation/index.d.ts +53 -46
- package/validation/index.js +91 -125
- package/validation/index.js.map +1 -1
- package/validation/index.mjs +0 -34
- package/validation/index.mjs.map +1 -1
- package/validation/rules/DeferStreamDirectiveLabelRule.d.mts +32 -2
- package/validation/rules/DeferStreamDirectiveLabelRule.d.ts +32 -2
- package/validation/rules/DeferStreamDirectiveLabelRule.js +9 -14
- package/validation/rules/DeferStreamDirectiveLabelRule.js.map +1 -1
- package/validation/rules/DeferStreamDirectiveLabelRule.mjs +0 -5
- package/validation/rules/DeferStreamDirectiveLabelRule.mjs.map +1 -1
- package/validation/rules/DeferStreamDirectiveOnRootFieldRule.d.mts +30 -2
- package/validation/rules/DeferStreamDirectiveOnRootFieldRule.d.ts +30 -2
- package/validation/rules/DeferStreamDirectiveOnRootFieldRule.js +8 -13
- package/validation/rules/DeferStreamDirectiveOnRootFieldRule.js.map +1 -1
- package/validation/rules/DeferStreamDirectiveOnRootFieldRule.mjs +0 -5
- package/validation/rules/DeferStreamDirectiveOnRootFieldRule.mjs.map +1 -1
- package/validation/rules/DeferStreamDirectiveOnValidOperationsRule.d.mts +54 -2
- package/validation/rules/DeferStreamDirectiveOnValidOperationsRule.d.ts +54 -2
- package/validation/rules/DeferStreamDirectiveOnValidOperationsRule.js +14 -19
- package/validation/rules/DeferStreamDirectiveOnValidOperationsRule.js.map +1 -1
- package/validation/rules/DeferStreamDirectiveOnValidOperationsRule.mjs +0 -5
- package/validation/rules/DeferStreamDirectiveOnValidOperationsRule.mjs.map +1 -1
- package/validation/rules/ExecutableDefinitionsRule.d.mts +30 -2
- package/validation/rules/ExecutableDefinitionsRule.d.ts +30 -2
- package/validation/rules/ExecutableDefinitionsRule.js +7 -15
- package/validation/rules/ExecutableDefinitionsRule.js.map +1 -1
- package/validation/rules/ExecutableDefinitionsRule.mjs +0 -8
- package/validation/rules/ExecutableDefinitionsRule.mjs.map +1 -1
- package/validation/rules/FieldsOnCorrectTypeRule.d.mts +30 -2
- package/validation/rules/FieldsOnCorrectTypeRule.d.ts +30 -2
- package/validation/rules/FieldsOnCorrectTypeRule.js +14 -41
- package/validation/rules/FieldsOnCorrectTypeRule.js.map +1 -1
- package/validation/rules/FieldsOnCorrectTypeRule.mjs +0 -27
- package/validation/rules/FieldsOnCorrectTypeRule.mjs.map +1 -1
- package/validation/rules/FragmentsOnCompositeTypesRule.d.mts +30 -2
- package/validation/rules/FragmentsOnCompositeTypesRule.d.ts +30 -2
- package/validation/rules/FragmentsOnCompositeTypesRule.js +12 -21
- package/validation/rules/FragmentsOnCompositeTypesRule.js.map +1 -1
- package/validation/rules/FragmentsOnCompositeTypesRule.mjs +0 -9
- package/validation/rules/FragmentsOnCompositeTypesRule.mjs.map +1 -1
- package/validation/rules/KnownArgumentNamesRule.d.mts +31 -5
- package/validation/rules/KnownArgumentNamesRule.d.ts +31 -5
- package/validation/rules/KnownArgumentNamesRule.js +16 -29
- package/validation/rules/KnownArgumentNamesRule.js.map +1 -1
- package/validation/rules/KnownArgumentNamesRule.mjs +0 -13
- package/validation/rules/KnownArgumentNamesRule.mjs.map +1 -1
- package/validation/rules/KnownDirectivesRule.d.mts +30 -2
- package/validation/rules/KnownDirectivesRule.d.ts +30 -2
- package/validation/rules/KnownDirectivesRule.js +66 -73
- package/validation/rules/KnownDirectivesRule.js.map +1 -1
- package/validation/rules/KnownDirectivesRule.mjs +3 -10
- package/validation/rules/KnownDirectivesRule.mjs.map +1 -1
- package/validation/rules/KnownFragmentNamesRule.d.mts +30 -2
- package/validation/rules/KnownFragmentNamesRule.d.ts +30 -2
- package/validation/rules/KnownFragmentNamesRule.js +2 -10
- package/validation/rules/KnownFragmentNamesRule.js.map +1 -1
- package/validation/rules/KnownFragmentNamesRule.mjs +0 -8
- package/validation/rules/KnownFragmentNamesRule.mjs.map +1 -1
- package/validation/rules/KnownOperationTypesRule.d.mts +22 -2
- package/validation/rules/KnownOperationTypesRule.d.ts +22 -2
- package/validation/rules/KnownOperationTypesRule.js +2 -10
- package/validation/rules/KnownOperationTypesRule.js.map +1 -1
- package/validation/rules/KnownOperationTypesRule.mjs +0 -8
- package/validation/rules/KnownOperationTypesRule.mjs.map +1 -1
- package/validation/rules/KnownTypeNamesRule.d.mts +30 -2
- package/validation/rules/KnownTypeNamesRule.d.ts +30 -2
- package/validation/rules/KnownTypeNamesRule.js +11 -19
- package/validation/rules/KnownTypeNamesRule.js.map +1 -1
- package/validation/rules/KnownTypeNamesRule.mjs +0 -8
- package/validation/rules/KnownTypeNamesRule.mjs.map +1 -1
- package/validation/rules/LoneAnonymousOperationRule.d.mts +30 -2
- package/validation/rules/LoneAnonymousOperationRule.d.ts +30 -2
- package/validation/rules/LoneAnonymousOperationRule.js +4 -12
- package/validation/rules/LoneAnonymousOperationRule.js.map +1 -1
- package/validation/rules/LoneAnonymousOperationRule.mjs +0 -8
- package/validation/rules/LoneAnonymousOperationRule.mjs.map +1 -1
- package/validation/rules/LoneSchemaDefinitionRule.d.mts +23 -2
- package/validation/rules/LoneSchemaDefinitionRule.d.ts +23 -2
- package/validation/rules/LoneSchemaDefinitionRule.js +3 -8
- package/validation/rules/LoneSchemaDefinitionRule.js.map +1 -1
- package/validation/rules/LoneSchemaDefinitionRule.mjs +0 -5
- package/validation/rules/LoneSchemaDefinitionRule.mjs.map +1 -1
- package/validation/rules/MaxIntrospectionDepthRule.d.mts +33 -2
- package/validation/rules/MaxIntrospectionDepthRule.d.ts +33 -2
- package/validation/rules/MaxIntrospectionDepthRule.js +5 -19
- package/validation/rules/MaxIntrospectionDepthRule.js.map +1 -1
- package/validation/rules/MaxIntrospectionDepthRule.mjs +0 -14
- package/validation/rules/MaxIntrospectionDepthRule.mjs.map +1 -1
- package/validation/rules/NoFragmentCyclesRule.d.mts +30 -2
- package/validation/rules/NoFragmentCyclesRule.d.ts +30 -2
- package/validation/rules/NoFragmentCyclesRule.js +2 -17
- package/validation/rules/NoFragmentCyclesRule.js.map +1 -1
- package/validation/rules/NoFragmentCyclesRule.mjs +0 -15
- package/validation/rules/NoFragmentCyclesRule.mjs.map +1 -1
- package/validation/rules/NoUndefinedVariablesRule.d.mts +30 -2
- package/validation/rules/NoUndefinedVariablesRule.d.ts +30 -2
- package/validation/rules/NoUndefinedVariablesRule.js +2 -10
- package/validation/rules/NoUndefinedVariablesRule.js.map +1 -1
- package/validation/rules/NoUndefinedVariablesRule.mjs +0 -8
- package/validation/rules/NoUndefinedVariablesRule.mjs.map +1 -1
- package/validation/rules/NoUnusedFragmentsRule.d.mts +30 -2
- package/validation/rules/NoUnusedFragmentsRule.d.ts +30 -2
- package/validation/rules/NoUnusedFragmentsRule.js +2 -10
- package/validation/rules/NoUnusedFragmentsRule.js.map +1 -1
- package/validation/rules/NoUnusedFragmentsRule.mjs +0 -8
- package/validation/rules/NoUnusedFragmentsRule.mjs.map +1 -1
- package/validation/rules/NoUnusedVariablesRule.d.mts +31 -2
- package/validation/rules/NoUnusedVariablesRule.d.ts +31 -2
- package/validation/rules/NoUnusedVariablesRule.js +3 -11
- package/validation/rules/NoUnusedVariablesRule.js.map +1 -1
- package/validation/rules/NoUnusedVariablesRule.mjs +0 -8
- package/validation/rules/NoUnusedVariablesRule.mjs.map +1 -1
- package/validation/rules/OverlappingFieldsCanBeMergedRule.d.mts +35 -2
- package/validation/rules/OverlappingFieldsCanBeMergedRule.d.ts +35 -2
- package/validation/rules/OverlappingFieldsCanBeMergedRule.js +32 -206
- package/validation/rules/OverlappingFieldsCanBeMergedRule.js.map +1 -1
- package/validation/rules/OverlappingFieldsCanBeMergedRule.mjs +1 -175
- package/validation/rules/OverlappingFieldsCanBeMergedRule.mjs.map +1 -1
- package/validation/rules/PossibleFragmentSpreadsRule.d.mts +38 -2
- package/validation/rules/PossibleFragmentSpreadsRule.d.ts +38 -2
- package/validation/rules/PossibleFragmentSpreadsRule.js +17 -24
- package/validation/rules/PossibleFragmentSpreadsRule.js.map +1 -1
- package/validation/rules/PossibleFragmentSpreadsRule.mjs +0 -7
- package/validation/rules/PossibleFragmentSpreadsRule.mjs.map +1 -1
- package/validation/rules/PossibleTypeExtensionsRule.d.mts +23 -2
- package/validation/rules/PossibleTypeExtensionsRule.d.ts +23 -2
- package/validation/rules/PossibleTypeExtensionsRule.js +38 -49
- package/validation/rules/PossibleTypeExtensionsRule.js.map +1 -1
- package/validation/rules/PossibleTypeExtensionsRule.mjs +0 -11
- package/validation/rules/PossibleTypeExtensionsRule.mjs.map +1 -1
- package/validation/rules/ProvidedRequiredArgumentsRule.d.mts +31 -5
- package/validation/rules/ProvidedRequiredArgumentsRule.d.ts +31 -5
- package/validation/rules/ProvidedRequiredArgumentsRule.js +20 -33
- package/validation/rules/ProvidedRequiredArgumentsRule.js.map +1 -1
- package/validation/rules/ProvidedRequiredArgumentsRule.mjs +0 -13
- package/validation/rules/ProvidedRequiredArgumentsRule.mjs.map +1 -1
- package/validation/rules/ScalarLeafsRule.d.mts +30 -2
- package/validation/rules/ScalarLeafsRule.d.ts +30 -2
- package/validation/rules/ScalarLeafsRule.js +10 -16
- package/validation/rules/ScalarLeafsRule.js.map +1 -1
- package/validation/rules/ScalarLeafsRule.mjs +0 -6
- package/validation/rules/ScalarLeafsRule.mjs.map +1 -1
- package/validation/rules/SingleFieldSubscriptionsRule.d.mts +36 -4
- package/validation/rules/SingleFieldSubscriptionsRule.d.ts +36 -4
- package/validation/rules/SingleFieldSubscriptionsRule.js +8 -17
- package/validation/rules/SingleFieldSubscriptionsRule.js.map +1 -1
- package/validation/rules/SingleFieldSubscriptionsRule.mjs +0 -9
- package/validation/rules/SingleFieldSubscriptionsRule.mjs.map +1 -1
- package/validation/rules/StreamDirectiveOnListFieldRule.d.mts +23 -2
- package/validation/rules/StreamDirectiveOnListFieldRule.d.ts +23 -2
- package/validation/rules/StreamDirectiveOnListFieldRule.js +7 -12
- package/validation/rules/StreamDirectiveOnListFieldRule.js.map +1 -1
- package/validation/rules/StreamDirectiveOnListFieldRule.mjs +0 -5
- package/validation/rules/StreamDirectiveOnListFieldRule.mjs.map +1 -1
- package/validation/rules/UniqueArgumentDefinitionNamesRule.d.mts +23 -2
- package/validation/rules/UniqueArgumentDefinitionNamesRule.d.ts +23 -2
- package/validation/rules/UniqueArgumentDefinitionNamesRule.js +4 -10
- package/validation/rules/UniqueArgumentDefinitionNamesRule.js.map +1 -1
- package/validation/rules/UniqueArgumentDefinitionNamesRule.mjs +0 -6
- package/validation/rules/UniqueArgumentDefinitionNamesRule.mjs.map +1 -1
- package/validation/rules/UniqueArgumentNamesRule.d.mts +30 -2
- package/validation/rules/UniqueArgumentNamesRule.d.ts +30 -2
- package/validation/rules/UniqueArgumentNamesRule.js +4 -12
- package/validation/rules/UniqueArgumentNamesRule.js.map +1 -1
- package/validation/rules/UniqueArgumentNamesRule.mjs +0 -8
- package/validation/rules/UniqueArgumentNamesRule.mjs.map +1 -1
- package/validation/rules/UniqueDirectiveNamesRule.d.mts +23 -2
- package/validation/rules/UniqueDirectiveNamesRule.d.ts +23 -2
- package/validation/rules/UniqueDirectiveNamesRule.js +3 -8
- package/validation/rules/UniqueDirectiveNamesRule.js.map +1 -1
- package/validation/rules/UniqueDirectiveNamesRule.mjs +0 -5
- package/validation/rules/UniqueDirectiveNamesRule.mjs.map +1 -1
- package/validation/rules/UniqueDirectivesPerLocationRule.d.mts +30 -2
- package/validation/rules/UniqueDirectivesPerLocationRule.d.ts +30 -2
- package/validation/rules/UniqueDirectivesPerLocationRule.js +20 -21
- package/validation/rules/UniqueDirectivesPerLocationRule.js.map +1 -1
- package/validation/rules/UniqueDirectivesPerLocationRule.mjs +10 -11
- package/validation/rules/UniqueDirectivesPerLocationRule.mjs.map +1 -1
- package/validation/rules/UniqueEnumValueNamesRule.d.mts +23 -2
- package/validation/rules/UniqueEnumValueNamesRule.d.ts +23 -2
- package/validation/rules/UniqueEnumValueNamesRule.js +5 -10
- package/validation/rules/UniqueEnumValueNamesRule.js.map +1 -1
- package/validation/rules/UniqueEnumValueNamesRule.mjs +0 -5
- package/validation/rules/UniqueEnumValueNamesRule.mjs.map +1 -1
- package/validation/rules/UniqueFieldDefinitionNamesRule.d.mts +23 -2
- package/validation/rules/UniqueFieldDefinitionNamesRule.d.ts +23 -2
- package/validation/rules/UniqueFieldDefinitionNamesRule.js +5 -10
- package/validation/rules/UniqueFieldDefinitionNamesRule.js.map +1 -1
- package/validation/rules/UniqueFieldDefinitionNamesRule.mjs +0 -5
- package/validation/rules/UniqueFieldDefinitionNamesRule.mjs.map +1 -1
- package/validation/rules/UniqueFragmentNamesRule.d.mts +30 -2
- package/validation/rules/UniqueFragmentNamesRule.d.ts +30 -2
- package/validation/rules/UniqueFragmentNamesRule.js +2 -9
- package/validation/rules/UniqueFragmentNamesRule.js.map +1 -1
- package/validation/rules/UniqueFragmentNamesRule.mjs +0 -7
- package/validation/rules/UniqueFragmentNamesRule.mjs.map +1 -1
- package/validation/rules/UniqueInputFieldNamesRule.d.mts +34 -2
- package/validation/rules/UniqueInputFieldNamesRule.d.ts +34 -2
- package/validation/rules/UniqueInputFieldNamesRule.js +4 -12
- package/validation/rules/UniqueInputFieldNamesRule.js.map +1 -1
- package/validation/rules/UniqueInputFieldNamesRule.mjs +0 -8
- package/validation/rules/UniqueInputFieldNamesRule.mjs.map +1 -1
- package/validation/rules/UniqueOperationNamesRule.d.mts +30 -2
- package/validation/rules/UniqueOperationNamesRule.d.ts +30 -2
- package/validation/rules/UniqueOperationNamesRule.js +2 -9
- package/validation/rules/UniqueOperationNamesRule.js.map +1 -1
- package/validation/rules/UniqueOperationNamesRule.mjs +0 -7
- package/validation/rules/UniqueOperationNamesRule.mjs.map +1 -1
- package/validation/rules/UniqueOperationTypesRule.d.mts +23 -2
- package/validation/rules/UniqueOperationTypesRule.d.ts +23 -2
- package/validation/rules/UniqueOperationTypesRule.js +3 -8
- package/validation/rules/UniqueOperationTypesRule.js.map +1 -1
- package/validation/rules/UniqueOperationTypesRule.mjs +0 -5
- package/validation/rules/UniqueOperationTypesRule.mjs.map +1 -1
- package/validation/rules/UniqueTypeNamesRule.d.mts +23 -2
- package/validation/rules/UniqueTypeNamesRule.d.ts +23 -2
- package/validation/rules/UniqueTypeNamesRule.js +3 -8
- package/validation/rules/UniqueTypeNamesRule.js.map +1 -1
- package/validation/rules/UniqueTypeNamesRule.mjs +0 -5
- package/validation/rules/UniqueTypeNamesRule.mjs.map +1 -1
- package/validation/rules/UniqueVariableNamesRule.d.mts +30 -2
- package/validation/rules/UniqueVariableNamesRule.d.ts +30 -2
- package/validation/rules/UniqueVariableNamesRule.js +4 -9
- package/validation/rules/UniqueVariableNamesRule.js.map +1 -1
- package/validation/rules/UniqueVariableNamesRule.mjs +0 -5
- package/validation/rules/UniqueVariableNamesRule.mjs.map +1 -1
- package/validation/rules/ValuesOfCorrectTypeRule.d.mts +30 -2
- package/validation/rules/ValuesOfCorrectTypeRule.d.ts +30 -2
- package/validation/rules/ValuesOfCorrectTypeRule.js +3 -23
- package/validation/rules/ValuesOfCorrectTypeRule.js.map +1 -1
- package/validation/rules/ValuesOfCorrectTypeRule.mjs +1 -21
- package/validation/rules/ValuesOfCorrectTypeRule.mjs.map +1 -1
- package/validation/rules/VariablesAreInputTypesRule.d.mts +34 -2
- package/validation/rules/VariablesAreInputTypesRule.d.ts +34 -2
- package/validation/rules/VariablesAreInputTypesRule.js +8 -16
- package/validation/rules/VariablesAreInputTypesRule.js.map +1 -1
- package/validation/rules/VariablesAreInputTypesRule.mjs +0 -8
- package/validation/rules/VariablesAreInputTypesRule.mjs.map +1 -1
- package/validation/rules/VariablesInAllowedPositionRule.d.mts +30 -2
- package/validation/rules/VariablesInAllowedPositionRule.d.ts +30 -2
- package/validation/rules/VariablesInAllowedPositionRule.js +14 -34
- package/validation/rules/VariablesInAllowedPositionRule.js.map +1 -1
- package/validation/rules/VariablesInAllowedPositionRule.mjs +0 -20
- package/validation/rules/VariablesInAllowedPositionRule.mjs.map +1 -1
- package/validation/rules/custom/NoDeprecatedCustomRule.d.mts +43 -2
- package/validation/rules/custom/NoDeprecatedCustomRule.d.ts +43 -2
- package/validation/rules/custom/NoDeprecatedCustomRule.js +8 -18
- package/validation/rules/custom/NoDeprecatedCustomRule.js.map +1 -1
- package/validation/rules/custom/NoDeprecatedCustomRule.mjs +0 -10
- package/validation/rules/custom/NoDeprecatedCustomRule.mjs.map +1 -1
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.d.mts +30 -2
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.d.ts +30 -2
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.js +6 -16
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.js.map +1 -1
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.mjs +0 -10
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.mjs.map +1 -1
- package/validation/specifiedRules.d.mts +3 -4
- package/validation/specifiedRules.d.ts +3 -4
- package/validation/specifiedRules.js +87 -133
- package/validation/specifiedRules.js.map +1 -1
- package/validation/specifiedRules.mjs +0 -46
- package/validation/specifiedRules.mjs.map +1 -1
- package/validation/validate.d.mts +70 -12
- package/validation/validate.d.ts +70 -12
- package/validation/validate.js +19 -60
- package/validation/validate.js.map +1 -1
- package/validation/validate.mjs +0 -41
- package/validation/validate.mjs.map +1 -1
- package/version.d.mts +3 -6
- package/version.d.ts +3 -6
- package/version.js +2 -10
- package/version.js.map +1 -1
- package/version.mjs +2 -10
- package/version.mjs.map +1 -1
package/type/definition.d.ts
CHANGED
|
@@ -1,81 +1,996 @@
|
|
|
1
|
-
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
8
|
-
import type {
|
|
9
|
-
import type {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
*/
|
|
1
|
+
/** @category Types */
|
|
2
|
+
import type { Maybe } from "../jsutils/Maybe.js";
|
|
3
|
+
import type { ObjMap } from "../jsutils/ObjMap.js";
|
|
4
|
+
import type { Path } from "../jsutils/Path.js";
|
|
5
|
+
import type { PromiseOrValue } from "../jsutils/PromiseOrValue.js";
|
|
6
|
+
import type { ConstValueNode, EnumTypeDefinitionNode, EnumTypeExtensionNode, EnumValueDefinitionNode, FieldDefinitionNode, FieldNode, FragmentDefinitionNode, InputObjectTypeDefinitionNode, InputObjectTypeExtensionNode, InputValueDefinitionNode, InterfaceTypeDefinitionNode, InterfaceTypeExtensionNode, ObjectTypeDefinitionNode, ObjectTypeExtensionNode, OperationDefinitionNode, ScalarTypeDefinitionNode, ScalarTypeExtensionNode, UnionTypeDefinitionNode, UnionTypeExtensionNode, ValueNode } from "../language/ast.js";
|
|
7
|
+
import type { GraphQLVariableSignature } from "../execution/getVariableSignature.js";
|
|
8
|
+
import type { VariableValues } from "../execution/values.js";
|
|
9
|
+
import type { GraphQLDirective } from "./directives.js";
|
|
10
|
+
import type { GraphQLSchema } from "./schema.js";
|
|
11
|
+
/** These are all of the possible kinds of types. */
|
|
13
12
|
export type GraphQLType = GraphQLNamedType | GraphQLWrappingType;
|
|
13
|
+
/**
|
|
14
|
+
* Returns true when the value is any GraphQL type.
|
|
15
|
+
* @param type - The GraphQL type to inspect.
|
|
16
|
+
* @returns True when the value is any GraphQL type.
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
20
|
+
* import { GraphQLList, GraphQLString, isType } from 'graphql/type';
|
|
21
|
+
*
|
|
22
|
+
* const schema = buildSchema(`
|
|
23
|
+
* type Query {
|
|
24
|
+
* name: String
|
|
25
|
+
* }
|
|
26
|
+
* `);
|
|
27
|
+
*
|
|
28
|
+
* isType(GraphQLString); // => true
|
|
29
|
+
* isType(new GraphQLList(GraphQLString)); // => true
|
|
30
|
+
* isType(schema.getType('Query')); // => true
|
|
31
|
+
* isType('String'); // => false
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
14
34
|
export declare function isType(type: unknown): type is GraphQLType;
|
|
35
|
+
/**
|
|
36
|
+
* Returns the value as a GraphQL type, or throws if it is not one.
|
|
37
|
+
* @param type - The GraphQL type to inspect.
|
|
38
|
+
* @returns The value typed as a GraphQL type.
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
42
|
+
* import { assertType } from 'graphql/type';
|
|
43
|
+
*
|
|
44
|
+
* const schema = buildSchema(`
|
|
45
|
+
* type Query {
|
|
46
|
+
* name: String
|
|
47
|
+
* }
|
|
48
|
+
* `);
|
|
49
|
+
*
|
|
50
|
+
* const queryType = assertType(schema.getType('Query'));
|
|
51
|
+
*
|
|
52
|
+
* queryType.toString(); // => 'Query'
|
|
53
|
+
* assertType('Query'); // throws an error
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
15
56
|
export declare function assertType(type: unknown): GraphQLType;
|
|
16
57
|
/**
|
|
17
|
-
* There are predicates for each GraphQL
|
|
58
|
+
* There are predicates for each kind of GraphQL type.
|
|
59
|
+
* @param type - The GraphQL type to inspect.
|
|
60
|
+
* @returns True when the value is a GraphQLScalarType.
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
64
|
+
* import { isScalarType } from 'graphql/type';
|
|
65
|
+
*
|
|
66
|
+
* const schema = buildSchema(`
|
|
67
|
+
* scalar DateTime
|
|
68
|
+
*
|
|
69
|
+
* type Query {
|
|
70
|
+
* createdAt: DateTime
|
|
71
|
+
* }
|
|
72
|
+
* `);
|
|
73
|
+
*
|
|
74
|
+
* isScalarType(schema.getType('DateTime')); // => true
|
|
75
|
+
* isScalarType(schema.getType('Query')); // => false
|
|
76
|
+
* ```
|
|
18
77
|
*/
|
|
19
78
|
export declare function isScalarType(type: unknown): type is GraphQLScalarType;
|
|
79
|
+
/**
|
|
80
|
+
* Returns the value as a GraphQLScalarType, or throws if it is not one.
|
|
81
|
+
* @param type - The GraphQL type to inspect.
|
|
82
|
+
* @returns The value typed as a GraphQLScalarType.
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
86
|
+
* import { assertScalarType } from 'graphql/type';
|
|
87
|
+
*
|
|
88
|
+
* const schema = buildSchema(`
|
|
89
|
+
* scalar DateTime
|
|
90
|
+
*
|
|
91
|
+
* type Query {
|
|
92
|
+
* createdAt: DateTime
|
|
93
|
+
* }
|
|
94
|
+
* `);
|
|
95
|
+
*
|
|
96
|
+
* const dateTimeType = assertScalarType(schema.getType('DateTime'));
|
|
97
|
+
*
|
|
98
|
+
* dateTimeType.name; // => 'DateTime'
|
|
99
|
+
* assertScalarType(schema.getType('Query')); // throws an error
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
20
102
|
export declare function assertScalarType(type: unknown): GraphQLScalarType;
|
|
21
|
-
|
|
103
|
+
/**
|
|
104
|
+
* Returns true when the value is a GraphQLObjectType.
|
|
105
|
+
* @param type - The GraphQL type to inspect.
|
|
106
|
+
* @returns True when the value is a GraphQLObjectType.
|
|
107
|
+
* @example
|
|
108
|
+
* ```ts
|
|
109
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
110
|
+
* import { isObjectType } from 'graphql/type';
|
|
111
|
+
*
|
|
112
|
+
* const schema = buildSchema(`
|
|
113
|
+
* input ReviewInput {
|
|
114
|
+
* stars: Int!
|
|
115
|
+
* }
|
|
116
|
+
*
|
|
117
|
+
* type User {
|
|
118
|
+
* name: String
|
|
119
|
+
* }
|
|
120
|
+
*
|
|
121
|
+
* type Query {
|
|
122
|
+
* user: User
|
|
123
|
+
* }
|
|
124
|
+
* `);
|
|
125
|
+
*
|
|
126
|
+
* isObjectType(schema.getType('User')); // => true
|
|
127
|
+
* isObjectType(schema.getType('ReviewInput')); // => false
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
22
130
|
export declare function isObjectType(type: unknown): type is GraphQLObjectType;
|
|
131
|
+
/**
|
|
132
|
+
* Returns the value as a GraphQLObjectType, or throws if it is not one.
|
|
133
|
+
* @param type - The GraphQL type to inspect.
|
|
134
|
+
* @returns The value typed as a GraphQLObjectType.
|
|
135
|
+
* @example
|
|
136
|
+
* ```ts
|
|
137
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
138
|
+
* import { assertObjectType } from 'graphql/type';
|
|
139
|
+
*
|
|
140
|
+
* const schema = buildSchema(`
|
|
141
|
+
* input ReviewInput {
|
|
142
|
+
* stars: Int!
|
|
143
|
+
* }
|
|
144
|
+
*
|
|
145
|
+
* type User {
|
|
146
|
+
* name: String
|
|
147
|
+
* }
|
|
148
|
+
*
|
|
149
|
+
* type Query {
|
|
150
|
+
* user: User
|
|
151
|
+
* }
|
|
152
|
+
* `);
|
|
153
|
+
*
|
|
154
|
+
* const userType = assertObjectType(schema.getType('User'));
|
|
155
|
+
*
|
|
156
|
+
* Object.keys(userType.getFields()); // => ['name']
|
|
157
|
+
* assertObjectType(schema.getType('ReviewInput')); // throws an error
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
23
160
|
export declare function assertObjectType(type: unknown): GraphQLObjectType;
|
|
161
|
+
/**
|
|
162
|
+
* Returns true when the value is a resolved GraphQL field definition.
|
|
163
|
+
* @param field - Value to inspect.
|
|
164
|
+
* @returns True when the value is a GraphQLField.
|
|
165
|
+
* @example
|
|
166
|
+
* ```ts
|
|
167
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
168
|
+
* import { isField } from 'graphql/type';
|
|
169
|
+
*
|
|
170
|
+
* const schema = buildSchema('type Query { greeting: String }');
|
|
171
|
+
* const field = schema.getQueryType().getFields().greeting;
|
|
172
|
+
*
|
|
173
|
+
* isField(field); // => true
|
|
174
|
+
* isField(schema.getQueryType()); // => false
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
24
177
|
export declare function isField(field: unknown): field is GraphQLField;
|
|
178
|
+
/**
|
|
179
|
+
* Returns the value as a GraphQLField, or throws if it is not one.
|
|
180
|
+
* @param field - Value to inspect.
|
|
181
|
+
* @returns The value typed as a GraphQLField.
|
|
182
|
+
* @example
|
|
183
|
+
* ```ts
|
|
184
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
185
|
+
* import { assertField } from 'graphql/type';
|
|
186
|
+
*
|
|
187
|
+
* const schema = buildSchema('type Query { greeting: String }');
|
|
188
|
+
* const field = assertField(schema.getQueryType().getFields().greeting);
|
|
189
|
+
*
|
|
190
|
+
* field.name; // => 'greeting'
|
|
191
|
+
* assertField(schema.getQueryType()); // throws an error
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
25
194
|
export declare function assertField(field: unknown): GraphQLField;
|
|
195
|
+
/**
|
|
196
|
+
* Returns true when the value is a resolved GraphQL argument definition.
|
|
197
|
+
* @param arg - Value to inspect.
|
|
198
|
+
* @returns True when the value is a GraphQLArgument.
|
|
199
|
+
* @example
|
|
200
|
+
* ```ts
|
|
201
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
202
|
+
* import { isArgument } from 'graphql/type';
|
|
203
|
+
*
|
|
204
|
+
* const schema = buildSchema('type Query { greeting(name: String): String }');
|
|
205
|
+
* const arg = schema.getQueryType().getFields().greeting.args[0];
|
|
206
|
+
*
|
|
207
|
+
* isArgument(arg); // => true
|
|
208
|
+
* isArgument(schema.getQueryType()); // => false
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
26
211
|
export declare function isArgument(arg: unknown): arg is GraphQLArgument;
|
|
212
|
+
/**
|
|
213
|
+
* Returns the value as a GraphQLArgument, or throws if it is not one.
|
|
214
|
+
* @param arg - Value to inspect.
|
|
215
|
+
* @returns The value typed as a GraphQLArgument.
|
|
216
|
+
* @example
|
|
217
|
+
* ```ts
|
|
218
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
219
|
+
* import { assertArgument } from 'graphql/type';
|
|
220
|
+
*
|
|
221
|
+
* const schema = buildSchema('type Query { greeting(name: String): String }');
|
|
222
|
+
* const arg = assertArgument(schema.getQueryType().getFields().greeting.args[0]);
|
|
223
|
+
*
|
|
224
|
+
* arg.name; // => 'name'
|
|
225
|
+
* assertArgument(schema.getQueryType()); // throws an error
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
27
228
|
export declare function assertArgument(arg: unknown): GraphQLArgument;
|
|
229
|
+
/**
|
|
230
|
+
* Returns true when the value is a GraphQLInterfaceType.
|
|
231
|
+
* @param type - The GraphQL type to inspect.
|
|
232
|
+
* @returns True when the value is a GraphQLInterfaceType.
|
|
233
|
+
* @example
|
|
234
|
+
* ```ts
|
|
235
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
236
|
+
* import { isInterfaceType } from 'graphql/type';
|
|
237
|
+
*
|
|
238
|
+
* const schema = buildSchema(`
|
|
239
|
+
* interface Node {
|
|
240
|
+
* id: ID!
|
|
241
|
+
* }
|
|
242
|
+
*
|
|
243
|
+
* type User implements Node {
|
|
244
|
+
* id: ID!
|
|
245
|
+
* }
|
|
246
|
+
*
|
|
247
|
+
* type Query {
|
|
248
|
+
* node: Node
|
|
249
|
+
* }
|
|
250
|
+
* `);
|
|
251
|
+
*
|
|
252
|
+
* isInterfaceType(schema.getType('Node')); // => true
|
|
253
|
+
* isInterfaceType(schema.getType('User')); // => false
|
|
254
|
+
* ```
|
|
255
|
+
*/
|
|
28
256
|
export declare function isInterfaceType(type: unknown): type is GraphQLInterfaceType;
|
|
257
|
+
/**
|
|
258
|
+
* Returns the value as a GraphQLInterfaceType, or throws if it is not one.
|
|
259
|
+
* @param type - The GraphQL type to inspect.
|
|
260
|
+
* @returns The value typed as a GraphQLInterfaceType.
|
|
261
|
+
* @example
|
|
262
|
+
* ```ts
|
|
263
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
264
|
+
* import { assertInterfaceType } from 'graphql/type';
|
|
265
|
+
*
|
|
266
|
+
* const schema = buildSchema(`
|
|
267
|
+
* interface Node {
|
|
268
|
+
* id: ID!
|
|
269
|
+
* }
|
|
270
|
+
*
|
|
271
|
+
* type User implements Node {
|
|
272
|
+
* id: ID!
|
|
273
|
+
* }
|
|
274
|
+
*
|
|
275
|
+
* type Query {
|
|
276
|
+
* node: Node
|
|
277
|
+
* }
|
|
278
|
+
* `);
|
|
279
|
+
*
|
|
280
|
+
* const nodeType = assertInterfaceType(schema.getType('Node'));
|
|
281
|
+
*
|
|
282
|
+
* nodeType.name; // => 'Node'
|
|
283
|
+
* assertInterfaceType(schema.getType('User')); // throws an error
|
|
284
|
+
* ```
|
|
285
|
+
*/
|
|
29
286
|
export declare function assertInterfaceType(type: unknown): GraphQLInterfaceType;
|
|
287
|
+
/**
|
|
288
|
+
* Returns true when the value is a GraphQLUnionType.
|
|
289
|
+
* @param type - The GraphQL type to inspect.
|
|
290
|
+
* @returns True when the value is a GraphQLUnionType.
|
|
291
|
+
* @example
|
|
292
|
+
* ```ts
|
|
293
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
294
|
+
* import { isUnionType } from 'graphql/type';
|
|
295
|
+
*
|
|
296
|
+
* const schema = buildSchema(`
|
|
297
|
+
* type Photo {
|
|
298
|
+
* url: String!
|
|
299
|
+
* }
|
|
300
|
+
*
|
|
301
|
+
* type Video {
|
|
302
|
+
* url: String!
|
|
303
|
+
* }
|
|
304
|
+
*
|
|
305
|
+
* union Media = Photo | Video
|
|
306
|
+
*
|
|
307
|
+
* type Query {
|
|
308
|
+
* media: [Media]
|
|
309
|
+
* }
|
|
310
|
+
* `);
|
|
311
|
+
*
|
|
312
|
+
* isUnionType(schema.getType('Media')); // => true
|
|
313
|
+
* isUnionType(schema.getType('Photo')); // => false
|
|
314
|
+
* ```
|
|
315
|
+
*/
|
|
30
316
|
export declare function isUnionType(type: unknown): type is GraphQLUnionType;
|
|
317
|
+
/**
|
|
318
|
+
* Returns the value as a GraphQLUnionType, or throws if it is not one.
|
|
319
|
+
* @param type - The GraphQL type to inspect.
|
|
320
|
+
* @returns The value typed as a GraphQLUnionType.
|
|
321
|
+
* @example
|
|
322
|
+
* ```ts
|
|
323
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
324
|
+
* import { assertUnionType } from 'graphql/type';
|
|
325
|
+
*
|
|
326
|
+
* const schema = buildSchema(`
|
|
327
|
+
* type Photo {
|
|
328
|
+
* url: String!
|
|
329
|
+
* }
|
|
330
|
+
*
|
|
331
|
+
* type Video {
|
|
332
|
+
* url: String!
|
|
333
|
+
* }
|
|
334
|
+
*
|
|
335
|
+
* union Media = Photo | Video
|
|
336
|
+
*
|
|
337
|
+
* type Query {
|
|
338
|
+
* media: [Media]
|
|
339
|
+
* }
|
|
340
|
+
* `);
|
|
341
|
+
*
|
|
342
|
+
* const mediaType = assertUnionType(schema.getType('Media'));
|
|
343
|
+
*
|
|
344
|
+
* mediaType.getTypes().map((type) => type.name); // => ['Photo', 'Video']
|
|
345
|
+
* assertUnionType(schema.getType('Photo')); // throws an error
|
|
346
|
+
* ```
|
|
347
|
+
*/
|
|
31
348
|
export declare function assertUnionType(type: unknown): GraphQLUnionType;
|
|
349
|
+
/**
|
|
350
|
+
* Returns true when the value is a GraphQLEnumType.
|
|
351
|
+
* @param type - The GraphQL type to inspect.
|
|
352
|
+
* @returns True when the value is a GraphQLEnumType.
|
|
353
|
+
* @example
|
|
354
|
+
* ```ts
|
|
355
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
356
|
+
* import { isEnumType } from 'graphql/type';
|
|
357
|
+
*
|
|
358
|
+
* const schema = buildSchema(`
|
|
359
|
+
* enum Episode {
|
|
360
|
+
* NEW_HOPE
|
|
361
|
+
* EMPIRE
|
|
362
|
+
* }
|
|
363
|
+
*
|
|
364
|
+
* type Query {
|
|
365
|
+
* favoriteEpisode: Episode
|
|
366
|
+
* }
|
|
367
|
+
* `);
|
|
368
|
+
*
|
|
369
|
+
* isEnumType(schema.getType('Episode')); // => true
|
|
370
|
+
* isEnumType(schema.getType('Query')); // => false
|
|
371
|
+
* ```
|
|
372
|
+
*/
|
|
32
373
|
export declare function isEnumType(type: unknown): type is GraphQLEnumType;
|
|
374
|
+
/**
|
|
375
|
+
* Returns the value as a GraphQLEnumType, or throws if it is not one.
|
|
376
|
+
* @param type - The GraphQL type to inspect.
|
|
377
|
+
* @returns The value typed as a GraphQLEnumType.
|
|
378
|
+
* @example
|
|
379
|
+
* ```ts
|
|
380
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
381
|
+
* import { assertEnumType } from 'graphql/type';
|
|
382
|
+
*
|
|
383
|
+
* const schema = buildSchema(`
|
|
384
|
+
* enum Episode {
|
|
385
|
+
* NEW_HOPE
|
|
386
|
+
* EMPIRE
|
|
387
|
+
* }
|
|
388
|
+
*
|
|
389
|
+
* type Query {
|
|
390
|
+
* favoriteEpisode: Episode
|
|
391
|
+
* }
|
|
392
|
+
* `);
|
|
393
|
+
*
|
|
394
|
+
* const episodeType = assertEnumType(schema.getType('Episode'));
|
|
395
|
+
*
|
|
396
|
+
* episodeType.getValues().map((value) => value.name); // => ['NEW_HOPE', 'EMPIRE']
|
|
397
|
+
* assertEnumType(schema.getType('Query')); // throws an error
|
|
398
|
+
* ```
|
|
399
|
+
*/
|
|
33
400
|
export declare function assertEnumType(type: unknown): GraphQLEnumType;
|
|
401
|
+
/**
|
|
402
|
+
* Returns true when the value is a resolved GraphQL enum value definition.
|
|
403
|
+
* @param value - Value to inspect.
|
|
404
|
+
* @returns True when the value is a GraphQLEnumValue.
|
|
405
|
+
* @example
|
|
406
|
+
* ```ts
|
|
407
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
408
|
+
* import { assertEnumType, isEnumValue } from 'graphql/type';
|
|
409
|
+
*
|
|
410
|
+
* const schema = buildSchema('enum Episode { NEW_HOPE } type Query { episode: Episode }');
|
|
411
|
+
* const enumValue = assertEnumType(schema.getType('Episode')).getValues()[0];
|
|
412
|
+
*
|
|
413
|
+
* isEnumValue(enumValue); // => true
|
|
414
|
+
* isEnumValue(schema.getType('Episode')); // => false
|
|
415
|
+
* ```
|
|
416
|
+
*/
|
|
34
417
|
export declare function isEnumValue(value: unknown): value is GraphQLEnumValue;
|
|
418
|
+
/**
|
|
419
|
+
* Returns the value as a GraphQLEnumValue, or throws if it is not one.
|
|
420
|
+
* @param value - Value to inspect.
|
|
421
|
+
* @returns The value typed as a GraphQLEnumValue.
|
|
422
|
+
* @example
|
|
423
|
+
* ```ts
|
|
424
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
425
|
+
* import { assertEnumType, assertEnumValue } from 'graphql/type';
|
|
426
|
+
*
|
|
427
|
+
* const schema = buildSchema('enum Episode { NEW_HOPE } type Query { episode: Episode }');
|
|
428
|
+
* const enumValue = assertEnumValue(
|
|
429
|
+
* assertEnumType(schema.getType('Episode')).getValues()[0],
|
|
430
|
+
* );
|
|
431
|
+
*
|
|
432
|
+
* enumValue.name; // => 'NEW_HOPE'
|
|
433
|
+
* assertEnumValue(schema.getType('Episode')); // throws an error
|
|
434
|
+
* ```
|
|
435
|
+
*/
|
|
35
436
|
export declare function assertEnumValue(value: unknown): GraphQLEnumValue;
|
|
437
|
+
/**
|
|
438
|
+
* Returns true when the value is a GraphQLInputObjectType.
|
|
439
|
+
* @param type - The GraphQL type to inspect.
|
|
440
|
+
* @returns True when the value is a GraphQLInputObjectType.
|
|
441
|
+
* @example
|
|
442
|
+
* ```ts
|
|
443
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
444
|
+
* import { isInputObjectType } from 'graphql/type';
|
|
445
|
+
*
|
|
446
|
+
* const schema = buildSchema(`
|
|
447
|
+
* input ReviewInput {
|
|
448
|
+
* stars: Int!
|
|
449
|
+
* }
|
|
450
|
+
*
|
|
451
|
+
* type Review {
|
|
452
|
+
* stars: Int!
|
|
453
|
+
* }
|
|
454
|
+
*
|
|
455
|
+
* type Query {
|
|
456
|
+
* review(input: ReviewInput): Review
|
|
457
|
+
* }
|
|
458
|
+
* `);
|
|
459
|
+
*
|
|
460
|
+
* isInputObjectType(schema.getType('ReviewInput')); // => true
|
|
461
|
+
* isInputObjectType(schema.getType('Review')); // => false
|
|
462
|
+
* ```
|
|
463
|
+
*/
|
|
36
464
|
export declare function isInputObjectType(type: unknown): type is GraphQLInputObjectType;
|
|
465
|
+
/**
|
|
466
|
+
* Returns the value as a GraphQLInputObjectType, or throws if it is not one.
|
|
467
|
+
* @param type - The GraphQL type to inspect.
|
|
468
|
+
* @returns The value typed as a GraphQLInputObjectType.
|
|
469
|
+
* @example
|
|
470
|
+
* ```ts
|
|
471
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
472
|
+
* import { assertInputObjectType } from 'graphql/type';
|
|
473
|
+
*
|
|
474
|
+
* const schema = buildSchema(`
|
|
475
|
+
* input ReviewInput {
|
|
476
|
+
* stars: Int!
|
|
477
|
+
* }
|
|
478
|
+
*
|
|
479
|
+
* type Review {
|
|
480
|
+
* stars: Int!
|
|
481
|
+
* }
|
|
482
|
+
*
|
|
483
|
+
* type Query {
|
|
484
|
+
* review(input: ReviewInput): Review
|
|
485
|
+
* }
|
|
486
|
+
* `);
|
|
487
|
+
*
|
|
488
|
+
* const inputType = assertInputObjectType(schema.getType('ReviewInput'));
|
|
489
|
+
*
|
|
490
|
+
* Object.keys(inputType.getFields()); // => ['stars']
|
|
491
|
+
* assertInputObjectType(schema.getType('Review')); // throws an error
|
|
492
|
+
* ```
|
|
493
|
+
*/
|
|
37
494
|
export declare function assertInputObjectType(type: unknown): GraphQLInputObjectType;
|
|
495
|
+
/**
|
|
496
|
+
* Returns true when the value is a resolved GraphQL input field definition.
|
|
497
|
+
* @param field - Value to inspect.
|
|
498
|
+
* @returns True when the value is a GraphQLInputField.
|
|
499
|
+
* @example
|
|
500
|
+
* ```ts
|
|
501
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
502
|
+
* import { assertInputObjectType, isInputField } from 'graphql/type';
|
|
503
|
+
*
|
|
504
|
+
* const schema = buildSchema('input ReviewInput { stars: Int } type Query { ok: Boolean }');
|
|
505
|
+
* const inputField = assertInputObjectType(schema.getType('ReviewInput')).getFields().stars;
|
|
506
|
+
*
|
|
507
|
+
* isInputField(inputField); // => true
|
|
508
|
+
* isInputField(schema.getQueryType()); // => false
|
|
509
|
+
* ```
|
|
510
|
+
*/
|
|
38
511
|
export declare function isInputField(field: unknown): field is GraphQLInputField;
|
|
512
|
+
/**
|
|
513
|
+
* Returns the value as a GraphQLInputField, or throws if it is not one.
|
|
514
|
+
* @param field - Value to inspect.
|
|
515
|
+
* @returns The value typed as a GraphQLInputField.
|
|
516
|
+
* @example
|
|
517
|
+
* ```ts
|
|
518
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
519
|
+
* import { assertInputField, assertInputObjectType } from 'graphql/type';
|
|
520
|
+
*
|
|
521
|
+
* const schema = buildSchema('input ReviewInput { stars: Int } type Query { ok: Boolean }');
|
|
522
|
+
* const inputField = assertInputField(
|
|
523
|
+
* assertInputObjectType(schema.getType('ReviewInput')).getFields().stars,
|
|
524
|
+
* );
|
|
525
|
+
*
|
|
526
|
+
* inputField.name; // => 'stars'
|
|
527
|
+
* assertInputField(schema.getQueryType()); // throws an error
|
|
528
|
+
* ```
|
|
529
|
+
*/
|
|
39
530
|
export declare function assertInputField(field: unknown): GraphQLInputField;
|
|
531
|
+
/**
|
|
532
|
+
* Returns true when the value is a GraphQLList.
|
|
533
|
+
* @param type - The GraphQL type to inspect.
|
|
534
|
+
* @returns True when the value is a GraphQLList.
|
|
535
|
+
* @example
|
|
536
|
+
* ```ts
|
|
537
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
538
|
+
* import { GraphQLList, GraphQLString, isListType } from 'graphql/type';
|
|
539
|
+
*
|
|
540
|
+
* const schema = buildSchema(`
|
|
541
|
+
* type Query {
|
|
542
|
+
* tags: [String!]!
|
|
543
|
+
* }
|
|
544
|
+
* `);
|
|
545
|
+
*
|
|
546
|
+
* const tagsField = schema.getQueryType()?.getFields().tags;
|
|
547
|
+
*
|
|
548
|
+
* isListType(new GraphQLList(GraphQLString)); // => true
|
|
549
|
+
* isListType(GraphQLString); // => false
|
|
550
|
+
* isListType(tagsField?.type); // => false
|
|
551
|
+
* ```
|
|
552
|
+
*/
|
|
40
553
|
export declare function isListType(type: GraphQLInputType): type is GraphQLList<GraphQLInputType>;
|
|
554
|
+
/**
|
|
555
|
+
* Returns true when the output type is a GraphQLList.
|
|
556
|
+
* @param type - The GraphQL output type to inspect.
|
|
557
|
+
* @returns True when the output type is a list type.
|
|
558
|
+
* @example
|
|
559
|
+
* ```ts
|
|
560
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
561
|
+
* import { getNullableType, isListType } from 'graphql/type';
|
|
562
|
+
*
|
|
563
|
+
* const schema = buildSchema(`
|
|
564
|
+
* type Query {
|
|
565
|
+
* tags: [String!]!
|
|
566
|
+
* }
|
|
567
|
+
* `);
|
|
568
|
+
*
|
|
569
|
+
* const tagsField = schema.getQueryType()?.getFields().tags;
|
|
570
|
+
* const nullableTagsType = getNullableType(tagsField?.type);
|
|
571
|
+
*
|
|
572
|
+
* isListType(nullableTagsType); // => true
|
|
573
|
+
* ```
|
|
574
|
+
*/
|
|
41
575
|
export declare function isListType(type: GraphQLOutputType): type is GraphQLList<GraphQLOutputType>;
|
|
576
|
+
/**
|
|
577
|
+
* Returns true when the value is a GraphQLList.
|
|
578
|
+
* @param type - The value to inspect.
|
|
579
|
+
* @returns True when the value is a list type.
|
|
580
|
+
* @example
|
|
581
|
+
* ```ts
|
|
582
|
+
* import { isListType } from 'graphql/type';
|
|
583
|
+
*
|
|
584
|
+
* isListType('[String]'); // => false
|
|
585
|
+
* isListType(null); // => false
|
|
586
|
+
* ```
|
|
587
|
+
*/
|
|
42
588
|
export declare function isListType(type: unknown): type is GraphQLList<GraphQLType>;
|
|
589
|
+
/**
|
|
590
|
+
* Returns the value as a GraphQLList, or throws if it is not one.
|
|
591
|
+
* @param type - The GraphQL type to inspect.
|
|
592
|
+
* @returns The value typed as a GraphQLList.
|
|
593
|
+
* @example
|
|
594
|
+
* ```ts
|
|
595
|
+
* import { GraphQLList, GraphQLString, assertListType } from 'graphql/type';
|
|
596
|
+
*
|
|
597
|
+
* const listType = assertListType(new GraphQLList(GraphQLString));
|
|
598
|
+
*
|
|
599
|
+
* listType.ofType; // => GraphQLString
|
|
600
|
+
* assertListType(GraphQLString); // throws an error
|
|
601
|
+
* ```
|
|
602
|
+
*/
|
|
43
603
|
export declare function assertListType(type: unknown): GraphQLList<GraphQLType>;
|
|
604
|
+
/**
|
|
605
|
+
* Returns true when the value is a GraphQLNonNull.
|
|
606
|
+
* @param type - The GraphQL type to inspect.
|
|
607
|
+
* @returns True when the value is a GraphQLNonNull.
|
|
608
|
+
* @example
|
|
609
|
+
* ```ts
|
|
610
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
611
|
+
* import { GraphQLNonNull, GraphQLString, isNonNullType } from 'graphql/type';
|
|
612
|
+
*
|
|
613
|
+
* const schema = buildSchema(`
|
|
614
|
+
* type Query {
|
|
615
|
+
* name: String!
|
|
616
|
+
* nickname: String
|
|
617
|
+
* }
|
|
618
|
+
* `);
|
|
619
|
+
*
|
|
620
|
+
* const fields = schema.getQueryType()?.getFields();
|
|
621
|
+
*
|
|
622
|
+
* isNonNullType(new GraphQLNonNull(GraphQLString)); // => true
|
|
623
|
+
* isNonNullType(fields?.name.type); // => true
|
|
624
|
+
* isNonNullType(fields?.nickname.type); // => false
|
|
625
|
+
* ```
|
|
626
|
+
*/
|
|
44
627
|
export declare function isNonNullType(type: GraphQLInputType): type is GraphQLNonNull<GraphQLNullableInputType>;
|
|
628
|
+
/**
|
|
629
|
+
* Returns true when the output type is a GraphQLNonNull.
|
|
630
|
+
* @param type - The GraphQL output type to inspect.
|
|
631
|
+
* @returns True when the output type is a non-null type.
|
|
632
|
+
* @example
|
|
633
|
+
* ```ts
|
|
634
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
635
|
+
* import { isNonNullType } from 'graphql/type';
|
|
636
|
+
*
|
|
637
|
+
* const schema = buildSchema(`
|
|
638
|
+
* type Query {
|
|
639
|
+
* name: String!
|
|
640
|
+
* nickname: String
|
|
641
|
+
* }
|
|
642
|
+
* `);
|
|
643
|
+
*
|
|
644
|
+
* const fields = schema.getQueryType()?.getFields();
|
|
645
|
+
*
|
|
646
|
+
* isNonNullType(fields?.name.type); // => true
|
|
647
|
+
* isNonNullType(fields?.nickname.type); // => false
|
|
648
|
+
* ```
|
|
649
|
+
*/
|
|
45
650
|
export declare function isNonNullType(type: GraphQLOutputType): type is GraphQLNonNull<GraphQLNullableOutputType>;
|
|
651
|
+
/**
|
|
652
|
+
* Returns true when the value is a GraphQLNonNull.
|
|
653
|
+
* @param type - The value to inspect.
|
|
654
|
+
* @returns True when the value is a non-null type.
|
|
655
|
+
* @example
|
|
656
|
+
* ```ts
|
|
657
|
+
* import { isNonNullType } from 'graphql/type';
|
|
658
|
+
*
|
|
659
|
+
* isNonNullType('String!'); // => false
|
|
660
|
+
* isNonNullType(null); // => false
|
|
661
|
+
* ```
|
|
662
|
+
*/
|
|
46
663
|
export declare function isNonNullType(type: unknown): type is GraphQLNonNull<GraphQLNullableType>;
|
|
47
|
-
export declare function assertNonNullType(type: unknown): GraphQLNonNull<GraphQLNullableType>;
|
|
48
664
|
/**
|
|
49
|
-
*
|
|
665
|
+
* Returns the value as a GraphQLNonNull, or throws if it is not one.
|
|
666
|
+
* @param type - The GraphQL type to inspect.
|
|
667
|
+
* @returns The value typed as a GraphQLNonNull.
|
|
668
|
+
* @example
|
|
669
|
+
* ```ts
|
|
670
|
+
* import { GraphQLNonNull, GraphQLString, assertNonNullType } from 'graphql/type';
|
|
671
|
+
*
|
|
672
|
+
* const nonNullType = assertNonNullType(new GraphQLNonNull(GraphQLString));
|
|
673
|
+
*
|
|
674
|
+
* nonNullType.ofType; // => GraphQLString
|
|
675
|
+
* assertNonNullType(GraphQLString); // throws an error
|
|
676
|
+
* ```
|
|
50
677
|
*/
|
|
678
|
+
export declare function assertNonNullType(type: unknown): GraphQLNonNull<GraphQLNullableType>;
|
|
679
|
+
/** These types may be used as input types for arguments and directives. */
|
|
51
680
|
export type GraphQLNullableInputType = GraphQLNamedInputType | GraphQLList<GraphQLInputType>;
|
|
681
|
+
/** These types may be used as input types for arguments and directives. */
|
|
52
682
|
export type GraphQLInputType = GraphQLNullableInputType | GraphQLNonNull<GraphQLNullableInputType>;
|
|
683
|
+
/**
|
|
684
|
+
* Returns true when the value can be used as a GraphQL input type.
|
|
685
|
+
* @param type - The GraphQL type to inspect.
|
|
686
|
+
* @returns True when the value can be used as a GraphQL input type.
|
|
687
|
+
* @example
|
|
688
|
+
* ```ts
|
|
689
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
690
|
+
* import { isInputType } from 'graphql/type';
|
|
691
|
+
*
|
|
692
|
+
* const schema = buildSchema(`
|
|
693
|
+
* input ReviewInput {
|
|
694
|
+
* stars: Int!
|
|
695
|
+
* }
|
|
696
|
+
*
|
|
697
|
+
* type Review {
|
|
698
|
+
* stars: Int!
|
|
699
|
+
* }
|
|
700
|
+
*
|
|
701
|
+
* type Query {
|
|
702
|
+
* review(input: ReviewInput): Review
|
|
703
|
+
* }
|
|
704
|
+
* `);
|
|
705
|
+
*
|
|
706
|
+
* isInputType(schema.getType('ReviewInput')); // => true
|
|
707
|
+
* isInputType(schema.getType('Review')); // => false
|
|
708
|
+
* ```
|
|
709
|
+
*/
|
|
53
710
|
export declare function isInputType(type: unknown): type is GraphQLInputType;
|
|
54
|
-
export declare function assertInputType(type: unknown): GraphQLInputType;
|
|
55
711
|
/**
|
|
56
|
-
*
|
|
712
|
+
* Returns the value as a GraphQL input type, or throws if it is not one.
|
|
713
|
+
* @param type - The GraphQL type to inspect.
|
|
714
|
+
* @returns The value typed as a GraphQL input type.
|
|
715
|
+
* @example
|
|
716
|
+
* ```ts
|
|
717
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
718
|
+
* import { assertInputType } from 'graphql/type';
|
|
719
|
+
*
|
|
720
|
+
* const schema = buildSchema(`
|
|
721
|
+
* input ReviewInput {
|
|
722
|
+
* stars: Int!
|
|
723
|
+
* }
|
|
724
|
+
*
|
|
725
|
+
* type Review {
|
|
726
|
+
* stars: Int!
|
|
727
|
+
* }
|
|
728
|
+
*
|
|
729
|
+
* type Query {
|
|
730
|
+
* review(input: ReviewInput): Review
|
|
731
|
+
* }
|
|
732
|
+
* `);
|
|
733
|
+
*
|
|
734
|
+
* const inputType = assertInputType(schema.getType('ReviewInput'));
|
|
735
|
+
*
|
|
736
|
+
* inputType.toString(); // => 'ReviewInput'
|
|
737
|
+
* assertInputType(schema.getType('Review')); // throws an error
|
|
738
|
+
* ```
|
|
57
739
|
*/
|
|
740
|
+
export declare function assertInputType(type: unknown): GraphQLInputType;
|
|
741
|
+
/** These types may be used as output types as the result of fields. */
|
|
58
742
|
export type GraphQLNullableOutputType = GraphQLNamedOutputType | GraphQLList<GraphQLOutputType>;
|
|
743
|
+
/** These types may be used as output types as the result of fields. */
|
|
59
744
|
export type GraphQLOutputType = GraphQLNullableOutputType | GraphQLNonNull<GraphQLNullableOutputType>;
|
|
745
|
+
/**
|
|
746
|
+
* Returns true when the value can be used as a GraphQL output type.
|
|
747
|
+
* @param type - The GraphQL type to inspect.
|
|
748
|
+
* @returns True when the value can be used as a GraphQL output type.
|
|
749
|
+
* @example
|
|
750
|
+
* ```ts
|
|
751
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
752
|
+
* import { isOutputType } from 'graphql/type';
|
|
753
|
+
*
|
|
754
|
+
* const schema = buildSchema(`
|
|
755
|
+
* input ReviewInput {
|
|
756
|
+
* stars: Int!
|
|
757
|
+
* }
|
|
758
|
+
*
|
|
759
|
+
* type Review {
|
|
760
|
+
* stars: Int!
|
|
761
|
+
* }
|
|
762
|
+
*
|
|
763
|
+
* type Query {
|
|
764
|
+
* review(input: ReviewInput): Review
|
|
765
|
+
* }
|
|
766
|
+
* `);
|
|
767
|
+
*
|
|
768
|
+
* isOutputType(schema.getType('Review')); // => true
|
|
769
|
+
* isOutputType(schema.getType('ReviewInput')); // => false
|
|
770
|
+
* ```
|
|
771
|
+
*/
|
|
60
772
|
export declare function isOutputType(type: unknown): type is GraphQLOutputType;
|
|
61
|
-
export declare function assertOutputType(type: unknown): GraphQLOutputType;
|
|
62
773
|
/**
|
|
63
|
-
*
|
|
774
|
+
* Returns the value as a GraphQL output type, or throws if it is not one.
|
|
775
|
+
* @param type - The GraphQL type to inspect.
|
|
776
|
+
* @returns The value typed as a GraphQL output type.
|
|
777
|
+
* @example
|
|
778
|
+
* ```ts
|
|
779
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
780
|
+
* import { assertOutputType } from 'graphql/type';
|
|
781
|
+
*
|
|
782
|
+
* const schema = buildSchema(`
|
|
783
|
+
* input ReviewInput {
|
|
784
|
+
* stars: Int!
|
|
785
|
+
* }
|
|
786
|
+
*
|
|
787
|
+
* type Review {
|
|
788
|
+
* stars: Int!
|
|
789
|
+
* }
|
|
790
|
+
*
|
|
791
|
+
* type Query {
|
|
792
|
+
* review(input: ReviewInput): Review
|
|
793
|
+
* }
|
|
794
|
+
* `);
|
|
795
|
+
*
|
|
796
|
+
* const outputType = assertOutputType(schema.getType('Review'));
|
|
797
|
+
*
|
|
798
|
+
* outputType.toString(); // => 'Review'
|
|
799
|
+
* assertOutputType(schema.getType('ReviewInput')); // throws an error
|
|
800
|
+
* ```
|
|
64
801
|
*/
|
|
802
|
+
export declare function assertOutputType(type: unknown): GraphQLOutputType;
|
|
803
|
+
/** These types may describe types which may be leaf values. */
|
|
65
804
|
export type GraphQLLeafType = GraphQLScalarType | GraphQLEnumType;
|
|
805
|
+
/**
|
|
806
|
+
* Returns true when the value is a GraphQL scalar or enum type.
|
|
807
|
+
* @param type - The GraphQL type to inspect.
|
|
808
|
+
* @returns True when the value is a GraphQL scalar or enum type.
|
|
809
|
+
* @example
|
|
810
|
+
* ```ts
|
|
811
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
812
|
+
* import { isLeafType } from 'graphql/type';
|
|
813
|
+
*
|
|
814
|
+
* const schema = buildSchema(`
|
|
815
|
+
* enum Episode {
|
|
816
|
+
* NEW_HOPE
|
|
817
|
+
* }
|
|
818
|
+
*
|
|
819
|
+
* type Review {
|
|
820
|
+
* stars: Int!
|
|
821
|
+
* }
|
|
822
|
+
*
|
|
823
|
+
* type Query {
|
|
824
|
+
* episode: Episode
|
|
825
|
+
* review: Review
|
|
826
|
+
* }
|
|
827
|
+
* `);
|
|
828
|
+
*
|
|
829
|
+
* isLeafType(schema.getType('Episode')); // => true
|
|
830
|
+
* isLeafType(schema.getType('String')); // => true
|
|
831
|
+
* isLeafType(schema.getType('Review')); // => false
|
|
832
|
+
* ```
|
|
833
|
+
*/
|
|
66
834
|
export declare function isLeafType(type: unknown): type is GraphQLLeafType;
|
|
67
|
-
export declare function assertLeafType(type: unknown): GraphQLLeafType;
|
|
68
835
|
/**
|
|
69
|
-
*
|
|
836
|
+
* Returns the value as a GraphQL leaf type, or throws if it is not one.
|
|
837
|
+
* @param type - The GraphQL type to inspect.
|
|
838
|
+
* @returns The value typed as a GraphQL leaf type.
|
|
839
|
+
* @example
|
|
840
|
+
* ```ts
|
|
841
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
842
|
+
* import { assertLeafType } from 'graphql/type';
|
|
843
|
+
*
|
|
844
|
+
* const schema = buildSchema(`
|
|
845
|
+
* enum Episode {
|
|
846
|
+
* NEW_HOPE
|
|
847
|
+
* }
|
|
848
|
+
*
|
|
849
|
+
* type Review {
|
|
850
|
+
* stars: Int!
|
|
851
|
+
* }
|
|
852
|
+
*
|
|
853
|
+
* type Query {
|
|
854
|
+
* episode: Episode
|
|
855
|
+
* review: Review
|
|
856
|
+
* }
|
|
857
|
+
* `);
|
|
858
|
+
*
|
|
859
|
+
* const episodeType = assertLeafType(schema.getType('Episode'));
|
|
860
|
+
*
|
|
861
|
+
* episodeType.toString(); // => 'Episode'
|
|
862
|
+
* assertLeafType(schema.getType('Review')); // throws an error
|
|
863
|
+
* ```
|
|
70
864
|
*/
|
|
865
|
+
export declare function assertLeafType(type: unknown): GraphQLLeafType;
|
|
866
|
+
/** These types may describe the parent context of a selection set. */
|
|
71
867
|
export type GraphQLCompositeType = GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType;
|
|
868
|
+
/**
|
|
869
|
+
* Returns true when the value is a GraphQL object, interface, or union type.
|
|
870
|
+
* @param type - The GraphQL type to inspect.
|
|
871
|
+
* @returns True when the value is a GraphQL object, interface, or union type.
|
|
872
|
+
* @example
|
|
873
|
+
* ```ts
|
|
874
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
875
|
+
* import { isCompositeType } from 'graphql/type';
|
|
876
|
+
*
|
|
877
|
+
* const schema = buildSchema(`
|
|
878
|
+
* interface Node {
|
|
879
|
+
* id: ID!
|
|
880
|
+
* }
|
|
881
|
+
*
|
|
882
|
+
* type User implements Node {
|
|
883
|
+
* id: ID!
|
|
884
|
+
* }
|
|
885
|
+
*
|
|
886
|
+
* union SearchResult = User
|
|
887
|
+
*
|
|
888
|
+
* type Query {
|
|
889
|
+
* node: Node
|
|
890
|
+
* search: [SearchResult]
|
|
891
|
+
* }
|
|
892
|
+
* `);
|
|
893
|
+
*
|
|
894
|
+
* isCompositeType(schema.getType('User')); // => true
|
|
895
|
+
* isCompositeType(schema.getType('Node')); // => true
|
|
896
|
+
* isCompositeType(schema.getType('SearchResult')); // => true
|
|
897
|
+
* isCompositeType(schema.getType('String')); // => false
|
|
898
|
+
* ```
|
|
899
|
+
*/
|
|
72
900
|
export declare function isCompositeType(type: unknown): type is GraphQLCompositeType;
|
|
73
|
-
export declare function assertCompositeType(type: unknown): GraphQLCompositeType;
|
|
74
901
|
/**
|
|
75
|
-
*
|
|
902
|
+
* Returns the value as a GraphQL composite type, or throws if it is not one.
|
|
903
|
+
* @param type - The GraphQL type to inspect.
|
|
904
|
+
* @returns The value typed as a GraphQL composite type.
|
|
905
|
+
* @example
|
|
906
|
+
* ```ts
|
|
907
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
908
|
+
* import { assertCompositeType } from 'graphql/type';
|
|
909
|
+
*
|
|
910
|
+
* const schema = buildSchema(`
|
|
911
|
+
* interface Node {
|
|
912
|
+
* id: ID!
|
|
913
|
+
* }
|
|
914
|
+
*
|
|
915
|
+
* type User implements Node {
|
|
916
|
+
* id: ID!
|
|
917
|
+
* }
|
|
918
|
+
*
|
|
919
|
+
* type Query {
|
|
920
|
+
* node: Node
|
|
921
|
+
* }
|
|
922
|
+
* `);
|
|
923
|
+
*
|
|
924
|
+
* const userType = assertCompositeType(schema.getType('User'));
|
|
925
|
+
*
|
|
926
|
+
* userType.toString(); // => 'User'
|
|
927
|
+
* assertCompositeType(schema.getType('String')); // throws an error
|
|
928
|
+
* ```
|
|
76
929
|
*/
|
|
930
|
+
export declare function assertCompositeType(type: unknown): GraphQLCompositeType;
|
|
931
|
+
/** These types may describe the parent context of a selection set. */
|
|
77
932
|
export type GraphQLAbstractType = GraphQLInterfaceType | GraphQLUnionType;
|
|
933
|
+
/**
|
|
934
|
+
* Returns true when the value is a GraphQL interface or union type.
|
|
935
|
+
* @param type - The GraphQL type to inspect.
|
|
936
|
+
* @returns True when the value is a GraphQL interface or union type.
|
|
937
|
+
* @example
|
|
938
|
+
* ```ts
|
|
939
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
940
|
+
* import { isAbstractType } from 'graphql/type';
|
|
941
|
+
*
|
|
942
|
+
* const schema = buildSchema(`
|
|
943
|
+
* interface Node {
|
|
944
|
+
* id: ID!
|
|
945
|
+
* }
|
|
946
|
+
*
|
|
947
|
+
* type User implements Node {
|
|
948
|
+
* id: ID!
|
|
949
|
+
* }
|
|
950
|
+
*
|
|
951
|
+
* union SearchResult = User
|
|
952
|
+
*
|
|
953
|
+
* type Query {
|
|
954
|
+
* node: Node
|
|
955
|
+
* search: [SearchResult]
|
|
956
|
+
* }
|
|
957
|
+
* `);
|
|
958
|
+
*
|
|
959
|
+
* isAbstractType(schema.getType('Node')); // => true
|
|
960
|
+
* isAbstractType(schema.getType('SearchResult')); // => true
|
|
961
|
+
* isAbstractType(schema.getType('User')); // => false
|
|
962
|
+
* ```
|
|
963
|
+
*/
|
|
78
964
|
export declare function isAbstractType(type: unknown): type is GraphQLAbstractType;
|
|
965
|
+
/**
|
|
966
|
+
* Returns the value as a GraphQL abstract type, or throws if it is not one.
|
|
967
|
+
* @param type - The GraphQL type to inspect.
|
|
968
|
+
* @returns The value typed as a GraphQL abstract type.
|
|
969
|
+
* @example
|
|
970
|
+
* ```ts
|
|
971
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
972
|
+
* import { assertAbstractType } from 'graphql/type';
|
|
973
|
+
*
|
|
974
|
+
* const schema = buildSchema(`
|
|
975
|
+
* interface Node {
|
|
976
|
+
* id: ID!
|
|
977
|
+
* }
|
|
978
|
+
*
|
|
979
|
+
* type User implements Node {
|
|
980
|
+
* id: ID!
|
|
981
|
+
* }
|
|
982
|
+
*
|
|
983
|
+
* type Query {
|
|
984
|
+
* node: Node
|
|
985
|
+
* }
|
|
986
|
+
* `);
|
|
987
|
+
*
|
|
988
|
+
* const nodeType = assertAbstractType(schema.getType('Node'));
|
|
989
|
+
*
|
|
990
|
+
* nodeType.toString(); // => 'Node'
|
|
991
|
+
* assertAbstractType(schema.getType('User')); // throws an error
|
|
992
|
+
* ```
|
|
993
|
+
*/
|
|
79
994
|
export declare function assertAbstractType(type: unknown): GraphQLAbstractType;
|
|
80
995
|
/**
|
|
81
996
|
* List Type Wrapper
|
|
@@ -83,9 +998,8 @@ export declare function assertAbstractType(type: unknown): GraphQLAbstractType;
|
|
|
83
998
|
* A list is a wrapping type which points to another type.
|
|
84
999
|
* Lists are often created within the context of defining the fields of
|
|
85
1000
|
* an object type.
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
1001
|
+
* @typeParam T - The GraphQL type wrapped by this list type.
|
|
1002
|
+
* @example
|
|
89
1003
|
* ```ts
|
|
90
1004
|
* const PersonType = new GraphQLObjectType({
|
|
91
1005
|
* name: 'Person',
|
|
@@ -97,11 +1011,56 @@ export declare function assertAbstractType(type: unknown): GraphQLAbstractType;
|
|
|
97
1011
|
* ```
|
|
98
1012
|
*/
|
|
99
1013
|
export declare class GraphQLList<T extends GraphQLType> implements GraphQLSchemaElement {
|
|
100
|
-
|
|
1014
|
+
/** The type wrapped by this list or non-null type. */
|
|
101
1015
|
readonly ofType: T;
|
|
1016
|
+
private readonly __GraphQLListTypeBrand;
|
|
1017
|
+
/**
|
|
1018
|
+
* Creates a GraphQLList instance.
|
|
1019
|
+
* @param ofType - The type to wrap.
|
|
1020
|
+
* @example
|
|
1021
|
+
* ```ts
|
|
1022
|
+
* import { GraphQLList, GraphQLString } from 'graphql/type';
|
|
1023
|
+
*
|
|
1024
|
+
* const stringList = new GraphQLList(GraphQLString);
|
|
1025
|
+
*
|
|
1026
|
+
* stringList.ofType; // => GraphQLString
|
|
1027
|
+
* String(stringList); // => '[String]'
|
|
1028
|
+
* ```
|
|
1029
|
+
*/
|
|
102
1030
|
constructor(ofType: T);
|
|
1031
|
+
/**
|
|
1032
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
1033
|
+
* @returns The built-in string tag for this object.
|
|
1034
|
+
*/
|
|
103
1035
|
get [Symbol.toStringTag](): string;
|
|
1036
|
+
/**
|
|
1037
|
+
* Returns this wrapping type as a GraphQL type-reference string.
|
|
1038
|
+
* @returns The GraphQL type-reference string.
|
|
1039
|
+
* @example
|
|
1040
|
+
* ```ts
|
|
1041
|
+
* import { GraphQLList, GraphQLNonNull, GraphQLString } from 'graphql/type';
|
|
1042
|
+
*
|
|
1043
|
+
* const stringList = new GraphQLList(GraphQLString);
|
|
1044
|
+
* const requiredStringList = new GraphQLList(new GraphQLNonNull(GraphQLString));
|
|
1045
|
+
*
|
|
1046
|
+
* stringList.toString(); // => '[String]'
|
|
1047
|
+
* requiredStringList.toString(); // => '[String!]'
|
|
1048
|
+
* ```
|
|
1049
|
+
*/
|
|
104
1050
|
toString(): string;
|
|
1051
|
+
/**
|
|
1052
|
+
* Returns the JSON representation used when this object is serialized.
|
|
1053
|
+
* @returns The JSON-serializable representation.
|
|
1054
|
+
* @example
|
|
1055
|
+
* ```ts
|
|
1056
|
+
* import { GraphQLList, GraphQLString } from 'graphql/type';
|
|
1057
|
+
*
|
|
1058
|
+
* const stringList = new GraphQLList(GraphQLString);
|
|
1059
|
+
*
|
|
1060
|
+
* stringList.toJSON(); // => '[String]'
|
|
1061
|
+
* JSON.stringify({ type: stringList }); // => '{"type":"[String]"}'
|
|
1062
|
+
* ```
|
|
1063
|
+
*/
|
|
105
1064
|
toJSON(): string;
|
|
106
1065
|
}
|
|
107
1066
|
/**
|
|
@@ -112,9 +1071,8 @@ export declare class GraphQLList<T extends GraphQLType> implements GraphQLSchema
|
|
|
112
1071
|
* an error is raised if this ever occurs during a request. It is useful for
|
|
113
1072
|
* fields which you can make a strong guarantee on non-nullability, for example
|
|
114
1073
|
* usually the id field of a database row will never be null.
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
1074
|
+
* @typeParam T - The nullable GraphQL type wrapped by this non-null type.
|
|
1075
|
+
* @example
|
|
118
1076
|
* ```ts
|
|
119
1077
|
* const RowType = new GraphQLObjectType({
|
|
120
1078
|
* name: 'Row',
|
|
@@ -123,46 +1081,332 @@ export declare class GraphQLList<T extends GraphQLType> implements GraphQLSchema
|
|
|
123
1081
|
* })
|
|
124
1082
|
* })
|
|
125
1083
|
* ```
|
|
1084
|
+
*
|
|
126
1085
|
* Note: the enforcement of non-nullability occurs within the executor.
|
|
127
1086
|
*/
|
|
128
1087
|
export declare class GraphQLNonNull<T extends GraphQLNullableType> implements GraphQLSchemaElement {
|
|
129
|
-
|
|
1088
|
+
/** The type wrapped by this list or non-null type. */
|
|
130
1089
|
readonly ofType: T;
|
|
1090
|
+
private readonly __GraphQLNonNullTypeBrand;
|
|
1091
|
+
/**
|
|
1092
|
+
* Creates a GraphQLNonNull instance.
|
|
1093
|
+
* @param ofType - The type to wrap.
|
|
1094
|
+
* @example
|
|
1095
|
+
* ```ts
|
|
1096
|
+
* import { GraphQLNonNull, GraphQLString } from 'graphql/type';
|
|
1097
|
+
*
|
|
1098
|
+
* const requiredString = new GraphQLNonNull(GraphQLString);
|
|
1099
|
+
*
|
|
1100
|
+
* requiredString.ofType; // => GraphQLString
|
|
1101
|
+
* String(requiredString); // => 'String!'
|
|
1102
|
+
* ```
|
|
1103
|
+
*/
|
|
131
1104
|
constructor(ofType: T);
|
|
1105
|
+
/**
|
|
1106
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
1107
|
+
* @returns The built-in string tag for this object.
|
|
1108
|
+
*/
|
|
132
1109
|
get [Symbol.toStringTag](): string;
|
|
1110
|
+
/**
|
|
1111
|
+
* Returns this wrapping type as a GraphQL type-reference string.
|
|
1112
|
+
* @returns The GraphQL type-reference string.
|
|
1113
|
+
* @example
|
|
1114
|
+
* ```ts
|
|
1115
|
+
* import { GraphQLList, GraphQLNonNull, GraphQLString } from 'graphql/type';
|
|
1116
|
+
*
|
|
1117
|
+
* const requiredString = new GraphQLNonNull(GraphQLString);
|
|
1118
|
+
* const requiredStringList = new GraphQLNonNull(
|
|
1119
|
+
* new GraphQLList(GraphQLString),
|
|
1120
|
+
* );
|
|
1121
|
+
*
|
|
1122
|
+
* requiredString.toString(); // => 'String!'
|
|
1123
|
+
* requiredStringList.toString(); // => '[String]!'
|
|
1124
|
+
* ```
|
|
1125
|
+
*/
|
|
133
1126
|
toString(): string;
|
|
1127
|
+
/**
|
|
1128
|
+
* Returns the JSON representation used when this object is serialized.
|
|
1129
|
+
* @returns The JSON-serializable representation.
|
|
1130
|
+
* @example
|
|
1131
|
+
* ```ts
|
|
1132
|
+
* import { GraphQLNonNull, GraphQLString } from 'graphql/type';
|
|
1133
|
+
*
|
|
1134
|
+
* const requiredString = new GraphQLNonNull(GraphQLString);
|
|
1135
|
+
*
|
|
1136
|
+
* requiredString.toJSON(); // => 'String!'
|
|
1137
|
+
* JSON.stringify({ type: requiredString }); // => '{"type":"String!"}'
|
|
1138
|
+
* ```
|
|
1139
|
+
*/
|
|
134
1140
|
toJSON(): string;
|
|
135
1141
|
}
|
|
1142
|
+
/** These types wrap and modify other types */
|
|
1143
|
+
export type GraphQLWrappingType = GraphQLList<GraphQLType> | GraphQLNonNull<GraphQLNullableType>;
|
|
136
1144
|
/**
|
|
137
|
-
*
|
|
1145
|
+
* Returns true when the value is a GraphQL list or non-null wrapper type.
|
|
1146
|
+
* @param type - The GraphQL type to inspect.
|
|
1147
|
+
* @returns True when the value is a GraphQL list or non-null wrapper type.
|
|
1148
|
+
* @example
|
|
1149
|
+
* ```ts
|
|
1150
|
+
* import {
|
|
1151
|
+
* GraphQLList,
|
|
1152
|
+
* GraphQLNonNull,
|
|
1153
|
+
* GraphQLString,
|
|
1154
|
+
* isWrappingType,
|
|
1155
|
+
* } from 'graphql/type';
|
|
1156
|
+
*
|
|
1157
|
+
* isWrappingType(new GraphQLList(GraphQLString)); // => true
|
|
1158
|
+
* isWrappingType(new GraphQLNonNull(GraphQLString)); // => true
|
|
1159
|
+
* isWrappingType(GraphQLString); // => false
|
|
1160
|
+
* ```
|
|
138
1161
|
*/
|
|
139
|
-
export type GraphQLWrappingType = GraphQLList<GraphQLType> | GraphQLNonNull<GraphQLNullableType>;
|
|
140
1162
|
export declare function isWrappingType(type: unknown): type is GraphQLWrappingType;
|
|
141
|
-
export declare function assertWrappingType(type: unknown): GraphQLWrappingType;
|
|
142
1163
|
/**
|
|
143
|
-
*
|
|
1164
|
+
* Returns the value as a GraphQL wrapping type, or throws if it is not one.
|
|
1165
|
+
* @param type - The GraphQL type to inspect.
|
|
1166
|
+
* @returns The value typed as a GraphQL wrapping type.
|
|
1167
|
+
* @example
|
|
1168
|
+
* ```ts
|
|
1169
|
+
* import { GraphQLList, GraphQLString, assertWrappingType } from 'graphql/type';
|
|
1170
|
+
*
|
|
1171
|
+
* const wrappingType = assertWrappingType(new GraphQLList(GraphQLString));
|
|
1172
|
+
*
|
|
1173
|
+
* wrappingType.toString(); // => '[String]'
|
|
1174
|
+
* assertWrappingType(GraphQLString); // throws an error
|
|
1175
|
+
* ```
|
|
144
1176
|
*/
|
|
1177
|
+
export declare function assertWrappingType(type: unknown): GraphQLWrappingType;
|
|
1178
|
+
/** These types can all accept null as a value. */
|
|
145
1179
|
export type GraphQLNullableType = GraphQLNamedType | GraphQLList<GraphQLType>;
|
|
1180
|
+
/**
|
|
1181
|
+
* Returns true when the value is a GraphQL type that can accept null.
|
|
1182
|
+
* @param type - The GraphQL type to inspect.
|
|
1183
|
+
* @returns True when the value is a GraphQL type that can accept null.
|
|
1184
|
+
* @example
|
|
1185
|
+
* ```ts
|
|
1186
|
+
* import { GraphQLNonNull, GraphQLString, isNullableType } from 'graphql/type';
|
|
1187
|
+
*
|
|
1188
|
+
* isNullableType(GraphQLString); // => true
|
|
1189
|
+
* isNullableType(new GraphQLNonNull(GraphQLString)); // => false
|
|
1190
|
+
* isNullableType(null); // => false
|
|
1191
|
+
* ```
|
|
1192
|
+
*/
|
|
146
1193
|
export declare function isNullableType(type: unknown): type is GraphQLNullableType;
|
|
1194
|
+
/**
|
|
1195
|
+
* Returns the value as a nullable GraphQL type, or throws if it is not one.
|
|
1196
|
+
* @param type - The GraphQL type to inspect.
|
|
1197
|
+
* @returns The value typed as a nullable GraphQL type.
|
|
1198
|
+
* @example
|
|
1199
|
+
* ```ts
|
|
1200
|
+
* import {
|
|
1201
|
+
* GraphQLNonNull,
|
|
1202
|
+
* GraphQLString,
|
|
1203
|
+
* assertNullableType,
|
|
1204
|
+
* } from 'graphql/type';
|
|
1205
|
+
*
|
|
1206
|
+
* const nullableType = assertNullableType(GraphQLString);
|
|
1207
|
+
*
|
|
1208
|
+
* nullableType; // => GraphQLString
|
|
1209
|
+
* assertNullableType(new GraphQLNonNull(GraphQLString)); // throws an error
|
|
1210
|
+
* ```
|
|
1211
|
+
*/
|
|
147
1212
|
export declare function assertNullableType(type: unknown): GraphQLNullableType;
|
|
1213
|
+
/**
|
|
1214
|
+
* Returns the nullable type.
|
|
1215
|
+
* @param type - The GraphQL type to inspect.
|
|
1216
|
+
* @returns The nullable type after removing one non-null wrapper, if present.
|
|
1217
|
+
* @example
|
|
1218
|
+
* ```ts
|
|
1219
|
+
* import { getNullableType } from 'graphql/type';
|
|
1220
|
+
*
|
|
1221
|
+
* getNullableType(null); // => undefined
|
|
1222
|
+
* getNullableType(undefined); // => undefined
|
|
1223
|
+
* ```
|
|
1224
|
+
*/
|
|
148
1225
|
export declare function getNullableType(type: undefined | null): void;
|
|
1226
|
+
/**
|
|
1227
|
+
* Returns the nullable type after removing one non-null wrapper.
|
|
1228
|
+
* @param type - A nullable type or non-null wrapper.
|
|
1229
|
+
* @returns The nullable type after removing one non-null wrapper, if present.
|
|
1230
|
+
* @typeParam T - The nullable GraphQL type returned after removing one non-null wrapper.
|
|
1231
|
+
* @example
|
|
1232
|
+
* ```ts
|
|
1233
|
+
* import {
|
|
1234
|
+
* GraphQLList,
|
|
1235
|
+
* GraphQLNonNull,
|
|
1236
|
+
* GraphQLString,
|
|
1237
|
+
* getNullableType,
|
|
1238
|
+
* } from 'graphql/type';
|
|
1239
|
+
*
|
|
1240
|
+
* const requiredString = new GraphQLNonNull(GraphQLString);
|
|
1241
|
+
* const stringList = new GraphQLList(GraphQLString);
|
|
1242
|
+
*
|
|
1243
|
+
* getNullableType(requiredString); // => GraphQLString
|
|
1244
|
+
* getNullableType(stringList); // => stringList
|
|
1245
|
+
* ```
|
|
1246
|
+
*/
|
|
149
1247
|
export declare function getNullableType<T extends GraphQLNullableType>(type: T | GraphQLNonNull<T>): T;
|
|
150
|
-
export declare function getNullableType(type: Maybe<GraphQLType>): GraphQLNullableType | undefined;
|
|
151
1248
|
/**
|
|
152
|
-
*
|
|
1249
|
+
* Returns the nullable type after removing one non-null wrapper.
|
|
1250
|
+
* @param type - The GraphQL type to inspect.
|
|
1251
|
+
* @returns The nullable type after removing one non-null wrapper, if present.
|
|
1252
|
+
* @example
|
|
1253
|
+
* ```ts
|
|
1254
|
+
* import {
|
|
1255
|
+
* GraphQLList,
|
|
1256
|
+
* GraphQLNonNull,
|
|
1257
|
+
* GraphQLString,
|
|
1258
|
+
* getNullableType,
|
|
1259
|
+
* } from 'graphql/type';
|
|
1260
|
+
*
|
|
1261
|
+
* const requiredStringList = new GraphQLNonNull(
|
|
1262
|
+
* new GraphQLList(GraphQLString),
|
|
1263
|
+
* );
|
|
1264
|
+
*
|
|
1265
|
+
* getNullableType(requiredStringList).toString(); // => '[String]'
|
|
1266
|
+
* getNullableType(GraphQLString); // => GraphQLString
|
|
1267
|
+
* ```
|
|
153
1268
|
*/
|
|
1269
|
+
export declare function getNullableType(type: Maybe<GraphQLType>): GraphQLNullableType | undefined;
|
|
1270
|
+
/** These named types do not include modifiers like List or NonNull. */
|
|
154
1271
|
export type GraphQLNamedType = GraphQLNamedInputType | GraphQLNamedOutputType;
|
|
1272
|
+
/** A named GraphQL type that can be used as an input type. */
|
|
155
1273
|
export type GraphQLNamedInputType = GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType;
|
|
1274
|
+
/** A named GraphQL type that can be used as an output type. */
|
|
156
1275
|
export type GraphQLNamedOutputType = GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType | GraphQLEnumType;
|
|
1276
|
+
/**
|
|
1277
|
+
* Returns true when the value is a GraphQL named type.
|
|
1278
|
+
* @param type - The GraphQL type to inspect.
|
|
1279
|
+
* @returns True when the value is a GraphQL named type.
|
|
1280
|
+
* @example
|
|
1281
|
+
* ```ts
|
|
1282
|
+
* import { GraphQLList, GraphQLString, isNamedType } from 'graphql/type';
|
|
1283
|
+
*
|
|
1284
|
+
* isNamedType(GraphQLString); // => true
|
|
1285
|
+
* isNamedType(new GraphQLList(GraphQLString)); // => false
|
|
1286
|
+
* isNamedType(null); // => false
|
|
1287
|
+
* ```
|
|
1288
|
+
*/
|
|
157
1289
|
export declare function isNamedType(type: unknown): type is GraphQLNamedType;
|
|
1290
|
+
/**
|
|
1291
|
+
* Returns the value as a GraphQL named type, or throws if it is not one.
|
|
1292
|
+
* @param type - The GraphQL type to inspect.
|
|
1293
|
+
* @returns The value typed as a GraphQL named type.
|
|
1294
|
+
* @example
|
|
1295
|
+
* ```ts
|
|
1296
|
+
* import { GraphQLList, GraphQLString, assertNamedType } from 'graphql/type';
|
|
1297
|
+
*
|
|
1298
|
+
* const namedType = assertNamedType(GraphQLString);
|
|
1299
|
+
*
|
|
1300
|
+
* namedType.name; // => 'String'
|
|
1301
|
+
* assertNamedType(new GraphQLList(GraphQLString)); // throws an error
|
|
1302
|
+
* ```
|
|
1303
|
+
*/
|
|
158
1304
|
export declare function assertNamedType(type: unknown): GraphQLNamedType;
|
|
1305
|
+
/**
|
|
1306
|
+
* Returns the named type.
|
|
1307
|
+
* @param type - The GraphQL type to inspect.
|
|
1308
|
+
* @returns The named type after unwrapping all list and non-null wrappers.
|
|
1309
|
+
* @example
|
|
1310
|
+
* ```ts
|
|
1311
|
+
* import { getNamedType } from 'graphql/type';
|
|
1312
|
+
*
|
|
1313
|
+
* getNamedType(null); // => undefined
|
|
1314
|
+
* getNamedType(undefined); // => undefined
|
|
1315
|
+
* ```
|
|
1316
|
+
*/
|
|
159
1317
|
export declare function getNamedType(type: undefined | null): void;
|
|
1318
|
+
/**
|
|
1319
|
+
* Returns the named input type after unwrapping all list and non-null wrappers.
|
|
1320
|
+
* @param type - The GraphQL input type to inspect.
|
|
1321
|
+
* @returns The named input type after unwrapping all wrappers.
|
|
1322
|
+
* @example
|
|
1323
|
+
* ```ts
|
|
1324
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
1325
|
+
* import { getNamedType } from 'graphql/type';
|
|
1326
|
+
*
|
|
1327
|
+
* const schema = buildSchema(`
|
|
1328
|
+
* input ReviewInput {
|
|
1329
|
+
* stars: Int!
|
|
1330
|
+
* }
|
|
1331
|
+
*
|
|
1332
|
+
* type Query {
|
|
1333
|
+
* review(input: [ReviewInput!]!): Boolean
|
|
1334
|
+
* }
|
|
1335
|
+
* `);
|
|
1336
|
+
*
|
|
1337
|
+
* const inputArg = schema.getQueryType()?.getFields().review.args[0];
|
|
1338
|
+
*
|
|
1339
|
+
* getNamedType(inputArg?.type).toString(); // => 'ReviewInput'
|
|
1340
|
+
* ```
|
|
1341
|
+
*/
|
|
160
1342
|
export declare function getNamedType(type: GraphQLInputType): GraphQLNamedInputType;
|
|
1343
|
+
/**
|
|
1344
|
+
* Returns the named output type after unwrapping all list and non-null wrappers.
|
|
1345
|
+
* @param type - The GraphQL output type to inspect.
|
|
1346
|
+
* @returns The named output type after unwrapping all wrappers.
|
|
1347
|
+
* @example
|
|
1348
|
+
* ```ts
|
|
1349
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
1350
|
+
* import { getNamedType } from 'graphql/type';
|
|
1351
|
+
*
|
|
1352
|
+
* const schema = buildSchema(`
|
|
1353
|
+
* type User {
|
|
1354
|
+
* name: String
|
|
1355
|
+
* }
|
|
1356
|
+
*
|
|
1357
|
+
* type Query {
|
|
1358
|
+
* users: [User!]!
|
|
1359
|
+
* }
|
|
1360
|
+
* `);
|
|
1361
|
+
*
|
|
1362
|
+
* const usersField = schema.getQueryType()?.getFields().users;
|
|
1363
|
+
*
|
|
1364
|
+
* getNamedType(usersField?.type).toString(); // => 'User'
|
|
1365
|
+
* ```
|
|
1366
|
+
*/
|
|
161
1367
|
export declare function getNamedType(type: GraphQLOutputType): GraphQLNamedOutputType;
|
|
1368
|
+
/**
|
|
1369
|
+
* Returns the named type after unwrapping all list and non-null wrappers.
|
|
1370
|
+
* @param type - The GraphQL type to inspect.
|
|
1371
|
+
* @returns The named type after unwrapping all wrappers.
|
|
1372
|
+
* @example
|
|
1373
|
+
* ```ts
|
|
1374
|
+
* import {
|
|
1375
|
+
* GraphQLList,
|
|
1376
|
+
* GraphQLNonNull,
|
|
1377
|
+
* GraphQLString,
|
|
1378
|
+
* getNamedType,
|
|
1379
|
+
* } from 'graphql/type';
|
|
1380
|
+
*
|
|
1381
|
+
* const nestedType = new GraphQLNonNull(
|
|
1382
|
+
* new GraphQLList(new GraphQLNonNull(GraphQLString)),
|
|
1383
|
+
* );
|
|
1384
|
+
*
|
|
1385
|
+
* getNamedType(nestedType); // => GraphQLString
|
|
1386
|
+
* ```
|
|
1387
|
+
*/
|
|
162
1388
|
export declare function getNamedType(type: GraphQLType): GraphQLNamedType;
|
|
1389
|
+
/**
|
|
1390
|
+
* Returns the named type after unwrapping all list and non-null wrappers.
|
|
1391
|
+
* @param type - The GraphQL type to inspect.
|
|
1392
|
+
* @returns The named type after unwrapping all wrappers, or undefined for nullish input.
|
|
1393
|
+
* @example
|
|
1394
|
+
* ```ts
|
|
1395
|
+
* import {
|
|
1396
|
+
* GraphQLList,
|
|
1397
|
+
* GraphQLString,
|
|
1398
|
+
* getNamedType,
|
|
1399
|
+
* } from 'graphql/type';
|
|
1400
|
+
*
|
|
1401
|
+
* getNamedType(new GraphQLList(GraphQLString)); // => GraphQLString
|
|
1402
|
+
* getNamedType(undefined); // => undefined
|
|
1403
|
+
* ```
|
|
1404
|
+
*/
|
|
163
1405
|
export declare function getNamedType(type: Maybe<GraphQLType>): GraphQLNamedType | undefined;
|
|
164
1406
|
/**
|
|
165
1407
|
* An interface for all Schema Elements.
|
|
1408
|
+
*
|
|
1409
|
+
* @internal
|
|
166
1410
|
*/
|
|
167
1411
|
export interface GraphQLSchemaElement {
|
|
168
1412
|
toString: () => string;
|
|
@@ -171,14 +1415,50 @@ export interface GraphQLSchemaElement {
|
|
|
171
1415
|
/**
|
|
172
1416
|
* Used while defining GraphQL types to allow for circular references in
|
|
173
1417
|
* otherwise immutable type definitions.
|
|
1418
|
+
* @typeParam T - The element type returned by the thunk or array.
|
|
174
1419
|
*/
|
|
175
1420
|
export type ThunkReadonlyArray<T> = (() => ReadonlyArray<T>) | ReadonlyArray<T>;
|
|
1421
|
+
/**
|
|
1422
|
+
* A thunk that resolves to an object map.
|
|
1423
|
+
* @typeParam T - Value type stored in the object map.
|
|
1424
|
+
*/
|
|
176
1425
|
export type ThunkObjMap<T> = (() => ObjMap<T>) | ObjMap<T>;
|
|
1426
|
+
/**
|
|
1427
|
+
* Resolves a thunked readonly array.
|
|
1428
|
+
* @param thunk - The thunk or value to resolve.
|
|
1429
|
+
* @returns The resolved readonly array.
|
|
1430
|
+
* @typeParam T - The element type resolved from the thunk or array.
|
|
1431
|
+
* @example
|
|
1432
|
+
* ```ts
|
|
1433
|
+
* import { GraphQLString, resolveReadonlyArrayThunk } from 'graphql/type';
|
|
1434
|
+
*
|
|
1435
|
+
* const lazyFields = resolveReadonlyArrayThunk(() => [GraphQLString]);
|
|
1436
|
+
* const fields = resolveReadonlyArrayThunk([GraphQLString]);
|
|
1437
|
+
*
|
|
1438
|
+
* lazyFields; // => [GraphQLString]
|
|
1439
|
+
* fields; // => [GraphQLString]
|
|
1440
|
+
* ```
|
|
1441
|
+
*/
|
|
177
1442
|
export declare function resolveReadonlyArrayThunk<T>(thunk: ThunkReadonlyArray<T>): ReadonlyArray<T>;
|
|
1443
|
+
/**
|
|
1444
|
+
* Resolves a thunked object map.
|
|
1445
|
+
* @param thunk - The thunk or value to resolve.
|
|
1446
|
+
* @returns The resolved object map.
|
|
1447
|
+
* @typeParam T - The object-map value type resolved from the thunk or map.
|
|
1448
|
+
* @example
|
|
1449
|
+
* ```ts
|
|
1450
|
+
* import { GraphQLString, resolveObjMapThunk } from 'graphql/type';
|
|
1451
|
+
*
|
|
1452
|
+
* const lazyFields = resolveObjMapThunk(() => ({ name: GraphQLString }));
|
|
1453
|
+
* const fields = resolveObjMapThunk({ name: GraphQLString });
|
|
1454
|
+
*
|
|
1455
|
+
* lazyFields.name; // => GraphQLString
|
|
1456
|
+
* fields.name; // => GraphQLString
|
|
1457
|
+
* ```
|
|
1458
|
+
*/
|
|
178
1459
|
export declare function resolveObjMapThunk<T>(thunk: ThunkObjMap<T>): ObjMap<T>;
|
|
179
1460
|
/**
|
|
180
1461
|
* Custom extensions
|
|
181
|
-
*
|
|
182
1462
|
* @remarks
|
|
183
1463
|
* Use a unique identifier name for your extension, for example the name of
|
|
184
1464
|
* your library or project. Do not use a shortened identifier as this increases
|
|
@@ -191,45 +1471,17 @@ export interface GraphQLScalarTypeExtensions {
|
|
|
191
1471
|
/**
|
|
192
1472
|
* Scalar Type Definition
|
|
193
1473
|
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
*
|
|
1474
|
+
* Scalar types define the leaf values of a GraphQL response and the input
|
|
1475
|
+
* values accepted by arguments and input object fields. A scalar type has a
|
|
1476
|
+
* name and coercion functions that validate and convert runtime values and
|
|
1477
|
+
* GraphQL literals.
|
|
197
1478
|
*
|
|
198
1479
|
* If a type's coerceOutputValue function returns `null` or does not return a
|
|
199
1480
|
* value (i.e. it returns `undefined`) then an error will be raised and a
|
|
200
|
-
* `null` value will be returned in the response.
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
* ```ts
|
|
206
|
-
* function ensureOdd(value) {
|
|
207
|
-
* if (!Number.isFinite(value)) {
|
|
208
|
-
* throw new Error(
|
|
209
|
-
* `Scalar "Odd" cannot represent "${value}" since it is not a finite number.`,
|
|
210
|
-
* );
|
|
211
|
-
* }
|
|
212
|
-
*
|
|
213
|
-
* if (value % 2 === 0) {
|
|
214
|
-
* throw new Error(`Scalar "Odd" cannot represent "${value}" since it is even.`);
|
|
215
|
-
* }
|
|
216
|
-
* }
|
|
217
|
-
*
|
|
218
|
-
* const OddType = new GraphQLScalarType({
|
|
219
|
-
* name: 'Odd',
|
|
220
|
-
* coerceOutputValue(value) {
|
|
221
|
-
* return ensureOdd(value);
|
|
222
|
-
* },
|
|
223
|
-
* coerceInputValue(value) {
|
|
224
|
-
* return ensureOdd(value);
|
|
225
|
-
* }
|
|
226
|
-
* valueToLiteral(value) {
|
|
227
|
-
* return parse(`${ensureOdd(value)`);
|
|
228
|
-
* }
|
|
229
|
-
* });
|
|
230
|
-
* ```
|
|
231
|
-
*
|
|
232
|
-
* Custom scalars behavior is defined via the following functions:
|
|
1481
|
+
* `null` value will be returned in the response. Prefer validating inputs
|
|
1482
|
+
* before execution so clients receive input diagnostics before result coercion
|
|
1483
|
+
* fails.
|
|
1484
|
+
* Custom scalar behavior is defined via the following functions:
|
|
233
1485
|
*
|
|
234
1486
|
* - coerceOutputValue(value): Implements "Result Coercion". Given an internal value,
|
|
235
1487
|
* produces an external value valid for this type. Returns undefined or
|
|
@@ -241,7 +1493,7 @@ export interface GraphQLScalarTypeExtensions {
|
|
|
241
1493
|
* invalid values.
|
|
242
1494
|
*
|
|
243
1495
|
* - coerceInputLiteral(ast): Implements "Input Coercion" for constant literals.
|
|
244
|
-
* Given
|
|
1496
|
+
* Given a GraphQL literal (AST) (for example, an argument value), produces
|
|
245
1497
|
* an internal value valid for this type. Returns undefined or throws an
|
|
246
1498
|
* error to indicate invalid values.
|
|
247
1499
|
*
|
|
@@ -261,51 +1513,259 @@ export interface GraphQLScalarTypeExtensions {
|
|
|
261
1513
|
* non-specified replacement of variables embedded within complex scalars.
|
|
262
1514
|
* Replaced by the combination of the `replaceVariables()` utility and the
|
|
263
1515
|
* `coerceInputLiteral()` method.
|
|
1516
|
+
* @typeParam TInternal - Internal runtime representation for this scalar.
|
|
1517
|
+
* @typeParam TExternal - External representation accepted from or returned to callers.
|
|
1518
|
+
* @example
|
|
1519
|
+
* ```ts
|
|
1520
|
+
* import { GraphQLScalarType, Kind } from 'graphql';
|
|
1521
|
+
*
|
|
1522
|
+
* const ensureOdd = (value) => {
|
|
1523
|
+
* if (!Number.isFinite(value)) {
|
|
1524
|
+
* throw new Error(
|
|
1525
|
+
* `Scalar "Odd" cannot represent "${value}" since it is not a finite number.`,
|
|
1526
|
+
* );
|
|
1527
|
+
* }
|
|
264
1528
|
*
|
|
1529
|
+
* if (value % 2 === 0) {
|
|
1530
|
+
* throw new Error(`Scalar "Odd" cannot represent "${value}" since it is even.`);
|
|
1531
|
+
* }
|
|
1532
|
+
*
|
|
1533
|
+
* return value;
|
|
1534
|
+
* };
|
|
1535
|
+
*
|
|
1536
|
+
* const OddType = new GraphQLScalarType({
|
|
1537
|
+
* name: 'Odd',
|
|
1538
|
+
* coerceOutputValue: (value) => {
|
|
1539
|
+
* return ensureOdd(value);
|
|
1540
|
+
* },
|
|
1541
|
+
* coerceInputValue: (value) => {
|
|
1542
|
+
* return ensureOdd(value);
|
|
1543
|
+
* },
|
|
1544
|
+
* valueToLiteral: (value) => {
|
|
1545
|
+
* return { kind: Kind.INT, value: String(ensureOdd(value)) };
|
|
1546
|
+
* }
|
|
1547
|
+
* });
|
|
1548
|
+
* ```
|
|
265
1549
|
*/
|
|
266
1550
|
export declare class GraphQLScalarType<TInternal = unknown, TExternal = TInternal> implements GraphQLSchemaElement {
|
|
267
|
-
|
|
1551
|
+
/** The GraphQL name for this schema element. */
|
|
268
1552
|
name: string;
|
|
1553
|
+
/** Human-readable description for this schema element, if provided. */
|
|
269
1554
|
description: Maybe<string>;
|
|
1555
|
+
/** URL identifying the behavior specified for this custom scalar. */
|
|
270
1556
|
specifiedByURL: Maybe<string>;
|
|
271
|
-
/**
|
|
1557
|
+
/**
|
|
1558
|
+
* Deprecated legacy serializer used to convert internal values for response
|
|
1559
|
+
* output. Use `coerceOutputValue()` instead.
|
|
1560
|
+
* @deprecated use `coerceOutputValue()` instead, `serialize()` will be removed in v18
|
|
1561
|
+
*/
|
|
272
1562
|
serialize: GraphQLScalarSerializer<TExternal>;
|
|
273
|
-
/**
|
|
1563
|
+
/**
|
|
1564
|
+
* Deprecated legacy parser used to convert externally provided input values.
|
|
1565
|
+
* Use `coerceInputValue()` instead.
|
|
1566
|
+
* @deprecated use `coerceInputValue()` instead, `parseValue()` will be removed in v18
|
|
1567
|
+
*/
|
|
274
1568
|
parseValue: GraphQLScalarValueParser<TInternal>;
|
|
275
|
-
/**
|
|
1569
|
+
/**
|
|
1570
|
+
* Deprecated legacy parser used to convert externally provided input
|
|
1571
|
+
* literals. Use `replaceVariables()` and `coerceInputLiteral()` instead.
|
|
1572
|
+
* @deprecated use `replaceVariables()` and `coerceInputLiteral()` instead, `parseLiteral()` will be removed in v18
|
|
1573
|
+
*/
|
|
276
1574
|
parseLiteral: GraphQLScalarLiteralParser<TInternal>;
|
|
1575
|
+
/** Coercer used to convert internal scalar values for response output. */
|
|
277
1576
|
coerceOutputValue: GraphQLScalarOutputValueCoercer<TExternal>;
|
|
1577
|
+
/** Coercer used to convert externally provided scalar input values. */
|
|
278
1578
|
coerceInputValue: GraphQLScalarInputValueCoercer<TInternal>;
|
|
1579
|
+
/** Coercer used to convert GraphQL scalar input literals. */
|
|
279
1580
|
coerceInputLiteral: GraphQLScalarInputLiteralCoercer<TInternal> | undefined;
|
|
1581
|
+
/** Converter used to produce GraphQL literals from runtime input values. */
|
|
280
1582
|
valueToLiteral: GraphQLScalarValueToLiteral | undefined;
|
|
1583
|
+
/** Extension fields to include in the formatted result. */
|
|
281
1584
|
extensions: Readonly<GraphQLScalarTypeExtensions>;
|
|
1585
|
+
/** AST node from which this schema element was built, if available. */
|
|
282
1586
|
astNode: Maybe<ScalarTypeDefinitionNode>;
|
|
1587
|
+
/** AST extension nodes applied to this schema element. */
|
|
283
1588
|
extensionASTNodes: ReadonlyArray<ScalarTypeExtensionNode>;
|
|
1589
|
+
/**
|
|
1590
|
+
* Creates a GraphQLScalarType instance.
|
|
1591
|
+
* @param config - Configuration describing this object.
|
|
1592
|
+
* @example
|
|
1593
|
+
* ```ts
|
|
1594
|
+
* import { Kind, parse } from 'graphql/language';
|
|
1595
|
+
* import { GraphQLScalarType } from 'graphql/type';
|
|
1596
|
+
*
|
|
1597
|
+
* const document = parse(`
|
|
1598
|
+
* "Odd integer values."
|
|
1599
|
+
* scalar Odd @specifiedBy(url: "https://example.com/odd")
|
|
1600
|
+
*
|
|
1601
|
+
* extend scalar Odd @specifiedBy(url: "https://example.com/odd-v2")
|
|
1602
|
+
* `);
|
|
1603
|
+
*
|
|
1604
|
+
* const Odd = new GraphQLScalarType({
|
|
1605
|
+
* name: 'Odd',
|
|
1606
|
+
* description: 'Odd integer values.',
|
|
1607
|
+
* specifiedByURL: 'https://example.com/odd',
|
|
1608
|
+
* coerceOutputValue: (value) => {
|
|
1609
|
+
* if (typeof value !== 'number' || value % 2 === 0) {
|
|
1610
|
+
* throw new TypeError('Odd can only produce odd numbers.');
|
|
1611
|
+
* }
|
|
1612
|
+
* return value;
|
|
1613
|
+
* },
|
|
1614
|
+
* coerceInputValue: (value) => {
|
|
1615
|
+
* if (typeof value !== 'number' || value % 2 === 0) {
|
|
1616
|
+
* throw new TypeError('Odd can only accept odd numbers.');
|
|
1617
|
+
* }
|
|
1618
|
+
* return value;
|
|
1619
|
+
* },
|
|
1620
|
+
* coerceInputLiteral: (ast) => {
|
|
1621
|
+
* if (ast.kind !== Kind.INT) {
|
|
1622
|
+
* throw new TypeError('Odd can only accept integer literals.');
|
|
1623
|
+
* }
|
|
1624
|
+
* const value = Number(ast.value);
|
|
1625
|
+
* if (value % 2 === 0) {
|
|
1626
|
+
* throw new TypeError('Odd can only accept odd integer literals.');
|
|
1627
|
+
* }
|
|
1628
|
+
* return value;
|
|
1629
|
+
* },
|
|
1630
|
+
* valueToLiteral: (value) => {
|
|
1631
|
+
* return { kind: Kind.INT, value: String(ensureOdd(value)) };
|
|
1632
|
+
* },
|
|
1633
|
+
* extensions: { numeric: true },
|
|
1634
|
+
* astNode: document.definitions[0],
|
|
1635
|
+
* extensionASTNodes: [ document.definitions[1] ],
|
|
1636
|
+
* });
|
|
1637
|
+
*
|
|
1638
|
+
* Odd.description; // => 'Odd integer values.'
|
|
1639
|
+
* Odd.specifiedByURL; // => 'https://example.com/odd'
|
|
1640
|
+
* Odd.coerceOutputValue(3); // => 3
|
|
1641
|
+
* Odd.coerceInputValue(5); // => 5
|
|
1642
|
+
* Odd.extensions; // => { numeric: true }
|
|
1643
|
+
* ```
|
|
1644
|
+
*/
|
|
284
1645
|
constructor(config: Readonly<GraphQLScalarTypeConfig<TInternal, TExternal>>);
|
|
1646
|
+
/**
|
|
1647
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
1648
|
+
* @returns The built-in string tag for this object.
|
|
1649
|
+
*/
|
|
285
1650
|
get [Symbol.toStringTag](): string;
|
|
1651
|
+
/**
|
|
1652
|
+
* Returns a normalized configuration object for this object.
|
|
1653
|
+
* @returns A configuration object that can be used to recreate this object.
|
|
1654
|
+
* @example
|
|
1655
|
+
* ```ts
|
|
1656
|
+
* import { GraphQLScalarType } from 'graphql/type';
|
|
1657
|
+
*
|
|
1658
|
+
* const Url = new GraphQLScalarType({
|
|
1659
|
+
* name: 'Url',
|
|
1660
|
+
* description: 'An absolute URL string.',
|
|
1661
|
+
* specifiedByURL: 'https://url.spec.whatwg.org/',
|
|
1662
|
+
* });
|
|
1663
|
+
*
|
|
1664
|
+
* const config = Url.toConfig();
|
|
1665
|
+
* const UrlCopy = new GraphQLScalarType(config);
|
|
1666
|
+
*
|
|
1667
|
+
* config.name; // => 'Url'
|
|
1668
|
+
* config.specifiedByURL; // => 'https://url.spec.whatwg.org/'
|
|
1669
|
+
* UrlCopy.name; // => Url.name
|
|
1670
|
+
* ```
|
|
1671
|
+
*/
|
|
286
1672
|
toConfig(): GraphQLScalarTypeNormalizedConfig<TInternal, TExternal>;
|
|
1673
|
+
/**
|
|
1674
|
+
* Returns the schema coordinate identifying this scalar type.
|
|
1675
|
+
* @returns The schema coordinate for this scalar type.
|
|
1676
|
+
* @example
|
|
1677
|
+
* ```ts
|
|
1678
|
+
* import { GraphQLScalarType } from 'graphql/type';
|
|
1679
|
+
*
|
|
1680
|
+
* const DateTime = new GraphQLScalarType({ name: 'DateTime' });
|
|
1681
|
+
*
|
|
1682
|
+
* DateTime.toString(); // => 'DateTime'
|
|
1683
|
+
* String(DateTime); // => 'DateTime'
|
|
1684
|
+
* ```
|
|
1685
|
+
*/
|
|
287
1686
|
toString(): string;
|
|
1687
|
+
/**
|
|
1688
|
+
* Returns the JSON representation used when this object is serialized.
|
|
1689
|
+
* @returns The JSON-serializable representation.
|
|
1690
|
+
* @example
|
|
1691
|
+
* ```ts
|
|
1692
|
+
* import { GraphQLScalarType } from 'graphql/type';
|
|
1693
|
+
*
|
|
1694
|
+
* const DateTime = new GraphQLScalarType({ name: 'DateTime' });
|
|
1695
|
+
*
|
|
1696
|
+
* DateTime.toJSON(); // => 'DateTime'
|
|
1697
|
+
* JSON.stringify({ type: DateTime }); // => '{"type":"DateTime"}'
|
|
1698
|
+
* ```
|
|
1699
|
+
*/
|
|
288
1700
|
toJSON(): string;
|
|
289
1701
|
}
|
|
1702
|
+
/**
|
|
1703
|
+
* Deprecated function type that serializes a runtime value as a scalar output
|
|
1704
|
+
* value. Use `GraphQLScalarOutputValueCoercer` instead.
|
|
1705
|
+
* @typeParam TExternal - External representation accepted from or returned to callers.
|
|
1706
|
+
* @deprecated Use GraphQLScalarOutputValueCoercer instead. Will be removed in v18.
|
|
1707
|
+
*/
|
|
290
1708
|
export type GraphQLScalarSerializer<TExternal> = (outputValue: unknown) => TExternal;
|
|
1709
|
+
/**
|
|
1710
|
+
* Function used to coerce internal scalar values for response output.
|
|
1711
|
+
* @typeParam TExternal - External representation accepted from or returned to callers.
|
|
1712
|
+
*/
|
|
291
1713
|
export type GraphQLScalarOutputValueCoercer<TExternal> = (outputValue: unknown) => TExternal;
|
|
1714
|
+
/**
|
|
1715
|
+
* Deprecated function type that parses a runtime input value as a scalar input
|
|
1716
|
+
* value. Use `GraphQLScalarInputValueCoercer` instead.
|
|
1717
|
+
* @typeParam TInternal - Internal runtime representation for this scalar.
|
|
1718
|
+
* @deprecated Use GraphQLScalarInputValueCoercer instead. Will be removed in v18.
|
|
1719
|
+
*/
|
|
292
1720
|
export type GraphQLScalarValueParser<TInternal> = (inputValue: unknown) => TInternal;
|
|
1721
|
+
/**
|
|
1722
|
+
* Function used to coerce externally provided scalar input values.
|
|
1723
|
+
* @typeParam TInternal - Internal runtime representation for this scalar.
|
|
1724
|
+
*/
|
|
293
1725
|
export type GraphQLScalarInputValueCoercer<TInternal> = (inputValue: unknown) => TInternal;
|
|
1726
|
+
/**
|
|
1727
|
+
* Deprecated function type that parses a GraphQL value literal as a scalar
|
|
1728
|
+
* input value. Use `GraphQLScalarInputLiteralCoercer` instead.
|
|
1729
|
+
* @typeParam TInternal - Internal runtime representation for this scalar.
|
|
1730
|
+
* @deprecated Use GraphQLScalarInputLiteralCoercer instead. Will be removed in v18.
|
|
1731
|
+
*/
|
|
294
1732
|
export type GraphQLScalarLiteralParser<TInternal> = (valueNode: ValueNode, variables: Maybe<ObjMap<unknown>>) => Maybe<TInternal>;
|
|
1733
|
+
/**
|
|
1734
|
+
* Function used to coerce GraphQL scalar input literals.
|
|
1735
|
+
* @typeParam TInternal - Internal runtime representation for this scalar.
|
|
1736
|
+
*/
|
|
295
1737
|
export type GraphQLScalarInputLiteralCoercer<TInternal> = (valueNode: ConstValueNode) => Maybe<TInternal>;
|
|
1738
|
+
/** @internal */
|
|
296
1739
|
export type GraphQLScalarValueToLiteral = (inputValue: unknown) => ConstValueNode | undefined;
|
|
1740
|
+
/**
|
|
1741
|
+
* Configuration used to construct a GraphQLScalarType.
|
|
1742
|
+
* @typeParam TInternal - Internal runtime representation for this scalar.
|
|
1743
|
+
* @typeParam TExternal - External representation accepted from or returned to callers.
|
|
1744
|
+
*/
|
|
297
1745
|
export interface GraphQLScalarTypeConfig<TInternal, TExternal> {
|
|
1746
|
+
/** The GraphQL name for this schema element. */
|
|
298
1747
|
name: string;
|
|
1748
|
+
/** Human-readable description for this schema element, if provided. */
|
|
299
1749
|
description?: Maybe<string>;
|
|
1750
|
+
/** URL identifying the behavior specified for this custom scalar. */
|
|
300
1751
|
specifiedByURL?: Maybe<string>;
|
|
301
|
-
/**
|
|
302
|
-
|
|
1752
|
+
/**
|
|
1753
|
+
* Deprecated legacy serializer used to convert internal values for response
|
|
1754
|
+
* output. Use `coerceOutputValue()` instead.
|
|
1755
|
+
* @deprecated use `coerceOutputValue()` instead, `serialize()` will be removed in v18
|
|
1756
|
+
*/
|
|
303
1757
|
serialize?: GraphQLScalarSerializer<TExternal> | undefined;
|
|
304
|
-
/**
|
|
305
|
-
|
|
1758
|
+
/**
|
|
1759
|
+
* Deprecated legacy parser used to convert externally provided input values.
|
|
1760
|
+
* Use `coerceInputValue()` instead.
|
|
1761
|
+
* @deprecated use `coerceInputValue()` instead, `parseValue()` will be removed in v18
|
|
1762
|
+
*/
|
|
306
1763
|
parseValue?: GraphQLScalarValueParser<TInternal> | undefined;
|
|
307
|
-
/**
|
|
308
|
-
|
|
1764
|
+
/**
|
|
1765
|
+
* Deprecated legacy parser used to convert externally provided input
|
|
1766
|
+
* literals. Use `replaceVariables()` and `coerceInputLiteral()` instead.
|
|
1767
|
+
* @deprecated use `replaceVariables()` and `coerceInputLiteral()` instead, `parseLiteral()` will be removed in v18
|
|
1768
|
+
*/
|
|
309
1769
|
parseLiteral?: GraphQLScalarLiteralParser<TInternal> | undefined;
|
|
310
1770
|
/** Coerces an internal value to include in a response. */
|
|
311
1771
|
coerceOutputValue?: GraphQLScalarOutputValueCoercer<TExternal> | undefined;
|
|
@@ -315,10 +1775,14 @@ export interface GraphQLScalarTypeConfig<TInternal, TExternal> {
|
|
|
315
1775
|
coerceInputLiteral?: GraphQLScalarInputLiteralCoercer<TInternal> | undefined;
|
|
316
1776
|
/** Translates an externally provided value to a literal (AST). */
|
|
317
1777
|
valueToLiteral?: GraphQLScalarValueToLiteral | undefined;
|
|
1778
|
+
/** Extension fields to include in the formatted result. */
|
|
318
1779
|
extensions?: Maybe<Readonly<GraphQLScalarTypeExtensions>>;
|
|
1780
|
+
/** AST node from which this schema element was built, if available. */
|
|
319
1781
|
astNode?: Maybe<ScalarTypeDefinitionNode>;
|
|
1782
|
+
/** AST extension nodes applied to this schema element. */
|
|
320
1783
|
extensionASTNodes?: Maybe<ReadonlyArray<ScalarTypeExtensionNode>>;
|
|
321
1784
|
}
|
|
1785
|
+
/** @internal */
|
|
322
1786
|
export interface GraphQLScalarTypeNormalizedConfig<TInternal, TExternal> extends GraphQLScalarTypeConfig<TInternal, TExternal> {
|
|
323
1787
|
serialize: GraphQLScalarSerializer<TExternal>;
|
|
324
1788
|
parseValue: GraphQLScalarValueParser<TInternal>;
|
|
@@ -331,15 +1795,15 @@ export interface GraphQLScalarTypeNormalizedConfig<TInternal, TExternal> extends
|
|
|
331
1795
|
}
|
|
332
1796
|
/**
|
|
333
1797
|
* Custom extensions
|
|
334
|
-
*
|
|
335
1798
|
* @remarks
|
|
336
1799
|
* Use a unique identifier name for your extension, for example the name of
|
|
337
1800
|
* your library or project. Do not use a shortened identifier as this increases
|
|
338
1801
|
* the risk of conflicts. We recommend you add at most one extension field,
|
|
339
1802
|
* an object which can contain all the values you need.
|
|
340
|
-
*
|
|
341
1803
|
* We've provided these template arguments because this is an open type and
|
|
342
1804
|
* you may find them useful.
|
|
1805
|
+
* @typeParam _TSource - Reserved source type parameter for extension typing.
|
|
1806
|
+
* @typeParam _TContext - Reserved context type parameter for extension typing.
|
|
343
1807
|
*/
|
|
344
1808
|
export interface GraphQLObjectTypeExtensions<_TSource = any, _TContext = any> {
|
|
345
1809
|
[attributeName: string | symbol]: unknown;
|
|
@@ -349,9 +1813,10 @@ export interface GraphQLObjectTypeExtensions<_TSource = any, _TContext = any> {
|
|
|
349
1813
|
*
|
|
350
1814
|
* Almost all of the GraphQL types you define will be object types. Object types
|
|
351
1815
|
* have a name, but most importantly describe their fields.
|
|
352
|
-
*
|
|
353
|
-
*
|
|
354
|
-
*
|
|
1816
|
+
* @typeParam TSource - Source object type passed to resolvers.
|
|
1817
|
+
* @typeParam TContext - Context object type passed to resolvers.
|
|
1818
|
+
* @typeParam TAbstract - Runtime value type used for abstract type resolution.
|
|
1819
|
+
* @example
|
|
355
1820
|
* ```ts
|
|
356
1821
|
* const AddressType = new GraphQLObjectType({
|
|
357
1822
|
* name: 'Address',
|
|
@@ -360,20 +1825,18 @@ export interface GraphQLObjectTypeExtensions<_TSource = any, _TContext = any> {
|
|
|
360
1825
|
* number: { type: GraphQLInt },
|
|
361
1826
|
* formatted: {
|
|
362
1827
|
* type: GraphQLString,
|
|
363
|
-
* resolve(obj) {
|
|
1828
|
+
* resolve: (obj) => {
|
|
364
1829
|
* return obj.number + ' ' + obj.street
|
|
365
1830
|
* }
|
|
366
1831
|
* }
|
|
367
1832
|
* }
|
|
368
1833
|
* });
|
|
369
1834
|
* ```
|
|
370
|
-
*
|
|
1835
|
+
* @example
|
|
371
1836
|
* When two types need to refer to each other, or a type needs to refer to
|
|
372
1837
|
* itself in a field, you can use a function expression (aka a closure or a
|
|
373
1838
|
* thunk) to supply the fields lazily.
|
|
374
1839
|
*
|
|
375
|
-
* Example:
|
|
376
|
-
*
|
|
377
1840
|
* ```ts
|
|
378
1841
|
* const PersonType = new GraphQLObjectType({
|
|
379
1842
|
* name: 'Person',
|
|
@@ -385,42 +1848,297 @@ export interface GraphQLObjectTypeExtensions<_TSource = any, _TContext = any> {
|
|
|
385
1848
|
* ```
|
|
386
1849
|
*/
|
|
387
1850
|
export declare class GraphQLObjectType<TSource = any, TContext = any, TAbstract = any> implements GraphQLSchemaElement {
|
|
388
|
-
|
|
1851
|
+
/** The GraphQL name for this schema element. */
|
|
389
1852
|
name: string;
|
|
1853
|
+
/** Human-readable description for this schema element, if provided. */
|
|
390
1854
|
description: Maybe<string>;
|
|
1855
|
+
/** Predicate used to determine whether a runtime value belongs to this object type. */
|
|
391
1856
|
isTypeOf: Maybe<GraphQLIsTypeOfFn<TAbstract, TContext>>;
|
|
1857
|
+
/** Extension fields to include in the formatted result. */
|
|
392
1858
|
extensions: Readonly<GraphQLObjectTypeExtensions<TSource, TContext>>;
|
|
1859
|
+
/** AST node from which this schema element was built, if available. */
|
|
393
1860
|
astNode: Maybe<ObjectTypeDefinitionNode>;
|
|
1861
|
+
/** AST extension nodes applied to this schema element. */
|
|
394
1862
|
extensionASTNodes: ReadonlyArray<ObjectTypeExtensionNode>;
|
|
395
1863
|
private _fields;
|
|
396
1864
|
private _interfaces;
|
|
1865
|
+
/**
|
|
1866
|
+
* Creates a GraphQLObjectType instance.
|
|
1867
|
+
* @param config - Configuration describing this object.
|
|
1868
|
+
* @example
|
|
1869
|
+
* ```ts
|
|
1870
|
+
* // Configure an object type with interfaces, fields, arguments, and metadata.
|
|
1871
|
+
* import { parse } from 'graphql/language';
|
|
1872
|
+
* import {
|
|
1873
|
+
* GraphQLID,
|
|
1874
|
+
* GraphQLInterfaceType,
|
|
1875
|
+
* GraphQLNonNull,
|
|
1876
|
+
* GraphQLObjectType,
|
|
1877
|
+
* GraphQLString,
|
|
1878
|
+
* } from 'graphql/type';
|
|
1879
|
+
*
|
|
1880
|
+
* const document = parse(`
|
|
1881
|
+
* type User implements Node {
|
|
1882
|
+
* id: ID!
|
|
1883
|
+
* name(format: String = "short"): String
|
|
1884
|
+
* }
|
|
1885
|
+
*
|
|
1886
|
+
* extend type User {
|
|
1887
|
+
* displayName: String
|
|
1888
|
+
* }
|
|
1889
|
+
* `);
|
|
1890
|
+
* const definition = document.definitions[0];
|
|
1891
|
+
* const nameField = definition.fields[1];
|
|
1892
|
+
* const formatArg = nameField.arguments[0];
|
|
1893
|
+
*
|
|
1894
|
+
* const Node = new GraphQLInterfaceType({
|
|
1895
|
+
* name: 'Node',
|
|
1896
|
+
* fields: {
|
|
1897
|
+
* id: { type: new GraphQLNonNull(GraphQLID) },
|
|
1898
|
+
* },
|
|
1899
|
+
* });
|
|
1900
|
+
*
|
|
1901
|
+
* const User = new GraphQLObjectType({
|
|
1902
|
+
* name: 'User',
|
|
1903
|
+
* description: 'A registered user.',
|
|
1904
|
+
* interfaces: [Node],
|
|
1905
|
+
* fields: {
|
|
1906
|
+
* id: { type: new GraphQLNonNull(GraphQLID) },
|
|
1907
|
+
* name: {
|
|
1908
|
+
* description: 'The formatted user name.',
|
|
1909
|
+
* type: GraphQLString,
|
|
1910
|
+
* args: {
|
|
1911
|
+
* format: {
|
|
1912
|
+
* description: 'Controls the name format.',
|
|
1913
|
+
* type: GraphQLString,
|
|
1914
|
+
* default: { value: 'short' },
|
|
1915
|
+
* deprecationReason: 'Use locale instead.',
|
|
1916
|
+
* extensions: { public: true },
|
|
1917
|
+
* astNode: formatArg,
|
|
1918
|
+
* },
|
|
1919
|
+
* },
|
|
1920
|
+
* resolve: (user, { format }) => {
|
|
1921
|
+
* return format === 'long' ? user.fullName : user.name;
|
|
1922
|
+
* },
|
|
1923
|
+
* deprecationReason: 'Use displayName.',
|
|
1924
|
+
* extensions: { cacheSeconds: 60 },
|
|
1925
|
+
* astNode: nameField,
|
|
1926
|
+
* },
|
|
1927
|
+
* },
|
|
1928
|
+
* isTypeOf: (value) => {
|
|
1929
|
+
* return typeof value === 'object' && value != null && 'id' in value;
|
|
1930
|
+
* },
|
|
1931
|
+
* extensions: { entity: 'User' },
|
|
1932
|
+
* astNode: definition,
|
|
1933
|
+
* extensionASTNodes: [ document.definitions[1] ],
|
|
1934
|
+
* });
|
|
1935
|
+
*
|
|
1936
|
+
* User.name; // => 'User'
|
|
1937
|
+
* User.getInterfaces(); // => [Node]
|
|
1938
|
+
* Object.keys(User.getFields()); // => ['id', 'name']
|
|
1939
|
+
* User.getFields().name.args[0].default.value; // => 'short'
|
|
1940
|
+
* User.extensions; // => { entity: 'User' }
|
|
1941
|
+
* ```
|
|
1942
|
+
* @example
|
|
1943
|
+
* ```ts
|
|
1944
|
+
* // This variant configures a subscription field with subscribe and resolve functions.
|
|
1945
|
+
* import { GraphQLObjectType, GraphQLString } from 'graphql/type';
|
|
1946
|
+
*
|
|
1947
|
+
* const Subscription = new GraphQLObjectType({
|
|
1948
|
+
* name: 'Subscription',
|
|
1949
|
+
* fields: {
|
|
1950
|
+
* greeting: {
|
|
1951
|
+
* type: GraphQLString,
|
|
1952
|
+
* subscribe: async function* () {
|
|
1953
|
+
* yield { greeting: 'Hello!' };
|
|
1954
|
+
* },
|
|
1955
|
+
* resolve: (event) => {
|
|
1956
|
+
* return event.greeting;
|
|
1957
|
+
* },
|
|
1958
|
+
* },
|
|
1959
|
+
* },
|
|
1960
|
+
* });
|
|
1961
|
+
*
|
|
1962
|
+
* typeof Subscription.getFields().greeting.subscribe; // => 'function'
|
|
1963
|
+
* ```
|
|
1964
|
+
*/
|
|
397
1965
|
constructor(config: Readonly<GraphQLObjectTypeConfig<TSource, TContext, TAbstract>>);
|
|
1966
|
+
/**
|
|
1967
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
1968
|
+
* @returns The built-in string tag for this object.
|
|
1969
|
+
*/
|
|
398
1970
|
get [Symbol.toStringTag](): string;
|
|
1971
|
+
/**
|
|
1972
|
+
* Returns the fields defined by this type.
|
|
1973
|
+
* @returns The fields keyed by field name.
|
|
1974
|
+
* @example
|
|
1975
|
+
* ```ts
|
|
1976
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
1977
|
+
* import { assertObjectType } from 'graphql/type';
|
|
1978
|
+
*
|
|
1979
|
+
* const schema = buildSchema(`
|
|
1980
|
+
* type User {
|
|
1981
|
+
* id: ID!
|
|
1982
|
+
* name: String
|
|
1983
|
+
* }
|
|
1984
|
+
*
|
|
1985
|
+
* type Query {
|
|
1986
|
+
* viewer: User
|
|
1987
|
+
* }
|
|
1988
|
+
* `);
|
|
1989
|
+
*
|
|
1990
|
+
* const User = assertObjectType(schema.getType('User'));
|
|
1991
|
+
* const fields = User.getFields();
|
|
1992
|
+
*
|
|
1993
|
+
* Object.keys(fields); // => ['id', 'name']
|
|
1994
|
+
* String(fields.id.type); // => 'ID!'
|
|
1995
|
+
* ```
|
|
1996
|
+
*/
|
|
399
1997
|
getFields(): GraphQLFieldMap<TSource, TContext>;
|
|
1998
|
+
/**
|
|
1999
|
+
* Returns the interfaces implemented by this type.
|
|
2000
|
+
* @returns The implemented interfaces.
|
|
2001
|
+
* @example
|
|
2002
|
+
* ```ts
|
|
2003
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
2004
|
+
* import { assertObjectType } from 'graphql/type';
|
|
2005
|
+
*
|
|
2006
|
+
* const schema = buildSchema(`
|
|
2007
|
+
* interface Node {
|
|
2008
|
+
* id: ID!
|
|
2009
|
+
* }
|
|
2010
|
+
*
|
|
2011
|
+
* type User implements Node {
|
|
2012
|
+
* id: ID!
|
|
2013
|
+
* }
|
|
2014
|
+
*
|
|
2015
|
+
* type Query {
|
|
2016
|
+
* viewer: User
|
|
2017
|
+
* }
|
|
2018
|
+
* `);
|
|
2019
|
+
*
|
|
2020
|
+
* const User = assertObjectType(schema.getType('User'));
|
|
2021
|
+
*
|
|
2022
|
+
* User.getInterfaces().map((type) => type.name); // => ['Node']
|
|
2023
|
+
* ```
|
|
2024
|
+
*/
|
|
400
2025
|
getInterfaces(): ReadonlyArray<GraphQLInterfaceType>;
|
|
2026
|
+
/**
|
|
2027
|
+
* Returns a normalized configuration object for this object.
|
|
2028
|
+
* @returns A configuration object that can be used to recreate this object.
|
|
2029
|
+
* @example
|
|
2030
|
+
* ```ts
|
|
2031
|
+
* import { GraphQLObjectType, GraphQLString } from 'graphql/type';
|
|
2032
|
+
*
|
|
2033
|
+
* const User = new GraphQLObjectType({
|
|
2034
|
+
* name: 'User',
|
|
2035
|
+
* fields: {
|
|
2036
|
+
* name: { type: GraphQLString },
|
|
2037
|
+
* },
|
|
2038
|
+
* });
|
|
2039
|
+
*
|
|
2040
|
+
* const config = User.toConfig();
|
|
2041
|
+
* const UserCopy = new GraphQLObjectType(config);
|
|
2042
|
+
*
|
|
2043
|
+
* config.fields.name.type; // => GraphQLString
|
|
2044
|
+
* UserCopy.getFields().name.type; // => GraphQLString
|
|
2045
|
+
* ```
|
|
2046
|
+
*/
|
|
401
2047
|
toConfig(): GraphQLObjectTypeNormalizedConfig<TSource, TContext, TAbstract>;
|
|
2048
|
+
/**
|
|
2049
|
+
* Returns the schema coordinate identifying this object type.
|
|
2050
|
+
* @returns The schema coordinate for this object type.
|
|
2051
|
+
* @example
|
|
2052
|
+
* ```ts
|
|
2053
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
2054
|
+
* import { assertObjectType } from 'graphql/type';
|
|
2055
|
+
*
|
|
2056
|
+
* const schema = buildSchema(`
|
|
2057
|
+
* type User {
|
|
2058
|
+
* name: String
|
|
2059
|
+
* }
|
|
2060
|
+
*
|
|
2061
|
+
* type Query {
|
|
2062
|
+
* viewer: User
|
|
2063
|
+
* }
|
|
2064
|
+
* `);
|
|
2065
|
+
*
|
|
2066
|
+
* const User = assertObjectType(schema.getType('User'));
|
|
2067
|
+
*
|
|
2068
|
+
* User.toString(); // => 'User'
|
|
2069
|
+
* ```
|
|
2070
|
+
*/
|
|
402
2071
|
toString(): string;
|
|
2072
|
+
/**
|
|
2073
|
+
* Returns the JSON representation used when this object is serialized.
|
|
2074
|
+
* @returns The JSON-serializable representation.
|
|
2075
|
+
* @example
|
|
2076
|
+
* ```ts
|
|
2077
|
+
* import { GraphQLObjectType, GraphQLString } from 'graphql/type';
|
|
2078
|
+
*
|
|
2079
|
+
* const User = new GraphQLObjectType({
|
|
2080
|
+
* name: 'User',
|
|
2081
|
+
* fields: { name: { type: GraphQLString } },
|
|
2082
|
+
* });
|
|
2083
|
+
*
|
|
2084
|
+
* User.toJSON(); // => 'User'
|
|
2085
|
+
* JSON.stringify({ type: User }); // => '{"type":"User"}'
|
|
2086
|
+
* ```
|
|
2087
|
+
*/
|
|
403
2088
|
toJSON(): string;
|
|
404
2089
|
}
|
|
2090
|
+
/**
|
|
2091
|
+
* Configuration used to construct a GraphQLObjectType.
|
|
2092
|
+
* @typeParam TSource - Source object type passed to resolvers.
|
|
2093
|
+
* @typeParam TContext - Context object type passed to resolvers.
|
|
2094
|
+
* @typeParam TAbstract - Runtime value type used for abstract type resolution.
|
|
2095
|
+
*/
|
|
405
2096
|
export interface GraphQLObjectTypeConfig<TSource, TContext, TAbstract = unknown> {
|
|
2097
|
+
/** The GraphQL name for this schema element. */
|
|
406
2098
|
name: string;
|
|
2099
|
+
/** Human-readable description for this schema element, if provided. */
|
|
407
2100
|
description?: Maybe<string>;
|
|
2101
|
+
/** Interfaces implemented by this object or interface type. */
|
|
408
2102
|
interfaces?: ThunkReadonlyArray<GraphQLInterfaceType> | undefined;
|
|
2103
|
+
/** Fields declared by this object, interface, input object, or literal. */
|
|
409
2104
|
fields: ThunkObjMap<GraphQLFieldConfig<TSource, TContext>>;
|
|
2105
|
+
/** Predicate used to determine whether a runtime value belongs to this object type. */
|
|
410
2106
|
isTypeOf?: Maybe<GraphQLIsTypeOfFn<TAbstract, TContext>>;
|
|
2107
|
+
/** Extension fields to include in the formatted result. */
|
|
411
2108
|
extensions?: Maybe<Readonly<GraphQLObjectTypeExtensions<TSource, TContext>>>;
|
|
2109
|
+
/** AST node from which this schema element was built, if available. */
|
|
412
2110
|
astNode?: Maybe<ObjectTypeDefinitionNode>;
|
|
2111
|
+
/** AST extension nodes applied to this schema element. */
|
|
413
2112
|
extensionASTNodes?: Maybe<ReadonlyArray<ObjectTypeExtensionNode>>;
|
|
414
2113
|
}
|
|
2114
|
+
/** @internal */
|
|
415
2115
|
export interface GraphQLObjectTypeNormalizedConfig<TSource, TContext, TAbstract = unknown> extends GraphQLObjectTypeConfig<TSource, TContext, TAbstract> {
|
|
416
2116
|
interfaces: ReadonlyArray<GraphQLInterfaceType>;
|
|
417
2117
|
fields: GraphQLFieldNormalizedConfigMap<TSource, TContext>;
|
|
418
2118
|
extensions: Readonly<GraphQLObjectTypeExtensions<TSource, TContext>>;
|
|
419
2119
|
extensionASTNodes: ReadonlyArray<ObjectTypeExtensionNode>;
|
|
420
2120
|
}
|
|
2121
|
+
/**
|
|
2122
|
+
* Resolves the concrete object type for an abstract GraphQL type.
|
|
2123
|
+
* @typeParam TSource - Source object type passed to resolvers.
|
|
2124
|
+
* @typeParam TContext - Context object type passed to resolvers.
|
|
2125
|
+
*/
|
|
421
2126
|
export type GraphQLTypeResolver<TSource, TContext> = (value: TSource, context: TContext, info: GraphQLResolveInfo, abstractType: GraphQLAbstractType) => PromiseOrValue<string | undefined>;
|
|
2127
|
+
/**
|
|
2128
|
+
* Checks whether a runtime value belongs to a GraphQL object type.
|
|
2129
|
+
* @typeParam TAbstract - Runtime value type used for abstract type resolution.
|
|
2130
|
+
* @typeParam TContext - Context object type passed to resolvers.
|
|
2131
|
+
*/
|
|
422
2132
|
export type GraphQLIsTypeOfFn<TAbstract, TContext> = (value: TAbstract, context: TContext, info: GraphQLResolveInfo) => PromiseOrValue<boolean>;
|
|
2133
|
+
/**
|
|
2134
|
+
* Resolves the runtime value for a GraphQL field.
|
|
2135
|
+
* @typeParam TSource - Source object type passed to resolvers.
|
|
2136
|
+
* @typeParam TContext - Context object type passed to resolvers.
|
|
2137
|
+
* @typeParam TArgs - Argument object type passed to resolvers.
|
|
2138
|
+
* @typeParam TResult - Result value type.
|
|
2139
|
+
*/
|
|
423
2140
|
export type GraphQLFieldResolver<TSource, TContext, TArgs = any, TResult = unknown> = (source: TSource, args: TArgs, context: TContext, info: GraphQLResolveInfo) => TResult;
|
|
2141
|
+
/** Utilities available from resolver info for tracking asynchronous work. */
|
|
424
2142
|
export interface GraphQLResolveInfoHelpers {
|
|
425
2143
|
/**
|
|
426
2144
|
* Promise.all wrapper that allows rejected branches to be tracked
|
|
@@ -445,56 +2163,90 @@ export interface GraphQLResolveInfoHelpers {
|
|
|
445
2163
|
* ]);
|
|
446
2164
|
*/
|
|
447
2165
|
readonly promiseAll: <T>(values: ReadonlyArray<PromiseLike<T> | T>) => Promise<Array<T>>;
|
|
2166
|
+
/** Tracks asynchronous work that should delay execution completion hooks. */
|
|
448
2167
|
readonly track: (maybePromises: ReadonlyArray<unknown>) => void;
|
|
449
2168
|
}
|
|
2169
|
+
/** Information about the currently executing GraphQL field. */
|
|
450
2170
|
export interface GraphQLResolveInfo {
|
|
2171
|
+
/** The field name referenced by this schema coordinate. */
|
|
451
2172
|
readonly fieldName: string;
|
|
2173
|
+
/** AST field nodes that contributed to the current field execution. */
|
|
452
2174
|
readonly fieldNodes: ReadonlyArray<FieldNode>;
|
|
2175
|
+
/** GraphQL output type declared for the current field. */
|
|
453
2176
|
readonly returnType: GraphQLOutputType;
|
|
2177
|
+
/** Object type that owns the current field. */
|
|
454
2178
|
readonly parentType: GraphQLObjectType;
|
|
2179
|
+
/** Response path where this error occurred during execution. */
|
|
455
2180
|
readonly path: Path;
|
|
2181
|
+
/** The schema used for validation or execution. */
|
|
456
2182
|
readonly schema: GraphQLSchema;
|
|
2183
|
+
/** Fragment definitions in the operation document keyed by fragment name. */
|
|
457
2184
|
readonly fragments: ObjMap<FragmentDefinitionNode>;
|
|
2185
|
+
/** Initial root value passed to the operation. */
|
|
458
2186
|
readonly rootValue: unknown;
|
|
2187
|
+
/** The operation selected for execution. */
|
|
459
2188
|
readonly operation: OperationDefinitionNode;
|
|
2189
|
+
/**
|
|
2190
|
+
* Coerced variable values and source metadata for this operation. Resolver
|
|
2191
|
+
* code that needs runtime variable values should read `variableValues.coerced`.
|
|
2192
|
+
*/
|
|
460
2193
|
readonly variableValues: VariableValues;
|
|
2194
|
+
/** Returns the AbortSignal supplied for this execution, if any. */
|
|
461
2195
|
readonly getAbortSignal: () => AbortSignal | undefined;
|
|
2196
|
+
/** Returns helper functions for tracking asynchronous resolver work. */
|
|
462
2197
|
readonly getAsyncHelpers: () => GraphQLResolveInfoHelpers;
|
|
463
2198
|
}
|
|
464
2199
|
/**
|
|
465
2200
|
* Custom extensions
|
|
466
|
-
*
|
|
467
2201
|
* @remarks
|
|
468
2202
|
* Use a unique identifier name for your extension, for example the name of
|
|
469
2203
|
* your library or project. Do not use a shortened identifier as this increases
|
|
470
2204
|
* the risk of conflicts. We recommend you add at most one extension field,
|
|
471
2205
|
* an object which can contain all the values you need.
|
|
472
|
-
*
|
|
473
2206
|
* We've provided these template arguments because this is an open type and
|
|
474
2207
|
* you may find them useful.
|
|
2208
|
+
* @typeParam _TSource - Reserved source type parameter for extension typing.
|
|
2209
|
+
* @typeParam _TContext - Reserved context type parameter for extension typing.
|
|
2210
|
+
* @typeParam _TArgs - Reserved argument type parameter for extension typing.
|
|
475
2211
|
*/
|
|
476
2212
|
export interface GraphQLFieldExtensions<_TSource, _TContext, _TArgs = any> {
|
|
477
2213
|
[attributeName: string | symbol]: unknown;
|
|
478
2214
|
}
|
|
2215
|
+
/**
|
|
2216
|
+
* Configuration used to define a GraphQL field.
|
|
2217
|
+
* @typeParam TSource - Source object type passed to resolvers.
|
|
2218
|
+
* @typeParam TContext - Context object type passed to resolvers.
|
|
2219
|
+
* @typeParam TArgs - Argument object type passed to resolvers.
|
|
2220
|
+
*/
|
|
479
2221
|
export interface GraphQLFieldConfig<TSource, TContext, TArgs = any> {
|
|
2222
|
+
/** Human-readable description for this schema element, if provided. */
|
|
480
2223
|
description?: Maybe<string>;
|
|
2224
|
+
/** The GraphQL type reference or runtime type for this element. */
|
|
481
2225
|
type: GraphQLOutputType;
|
|
2226
|
+
/** Arguments accepted by this field or directive. */
|
|
482
2227
|
args?: GraphQLFieldConfigArgumentMap | undefined;
|
|
2228
|
+
/** Resolver function used to produce this field value. */
|
|
483
2229
|
resolve?: GraphQLFieldResolver<TSource, TContext, TArgs> | undefined;
|
|
2230
|
+
/** Resolver function used to create a subscription event stream for this field. */
|
|
484
2231
|
subscribe?: GraphQLFieldResolver<TSource, TContext, TArgs> | undefined;
|
|
2232
|
+
/** Reason this element is deprecated, if one was provided. */
|
|
485
2233
|
deprecationReason?: Maybe<string>;
|
|
2234
|
+
/** Extension fields to include in the formatted result. */
|
|
486
2235
|
extensions?: Maybe<Readonly<GraphQLFieldExtensions<TSource, TContext, TArgs>>>;
|
|
2236
|
+
/** AST node from which this schema element was built, if available. */
|
|
487
2237
|
astNode?: Maybe<FieldDefinitionNode>;
|
|
488
2238
|
}
|
|
2239
|
+
/** @internal */
|
|
489
2240
|
export interface GraphQLFieldNormalizedConfig<TSource, TContext, TArgs = any> extends GraphQLFieldConfig<TSource, TContext, TArgs> {
|
|
490
2241
|
args: GraphQLFieldNormalizedConfigArgumentMap;
|
|
491
2242
|
extensions: Readonly<GraphQLFieldExtensions<TSource, TContext, TArgs>>;
|
|
492
2243
|
}
|
|
2244
|
+
/** A map of argument names to argument configuration objects. */
|
|
493
2245
|
export type GraphQLFieldConfigArgumentMap = ObjMap<GraphQLArgumentConfig>;
|
|
2246
|
+
/** @internal */
|
|
494
2247
|
export type GraphQLFieldNormalizedConfigArgumentMap = ObjMap<GraphQLArgumentNormalizedConfig>;
|
|
495
2248
|
/**
|
|
496
2249
|
* Custom extensions
|
|
497
|
-
*
|
|
498
2250
|
* @remarks
|
|
499
2251
|
* Use a unique identifier name for your extension, for example the name of
|
|
500
2252
|
* your library or project. Do not use a shortened identifier as this increases
|
|
@@ -504,69 +2256,330 @@ export type GraphQLFieldNormalizedConfigArgumentMap = ObjMap<GraphQLArgumentNorm
|
|
|
504
2256
|
export interface GraphQLArgumentExtensions {
|
|
505
2257
|
[attributeName: string | symbol]: unknown;
|
|
506
2258
|
}
|
|
2259
|
+
/** Configuration used to define a GraphQL argument. */
|
|
507
2260
|
export interface GraphQLArgumentConfig {
|
|
2261
|
+
/** Human-readable description for this schema element, if provided. */
|
|
508
2262
|
description?: Maybe<string>;
|
|
2263
|
+
/** The GraphQL type reference or runtime type for this element. */
|
|
509
2264
|
type: GraphQLInputType;
|
|
510
|
-
/**
|
|
2265
|
+
/**
|
|
2266
|
+
* Deprecated legacy default value for this argument. Use `default` instead.
|
|
2267
|
+
* @deprecated use `default` instead, `defaultValue` will be removed in v18
|
|
2268
|
+
*/
|
|
511
2269
|
defaultValue?: unknown;
|
|
2270
|
+
/** Default value represented as either a runtime value or a GraphQL literal. */
|
|
512
2271
|
default?: GraphQLDefaultInput | undefined;
|
|
2272
|
+
/** Reason this element is deprecated, if one was provided. */
|
|
513
2273
|
deprecationReason?: Maybe<string>;
|
|
2274
|
+
/** Extension fields to include in the formatted result. */
|
|
514
2275
|
extensions?: Maybe<Readonly<GraphQLArgumentExtensions>>;
|
|
2276
|
+
/** AST node from which this schema element was built, if available. */
|
|
515
2277
|
astNode?: Maybe<InputValueDefinitionNode>;
|
|
516
2278
|
}
|
|
2279
|
+
/** @internal */
|
|
517
2280
|
export interface GraphQLArgumentNormalizedConfig extends GraphQLArgumentConfig {
|
|
518
2281
|
default: GraphQLDefaultInput | undefined;
|
|
519
2282
|
extensions: Readonly<GraphQLArgumentExtensions>;
|
|
520
2283
|
}
|
|
2284
|
+
/**
|
|
2285
|
+
* A map of field names to field configuration objects.
|
|
2286
|
+
* @typeParam TSource - Source object type passed to resolvers.
|
|
2287
|
+
* @typeParam TContext - Context object type passed to resolvers.
|
|
2288
|
+
*/
|
|
521
2289
|
export type GraphQLFieldConfigMap<TSource, TContext> = ObjMap<GraphQLFieldConfig<TSource, TContext>>;
|
|
2290
|
+
/** @internal */
|
|
522
2291
|
export type GraphQLFieldNormalizedConfigMap<TSource, TContext> = ObjMap<GraphQLFieldNormalizedConfig<TSource, TContext>>;
|
|
2292
|
+
/**
|
|
2293
|
+
* A resolved GraphQL field definition.
|
|
2294
|
+
* @typeParam TSource - Source object type passed to resolvers.
|
|
2295
|
+
* @typeParam TContext - Context object type passed to resolvers.
|
|
2296
|
+
* @typeParam TArgs - Argument object type passed to resolvers.
|
|
2297
|
+
*/
|
|
523
2298
|
export declare class GraphQLField<TSource = any, TContext = any, TArgs = any> implements GraphQLSchemaElement {
|
|
524
|
-
|
|
2299
|
+
/** Object or interface type that owns this field, if known. */
|
|
525
2300
|
parentType: GraphQLObjectType<TSource, TContext> | GraphQLInterfaceType<TSource, TContext> | undefined;
|
|
2301
|
+
/** The GraphQL name for this schema element. */
|
|
526
2302
|
name: string;
|
|
2303
|
+
/** Human-readable description for this schema element, if provided. */
|
|
527
2304
|
description: Maybe<string>;
|
|
2305
|
+
/** The GraphQL type reference or runtime type for this element. */
|
|
528
2306
|
type: GraphQLOutputType;
|
|
2307
|
+
/** Arguments accepted by this field or directive. */
|
|
529
2308
|
args: ReadonlyArray<GraphQLArgument>;
|
|
2309
|
+
/** Resolver function used to produce this field value. */
|
|
530
2310
|
resolve?: GraphQLFieldResolver<TSource, TContext, TArgs> | undefined;
|
|
2311
|
+
/** Resolver function used to create a subscription event stream for this field. */
|
|
531
2312
|
subscribe?: GraphQLFieldResolver<TSource, TContext, TArgs> | undefined;
|
|
2313
|
+
/** Reason this element is deprecated, if one was provided. */
|
|
532
2314
|
deprecationReason: Maybe<string>;
|
|
2315
|
+
/** Extension fields to include in the formatted result. */
|
|
533
2316
|
extensions: Readonly<GraphQLFieldExtensions<TSource, TContext, TArgs>>;
|
|
2317
|
+
/** AST node from which this schema element was built, if available. */
|
|
534
2318
|
astNode: Maybe<FieldDefinitionNode>;
|
|
2319
|
+
/**
|
|
2320
|
+
* Creates a resolved GraphQL field definition.
|
|
2321
|
+
* @param parentType - Object or interface type that owns this field, if known.
|
|
2322
|
+
* @param name - Field name.
|
|
2323
|
+
* @param config - Field configuration.
|
|
2324
|
+
* @example
|
|
2325
|
+
* ```ts
|
|
2326
|
+
* import { parse } from 'graphql/language';
|
|
2327
|
+
* import { GraphQLField, GraphQLObjectType, GraphQLString } from 'graphql/type';
|
|
2328
|
+
*
|
|
2329
|
+
* const Query = new GraphQLObjectType({ name: 'Query', fields: {} });
|
|
2330
|
+
* const document = parse('type Query { greeting: String }');
|
|
2331
|
+
* const fieldNode = document.definitions[0].fields[0];
|
|
2332
|
+
* const field = new GraphQLField(Query, 'greeting', {
|
|
2333
|
+
* description: 'Greeting text.',
|
|
2334
|
+
* type: GraphQLString,
|
|
2335
|
+
* args: {
|
|
2336
|
+
* name: { type: GraphQLString, default: { value: 'world' } },
|
|
2337
|
+
* },
|
|
2338
|
+
* resolve: (_source, { name }) => `Hello, ${name}!`,
|
|
2339
|
+
* subscribe: async function* () {
|
|
2340
|
+
* yield { greeting: 'Hello!' };
|
|
2341
|
+
* },
|
|
2342
|
+
* deprecationReason: 'Use hello.',
|
|
2343
|
+
* extensions: { cacheSeconds: 60 },
|
|
2344
|
+
* astNode: fieldNode,
|
|
2345
|
+
* });
|
|
2346
|
+
*
|
|
2347
|
+
* field.parentType; // => Query
|
|
2348
|
+
* field.name; // => 'greeting'
|
|
2349
|
+
* field.args[0].default.value; // => 'world'
|
|
2350
|
+
* typeof field.subscribe; // => 'function'
|
|
2351
|
+
* field.deprecationReason; // => 'Use hello.'
|
|
2352
|
+
* field.astNode; // => fieldNode
|
|
2353
|
+
* ```
|
|
2354
|
+
*/
|
|
535
2355
|
constructor(parentType: GraphQLObjectType<TSource, TContext> | GraphQLInterfaceType<TSource, TContext> | undefined, name: string, config: GraphQLFieldConfig<TSource, TContext, TArgs>);
|
|
2356
|
+
/**
|
|
2357
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
2358
|
+
* @returns The built-in string tag for this object.
|
|
2359
|
+
*/
|
|
536
2360
|
get [Symbol.toStringTag](): string;
|
|
2361
|
+
/**
|
|
2362
|
+
* Returns a normalized configuration object for this field.
|
|
2363
|
+
* @returns A configuration object that can be used to recreate this field.
|
|
2364
|
+
* @example
|
|
2365
|
+
* ```ts
|
|
2366
|
+
* import { GraphQLField, GraphQLObjectType, GraphQLString } from 'graphql/type';
|
|
2367
|
+
*
|
|
2368
|
+
* const Query = new GraphQLObjectType({ name: 'Query', fields: {} });
|
|
2369
|
+
* const field = new GraphQLField(Query, 'greeting', {
|
|
2370
|
+
* type: GraphQLString,
|
|
2371
|
+
* extensions: { cacheSeconds: 60 },
|
|
2372
|
+
* });
|
|
2373
|
+
*
|
|
2374
|
+
* field.toConfig().type; // => GraphQLString
|
|
2375
|
+
* field.toConfig().extensions; // => { cacheSeconds: 60 }
|
|
2376
|
+
* ```
|
|
2377
|
+
*/
|
|
537
2378
|
toConfig(): GraphQLFieldNormalizedConfig<TSource, TContext, TArgs>;
|
|
2379
|
+
/**
|
|
2380
|
+
* Returns this field as a schema coordinate string.
|
|
2381
|
+
* @returns The field coordinate.
|
|
2382
|
+
* @example
|
|
2383
|
+
* ```ts
|
|
2384
|
+
* import { GraphQLField, GraphQLObjectType, GraphQLString } from 'graphql/type';
|
|
2385
|
+
*
|
|
2386
|
+
* const Query = new GraphQLObjectType({ name: 'Query', fields: {} });
|
|
2387
|
+
* const field = new GraphQLField(Query, 'greeting', { type: GraphQLString });
|
|
2388
|
+
*
|
|
2389
|
+
* field.toString(); // => 'Query.greeting'
|
|
2390
|
+
* ```
|
|
2391
|
+
*/
|
|
538
2392
|
toString(): string;
|
|
2393
|
+
/**
|
|
2394
|
+
* Returns the JSON representation used when this object is serialized.
|
|
2395
|
+
* @returns The field coordinate.
|
|
2396
|
+
* @example
|
|
2397
|
+
* ```ts
|
|
2398
|
+
* import { GraphQLField, GraphQLObjectType, GraphQLString } from 'graphql/type';
|
|
2399
|
+
*
|
|
2400
|
+
* const Query = new GraphQLObjectType({ name: 'Query', fields: {} });
|
|
2401
|
+
* const field = new GraphQLField(Query, 'greeting', { type: GraphQLString });
|
|
2402
|
+
*
|
|
2403
|
+
* JSON.stringify(field); // => '"Query.greeting"'
|
|
2404
|
+
* ```
|
|
2405
|
+
*/
|
|
539
2406
|
toJSON(): string;
|
|
540
2407
|
}
|
|
2408
|
+
/** A resolved GraphQL argument definition. */
|
|
541
2409
|
export declare class GraphQLArgument implements GraphQLSchemaElement {
|
|
542
|
-
|
|
2410
|
+
/** Field or directive that owns this argument. */
|
|
543
2411
|
parent: GraphQLField | GraphQLDirective;
|
|
2412
|
+
/** The GraphQL name for this schema element. */
|
|
544
2413
|
name: string;
|
|
2414
|
+
/** Human-readable description for this schema element, if provided. */
|
|
545
2415
|
description: Maybe<string>;
|
|
2416
|
+
/** The GraphQL type reference or runtime type for this element. */
|
|
546
2417
|
type: GraphQLInputType;
|
|
2418
|
+
/**
|
|
2419
|
+
* Deprecated legacy default value used when no explicit value is supplied.
|
|
2420
|
+
* Use `default` instead.
|
|
2421
|
+
* @deprecated use `default` instead, `defaultValue` will be removed in v18
|
|
2422
|
+
*/
|
|
547
2423
|
defaultValue: unknown;
|
|
2424
|
+
/** Default value represented as either a runtime value or a GraphQL literal. */
|
|
548
2425
|
default: GraphQLDefaultInput | undefined;
|
|
2426
|
+
/** Reason this element is deprecated, if one was provided. */
|
|
549
2427
|
deprecationReason: Maybe<string>;
|
|
2428
|
+
/** Extension fields to include in the formatted result. */
|
|
550
2429
|
extensions: Readonly<GraphQLArgumentExtensions>;
|
|
2430
|
+
/** AST node from which this schema element was built, if available. */
|
|
551
2431
|
astNode: Maybe<InputValueDefinitionNode>;
|
|
2432
|
+
/**
|
|
2433
|
+
* Creates a resolved GraphQL argument definition.
|
|
2434
|
+
* @param parent - Field or directive that owns this argument.
|
|
2435
|
+
* @param name - Argument name.
|
|
2436
|
+
* @param config - Argument configuration.
|
|
2437
|
+
* @example
|
|
2438
|
+
* ```ts
|
|
2439
|
+
* import {
|
|
2440
|
+
* GraphQLArgument,
|
|
2441
|
+
* GraphQLField,
|
|
2442
|
+
* GraphQLObjectType,
|
|
2443
|
+
* GraphQLString,
|
|
2444
|
+
* } from 'graphql/type';
|
|
2445
|
+
*
|
|
2446
|
+
* const Query = new GraphQLObjectType({ name: 'Query', fields: {} });
|
|
2447
|
+
* const field = new GraphQLField(Query, 'greeting', { type: GraphQLString });
|
|
2448
|
+
* const arg = new GraphQLArgument(field, 'name', {
|
|
2449
|
+
* type: GraphQLString,
|
|
2450
|
+
* default: { value: 'world' },
|
|
2451
|
+
* });
|
|
2452
|
+
*
|
|
2453
|
+
* arg.parent; // => field
|
|
2454
|
+
* arg.name; // => 'name'
|
|
2455
|
+
* arg.default.value; // => 'world'
|
|
2456
|
+
* ```
|
|
2457
|
+
*/
|
|
552
2458
|
constructor(parent: GraphQLField | GraphQLDirective, name: string, config: GraphQLArgumentConfig);
|
|
2459
|
+
/**
|
|
2460
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
2461
|
+
* @returns The built-in string tag for this object.
|
|
2462
|
+
*/
|
|
553
2463
|
get [Symbol.toStringTag](): string;
|
|
2464
|
+
/**
|
|
2465
|
+
* Returns a normalized configuration object for this argument.
|
|
2466
|
+
* @returns A configuration object that can be used to recreate this argument.
|
|
2467
|
+
* @example
|
|
2468
|
+
* ```ts
|
|
2469
|
+
* import {
|
|
2470
|
+
* GraphQLArgument,
|
|
2471
|
+
* GraphQLField,
|
|
2472
|
+
* GraphQLObjectType,
|
|
2473
|
+
* GraphQLString,
|
|
2474
|
+
* } from 'graphql/type';
|
|
2475
|
+
*
|
|
2476
|
+
* const Query = new GraphQLObjectType({ name: 'Query', fields: {} });
|
|
2477
|
+
* const field = new GraphQLField(Query, 'greeting', { type: GraphQLString });
|
|
2478
|
+
* const arg = new GraphQLArgument(field, 'name', {
|
|
2479
|
+
* type: GraphQLString,
|
|
2480
|
+
* default: { value: 'world' },
|
|
2481
|
+
* });
|
|
2482
|
+
*
|
|
2483
|
+
* arg.toConfig().default.value; // => 'world'
|
|
2484
|
+
* ```
|
|
2485
|
+
*/
|
|
554
2486
|
toConfig(): GraphQLArgumentNormalizedConfig;
|
|
2487
|
+
/**
|
|
2488
|
+
* Returns this argument as a schema coordinate string.
|
|
2489
|
+
* @returns The argument coordinate.
|
|
2490
|
+
* @example
|
|
2491
|
+
* ```ts
|
|
2492
|
+
* import {
|
|
2493
|
+
* GraphQLArgument,
|
|
2494
|
+
* GraphQLField,
|
|
2495
|
+
* GraphQLObjectType,
|
|
2496
|
+
* GraphQLString,
|
|
2497
|
+
* } from 'graphql/type';
|
|
2498
|
+
*
|
|
2499
|
+
* const Query = new GraphQLObjectType({ name: 'Query', fields: {} });
|
|
2500
|
+
* const field = new GraphQLField(Query, 'greeting', { type: GraphQLString });
|
|
2501
|
+
* const arg = new GraphQLArgument(field, 'name', { type: GraphQLString });
|
|
2502
|
+
*
|
|
2503
|
+
* arg.toString(); // => 'Query.greeting(name:)'
|
|
2504
|
+
* ```
|
|
2505
|
+
*/
|
|
555
2506
|
toString(): string;
|
|
2507
|
+
/**
|
|
2508
|
+
* Returns the JSON representation used when this object is serialized.
|
|
2509
|
+
* @returns The argument coordinate.
|
|
2510
|
+
* @example
|
|
2511
|
+
* ```ts
|
|
2512
|
+
* import {
|
|
2513
|
+
* GraphQLArgument,
|
|
2514
|
+
* GraphQLField,
|
|
2515
|
+
* GraphQLObjectType,
|
|
2516
|
+
* GraphQLString,
|
|
2517
|
+
* } from 'graphql/type';
|
|
2518
|
+
*
|
|
2519
|
+
* const Query = new GraphQLObjectType({ name: 'Query', fields: {} });
|
|
2520
|
+
* const field = new GraphQLField(Query, 'greeting', { type: GraphQLString });
|
|
2521
|
+
* const arg = new GraphQLArgument(field, 'name', { type: GraphQLString });
|
|
2522
|
+
*
|
|
2523
|
+
* JSON.stringify(arg); // => '"Query.greeting(name:)"'
|
|
2524
|
+
* ```
|
|
2525
|
+
*/
|
|
556
2526
|
toJSON(): string;
|
|
557
2527
|
}
|
|
2528
|
+
/**
|
|
2529
|
+
* Returns true when the argument is non-null and has no default value.
|
|
2530
|
+
* @param arg - The argument definition to inspect.
|
|
2531
|
+
* @returns True when the argument is non-null and has no default value.
|
|
2532
|
+
* @example
|
|
2533
|
+
* ```ts
|
|
2534
|
+
* import {
|
|
2535
|
+
* GraphQLArgument,
|
|
2536
|
+
* GraphQLField,
|
|
2537
|
+
* GraphQLInt,
|
|
2538
|
+
* GraphQLNonNull,
|
|
2539
|
+
* GraphQLObjectType,
|
|
2540
|
+
* GraphQLString,
|
|
2541
|
+
* isRequiredArgument,
|
|
2542
|
+
* } from 'graphql/type';
|
|
2543
|
+
*
|
|
2544
|
+
* const Query = new GraphQLObjectType({ name: 'Query', fields: {} });
|
|
2545
|
+
* const field = new GraphQLField(Query, 'reviews', { type: GraphQLString });
|
|
2546
|
+
* const requiredArgument = new GraphQLArgument(field, 'id', {
|
|
2547
|
+
* type: new GraphQLNonNull(GraphQLInt),
|
|
2548
|
+
* });
|
|
2549
|
+
* const optionalArgument = new GraphQLArgument(field, 'name', {
|
|
2550
|
+
* type: GraphQLString,
|
|
2551
|
+
* });
|
|
2552
|
+
* const argumentWithDefault = new GraphQLArgument(field, 'limit', {
|
|
2553
|
+
* type: new GraphQLNonNull(GraphQLInt),
|
|
2554
|
+
* default: { value: 10 },
|
|
2555
|
+
* });
|
|
2556
|
+
*
|
|
2557
|
+
* isRequiredArgument(requiredArgument); // => true
|
|
2558
|
+
* isRequiredArgument(optionalArgument); // => false
|
|
2559
|
+
* isRequiredArgument(argumentWithDefault); // => false
|
|
2560
|
+
* ```
|
|
2561
|
+
*/
|
|
558
2562
|
export declare function isRequiredArgument(arg: GraphQLArgument | GraphQLVariableSignature): boolean;
|
|
2563
|
+
/**
|
|
2564
|
+
* A map of field names to resolved field definitions.
|
|
2565
|
+
* @typeParam TSource - Source object type passed to resolvers.
|
|
2566
|
+
* @typeParam TContext - Context object type passed to resolvers.
|
|
2567
|
+
*/
|
|
559
2568
|
export type GraphQLFieldMap<TSource, TContext> = ObjMap<GraphQLField<TSource, TContext>>;
|
|
2569
|
+
/** Default input represented as either a runtime value or a GraphQL literal. */
|
|
560
2570
|
export type GraphQLDefaultInput = {
|
|
2571
|
+
/** Runtime default value. */
|
|
561
2572
|
value: unknown;
|
|
2573
|
+
/** GraphQL literal default value is not provided in this variant. */
|
|
562
2574
|
literal?: never;
|
|
563
2575
|
} | {
|
|
2576
|
+
/** GraphQL literal default value. */
|
|
564
2577
|
literal: ConstValueNode;
|
|
2578
|
+
/** Runtime default value is not provided in this variant. */
|
|
565
2579
|
value?: never;
|
|
566
2580
|
};
|
|
567
2581
|
/**
|
|
568
2582
|
* Custom extensions
|
|
569
|
-
*
|
|
570
2583
|
* @remarks
|
|
571
2584
|
* Use a unique identifier name for your extension, for example the name of
|
|
572
2585
|
* your library or project. Do not use a shortened identifier as this increases
|
|
@@ -583,9 +2596,9 @@ export interface GraphQLInterfaceTypeExtensions {
|
|
|
583
2596
|
* is used to describe what types are possible, what fields are in common across
|
|
584
2597
|
* all types, as well as a function to determine which type is actually used
|
|
585
2598
|
* when the field is resolved.
|
|
586
|
-
*
|
|
587
|
-
*
|
|
588
|
-
*
|
|
2599
|
+
* @typeParam TSource - Source object type passed to resolvers.
|
|
2600
|
+
* @typeParam TContext - Context object type passed to resolvers.
|
|
2601
|
+
* @example
|
|
589
2602
|
* ```ts
|
|
590
2603
|
* const EntityType = new GraphQLInterfaceType({
|
|
591
2604
|
* name: 'Entity',
|
|
@@ -596,27 +2609,223 @@ export interface GraphQLInterfaceTypeExtensions {
|
|
|
596
2609
|
* ```
|
|
597
2610
|
*/
|
|
598
2611
|
export declare class GraphQLInterfaceType<TSource = any, TContext = any> implements GraphQLSchemaElement {
|
|
599
|
-
|
|
2612
|
+
/** The GraphQL name for this schema element. */
|
|
600
2613
|
name: string;
|
|
2614
|
+
/** Human-readable description for this schema element, if provided. */
|
|
601
2615
|
description: Maybe<string>;
|
|
2616
|
+
/** Function that resolves the concrete object type for this abstract type. */
|
|
602
2617
|
resolveType: Maybe<GraphQLTypeResolver<TSource, TContext>>;
|
|
2618
|
+
/** Extension fields to include in the formatted result. */
|
|
603
2619
|
extensions: Readonly<GraphQLInterfaceTypeExtensions>;
|
|
2620
|
+
/** AST node from which this schema element was built, if available. */
|
|
604
2621
|
astNode: Maybe<InterfaceTypeDefinitionNode>;
|
|
2622
|
+
/** AST extension nodes applied to this schema element. */
|
|
605
2623
|
extensionASTNodes: ReadonlyArray<InterfaceTypeExtensionNode>;
|
|
606
2624
|
private _fields;
|
|
607
2625
|
private _interfaces;
|
|
2626
|
+
/**
|
|
2627
|
+
* Creates a GraphQLInterfaceType instance.
|
|
2628
|
+
* @param config - Configuration describing this object.
|
|
2629
|
+
* @example
|
|
2630
|
+
* ```ts
|
|
2631
|
+
* import { parse } from 'graphql/language';
|
|
2632
|
+
* import { GraphQLID, GraphQLInterfaceType, GraphQLNonNull } from 'graphql/type';
|
|
2633
|
+
*
|
|
2634
|
+
* const document = parse(`
|
|
2635
|
+
* interface Node {
|
|
2636
|
+
* id: ID!
|
|
2637
|
+
* }
|
|
2638
|
+
*
|
|
2639
|
+
* interface Resource implements Node {
|
|
2640
|
+
* id: ID!
|
|
2641
|
+
* }
|
|
2642
|
+
*
|
|
2643
|
+
* extend interface Resource {
|
|
2644
|
+
* url: String
|
|
2645
|
+
* }
|
|
2646
|
+
* `);
|
|
2647
|
+
*
|
|
2648
|
+
* const Node = new GraphQLInterfaceType({
|
|
2649
|
+
* name: 'Node',
|
|
2650
|
+
* fields: {
|
|
2651
|
+
* id: { type: new GraphQLNonNull(GraphQLID) },
|
|
2652
|
+
* },
|
|
2653
|
+
* });
|
|
2654
|
+
*
|
|
2655
|
+
* const Resource = new GraphQLInterfaceType({
|
|
2656
|
+
* name: 'Resource',
|
|
2657
|
+
* description: 'An addressable resource.',
|
|
2658
|
+
* interfaces: [Node],
|
|
2659
|
+
* fields: {
|
|
2660
|
+
* id: { type: new GraphQLNonNull(GraphQLID) },
|
|
2661
|
+
* },
|
|
2662
|
+
* resolveType: (value) => {
|
|
2663
|
+
* return typeof value === 'object' && value != null && 'url' in value
|
|
2664
|
+
* ? 'WebPage'
|
|
2665
|
+
* : null;
|
|
2666
|
+
* },
|
|
2667
|
+
* extensions: { abstract: true },
|
|
2668
|
+
* astNode: document.definitions[1],
|
|
2669
|
+
* extensionASTNodes: [ document.definitions[2] ],
|
|
2670
|
+
* });
|
|
2671
|
+
*
|
|
2672
|
+
* Resource.name; // => 'Resource'
|
|
2673
|
+
* Resource.getInterfaces(); // => [Node]
|
|
2674
|
+
* Object.keys(Resource.getFields()); // => ['id']
|
|
2675
|
+
* Resource.extensions; // => { abstract: true }
|
|
2676
|
+
* ```
|
|
2677
|
+
*/
|
|
608
2678
|
constructor(config: Readonly<GraphQLInterfaceTypeConfig<TSource, TContext>>);
|
|
2679
|
+
/**
|
|
2680
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
2681
|
+
* @returns The built-in string tag for this object.
|
|
2682
|
+
*/
|
|
609
2683
|
get [Symbol.toStringTag](): string;
|
|
2684
|
+
/**
|
|
2685
|
+
* Returns the fields defined by this type.
|
|
2686
|
+
* @returns The fields keyed by field name.
|
|
2687
|
+
* @example
|
|
2688
|
+
* ```ts
|
|
2689
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
2690
|
+
* import { assertInterfaceType } from 'graphql/type';
|
|
2691
|
+
*
|
|
2692
|
+
* const schema = buildSchema(`
|
|
2693
|
+
* interface Node {
|
|
2694
|
+
* id: ID!
|
|
2695
|
+
* }
|
|
2696
|
+
*
|
|
2697
|
+
* type User implements Node {
|
|
2698
|
+
* id: ID!
|
|
2699
|
+
* }
|
|
2700
|
+
*
|
|
2701
|
+
* type Query {
|
|
2702
|
+
* node: Node
|
|
2703
|
+
* }
|
|
2704
|
+
* `);
|
|
2705
|
+
*
|
|
2706
|
+
* const Node = assertInterfaceType(schema.getType('Node'));
|
|
2707
|
+
* const fields = Node.getFields();
|
|
2708
|
+
*
|
|
2709
|
+
* Object.keys(fields); // => ['id']
|
|
2710
|
+
* String(fields.id.type); // => 'ID!'
|
|
2711
|
+
* ```
|
|
2712
|
+
*/
|
|
610
2713
|
getFields(): GraphQLFieldMap<TSource, TContext>;
|
|
2714
|
+
/**
|
|
2715
|
+
* Returns the interfaces implemented by this type.
|
|
2716
|
+
* @returns The implemented interfaces.
|
|
2717
|
+
* @example
|
|
2718
|
+
* ```ts
|
|
2719
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
2720
|
+
* import { assertInterfaceType } from 'graphql/type';
|
|
2721
|
+
*
|
|
2722
|
+
* const schema = buildSchema(`
|
|
2723
|
+
* interface Resource {
|
|
2724
|
+
* url: String!
|
|
2725
|
+
* }
|
|
2726
|
+
*
|
|
2727
|
+
* interface Image implements Resource {
|
|
2728
|
+
* url: String!
|
|
2729
|
+
* width: Int
|
|
2730
|
+
* }
|
|
2731
|
+
*
|
|
2732
|
+
* type Photo implements Resource & Image {
|
|
2733
|
+
* url: String!
|
|
2734
|
+
* width: Int
|
|
2735
|
+
* }
|
|
2736
|
+
*
|
|
2737
|
+
* type Query {
|
|
2738
|
+
* image: Image
|
|
2739
|
+
* }
|
|
2740
|
+
* `);
|
|
2741
|
+
*
|
|
2742
|
+
* const Image = assertInterfaceType(schema.getType('Image'));
|
|
2743
|
+
*
|
|
2744
|
+
* Image.getInterfaces().map((type) => type.name); // => ['Resource']
|
|
2745
|
+
* ```
|
|
2746
|
+
*/
|
|
611
2747
|
getInterfaces(): ReadonlyArray<GraphQLInterfaceType>;
|
|
2748
|
+
/**
|
|
2749
|
+
* Returns a normalized configuration object for this object.
|
|
2750
|
+
* @returns A configuration object that can be used to recreate this object.
|
|
2751
|
+
* @example
|
|
2752
|
+
* ```ts
|
|
2753
|
+
* import { GraphQLID, GraphQLInterfaceType, GraphQLNonNull } from 'graphql/type';
|
|
2754
|
+
*
|
|
2755
|
+
* const Node = new GraphQLInterfaceType({
|
|
2756
|
+
* name: 'Node',
|
|
2757
|
+
* fields: {
|
|
2758
|
+
* id: { type: new GraphQLNonNull(GraphQLID) },
|
|
2759
|
+
* },
|
|
2760
|
+
* });
|
|
2761
|
+
*
|
|
2762
|
+
* const config = Node.toConfig();
|
|
2763
|
+
* const NodeCopy = new GraphQLInterfaceType(config);
|
|
2764
|
+
*
|
|
2765
|
+
* String(config.fields.id.type); // => 'ID!'
|
|
2766
|
+
* String(NodeCopy.getFields().id.type); // => 'ID!'
|
|
2767
|
+
* ```
|
|
2768
|
+
*/
|
|
612
2769
|
toConfig(): GraphQLInterfaceTypeNormalizedConfig<TSource, TContext>;
|
|
2770
|
+
/**
|
|
2771
|
+
* Returns the schema coordinate identifying this interface type.
|
|
2772
|
+
* @returns The schema coordinate for this interface type.
|
|
2773
|
+
* @example
|
|
2774
|
+
* ```ts
|
|
2775
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
2776
|
+
* import { assertInterfaceType } from 'graphql/type';
|
|
2777
|
+
*
|
|
2778
|
+
* const schema = buildSchema(`
|
|
2779
|
+
* interface Node {
|
|
2780
|
+
* id: ID!
|
|
2781
|
+
* }
|
|
2782
|
+
*
|
|
2783
|
+
* type User implements Node {
|
|
2784
|
+
* id: ID!
|
|
2785
|
+
* }
|
|
2786
|
+
*
|
|
2787
|
+
* type Query {
|
|
2788
|
+
* node: Node
|
|
2789
|
+
* }
|
|
2790
|
+
* `);
|
|
2791
|
+
*
|
|
2792
|
+
* const Node = assertInterfaceType(schema.getType('Node'));
|
|
2793
|
+
*
|
|
2794
|
+
* Node.toString(); // => 'Node'
|
|
2795
|
+
* ```
|
|
2796
|
+
*/
|
|
613
2797
|
toString(): string;
|
|
2798
|
+
/**
|
|
2799
|
+
* Returns the JSON representation used when this object is serialized.
|
|
2800
|
+
* @returns The JSON-serializable representation.
|
|
2801
|
+
* @example
|
|
2802
|
+
* ```ts
|
|
2803
|
+
* import { GraphQLInterfaceType, GraphQLString } from 'graphql/type';
|
|
2804
|
+
*
|
|
2805
|
+
* const Named = new GraphQLInterfaceType({
|
|
2806
|
+
* name: 'Named',
|
|
2807
|
+
* fields: { name: { type: GraphQLString } },
|
|
2808
|
+
* });
|
|
2809
|
+
*
|
|
2810
|
+
* Named.toJSON(); // => 'Named'
|
|
2811
|
+
* JSON.stringify({ type: Named }); // => '{"type":"Named"}'
|
|
2812
|
+
* ```
|
|
2813
|
+
*/
|
|
614
2814
|
toJSON(): string;
|
|
615
2815
|
}
|
|
2816
|
+
/**
|
|
2817
|
+
* Configuration used to construct a GraphQLInterfaceType.
|
|
2818
|
+
* @typeParam TSource - Source object type passed to resolvers.
|
|
2819
|
+
* @typeParam TContext - Context object type passed to resolvers.
|
|
2820
|
+
*/
|
|
616
2821
|
export interface GraphQLInterfaceTypeConfig<TSource, TContext> {
|
|
2822
|
+
/** The GraphQL name for this schema element. */
|
|
617
2823
|
name: string;
|
|
2824
|
+
/** Human-readable description for this schema element, if provided. */
|
|
618
2825
|
description?: Maybe<string>;
|
|
2826
|
+
/** Interfaces implemented by this object or interface type. */
|
|
619
2827
|
interfaces?: ThunkReadonlyArray<GraphQLInterfaceType> | undefined;
|
|
2828
|
+
/** Fields declared by this object, interface, input object, or literal. */
|
|
620
2829
|
fields: ThunkObjMap<GraphQLFieldConfig<TSource, TContext>>;
|
|
621
2830
|
/**
|
|
622
2831
|
* Optionally provide a custom type resolver function. If one is not provided,
|
|
@@ -624,10 +2833,14 @@ export interface GraphQLInterfaceTypeConfig<TSource, TContext> {
|
|
|
624
2833
|
* Object type.
|
|
625
2834
|
*/
|
|
626
2835
|
resolveType?: Maybe<GraphQLTypeResolver<TSource, TContext>>;
|
|
2836
|
+
/** Extension fields to include in the formatted result. */
|
|
627
2837
|
extensions?: Maybe<Readonly<GraphQLInterfaceTypeExtensions>>;
|
|
2838
|
+
/** AST node from which this schema element was built, if available. */
|
|
628
2839
|
astNode?: Maybe<InterfaceTypeDefinitionNode>;
|
|
2840
|
+
/** AST extension nodes applied to this schema element. */
|
|
629
2841
|
extensionASTNodes?: Maybe<ReadonlyArray<InterfaceTypeExtensionNode>>;
|
|
630
2842
|
}
|
|
2843
|
+
/** @internal */
|
|
631
2844
|
export interface GraphQLInterfaceTypeNormalizedConfig<TSource, TContext> extends GraphQLInterfaceTypeConfig<TSource, TContext> {
|
|
632
2845
|
interfaces: ReadonlyArray<GraphQLInterfaceType>;
|
|
633
2846
|
fields: GraphQLFieldNormalizedConfigMap<TSource, TContext>;
|
|
@@ -636,7 +2849,6 @@ export interface GraphQLInterfaceTypeNormalizedConfig<TSource, TContext> extends
|
|
|
636
2849
|
}
|
|
637
2850
|
/**
|
|
638
2851
|
* Custom extensions
|
|
639
|
-
*
|
|
640
2852
|
* @remarks
|
|
641
2853
|
* Use a unique identifier name for your extension, for example the name of
|
|
642
2854
|
* your library or project. Do not use a shortened identifier as this increases
|
|
@@ -652,14 +2864,14 @@ export interface GraphQLUnionTypeExtensions {
|
|
|
652
2864
|
* When a field can return one of a heterogeneous set of types, a Union type
|
|
653
2865
|
* is used to describe what types are possible as well as providing a function
|
|
654
2866
|
* to determine which type is actually used when the field is resolved.
|
|
655
|
-
*
|
|
656
|
-
*
|
|
657
|
-
*
|
|
2867
|
+
* @typeParam TSource - Source object type passed to resolvers.
|
|
2868
|
+
* @typeParam TContext - Context object type passed to resolvers.
|
|
2869
|
+
* @example
|
|
658
2870
|
* ```ts
|
|
659
2871
|
* const PetType = new GraphQLUnionType({
|
|
660
2872
|
* name: 'Pet',
|
|
661
|
-
* types: [
|
|
662
|
-
* resolveType(value) {
|
|
2873
|
+
* types: [DogType, CatType],
|
|
2874
|
+
* resolveType: (value) => {
|
|
663
2875
|
* if (value instanceof Dog) {
|
|
664
2876
|
* return DogType;
|
|
665
2877
|
* }
|
|
@@ -671,24 +2883,183 @@ export interface GraphQLUnionTypeExtensions {
|
|
|
671
2883
|
* ```
|
|
672
2884
|
*/
|
|
673
2885
|
export declare class GraphQLUnionType<TSource = any, TContext = any> implements GraphQLSchemaElement {
|
|
674
|
-
|
|
2886
|
+
/** The GraphQL name for this schema element. */
|
|
675
2887
|
name: string;
|
|
2888
|
+
/** Human-readable description for this schema element, if provided. */
|
|
676
2889
|
description: Maybe<string>;
|
|
2890
|
+
/** Function that resolves the concrete object type for this abstract type. */
|
|
677
2891
|
resolveType: Maybe<GraphQLTypeResolver<TSource, TContext>>;
|
|
2892
|
+
/** Extension fields to include in the formatted result. */
|
|
678
2893
|
extensions: Readonly<GraphQLUnionTypeExtensions>;
|
|
2894
|
+
/** AST node from which this schema element was built, if available. */
|
|
679
2895
|
astNode: Maybe<UnionTypeDefinitionNode>;
|
|
2896
|
+
/** AST extension nodes applied to this schema element. */
|
|
680
2897
|
extensionASTNodes: ReadonlyArray<UnionTypeExtensionNode>;
|
|
681
2898
|
private _types;
|
|
2899
|
+
/**
|
|
2900
|
+
* Creates a GraphQLUnionType instance.
|
|
2901
|
+
* @param config - Configuration describing this object.
|
|
2902
|
+
* @example
|
|
2903
|
+
* ```ts
|
|
2904
|
+
* import { parse } from 'graphql/language';
|
|
2905
|
+
* import { GraphQLObjectType, GraphQLString, GraphQLUnionType } from 'graphql/type';
|
|
2906
|
+
*
|
|
2907
|
+
* const document = parse(`
|
|
2908
|
+
* union Media = Photo | Video
|
|
2909
|
+
*
|
|
2910
|
+
* extend union Media = Audio
|
|
2911
|
+
* `);
|
|
2912
|
+
*
|
|
2913
|
+
* const Photo = new GraphQLObjectType({
|
|
2914
|
+
* name: 'Photo',
|
|
2915
|
+
* fields: { url: { type: GraphQLString } },
|
|
2916
|
+
* });
|
|
2917
|
+
* const Video = new GraphQLObjectType({
|
|
2918
|
+
* name: 'Video',
|
|
2919
|
+
* fields: { url: { type: GraphQLString } },
|
|
2920
|
+
* });
|
|
2921
|
+
*
|
|
2922
|
+
* const Media = new GraphQLUnionType({
|
|
2923
|
+
* name: 'Media',
|
|
2924
|
+
* description: 'Media that can appear in a search result.',
|
|
2925
|
+
* types: [Photo, Video],
|
|
2926
|
+
* resolveType: (value) => {
|
|
2927
|
+
* return typeof value === 'object' && value != null && 'duration' in value
|
|
2928
|
+
* ? 'Video'
|
|
2929
|
+
* : 'Photo';
|
|
2930
|
+
* },
|
|
2931
|
+
* extensions: { searchable: true },
|
|
2932
|
+
* astNode: document.definitions[0],
|
|
2933
|
+
* extensionASTNodes: [ document.definitions[1] ],
|
|
2934
|
+
* });
|
|
2935
|
+
*
|
|
2936
|
+
* Media.description; // => 'Media that can appear in a search result.'
|
|
2937
|
+
* Media.getTypes().map((type) => type.name); // => ['Photo', 'Video']
|
|
2938
|
+
* Media.extensions; // => { searchable: true }
|
|
2939
|
+
* ```
|
|
2940
|
+
*/
|
|
682
2941
|
constructor(config: Readonly<GraphQLUnionTypeConfig<TSource, TContext>>);
|
|
2942
|
+
/**
|
|
2943
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
2944
|
+
* @returns The built-in string tag for this object.
|
|
2945
|
+
*/
|
|
683
2946
|
get [Symbol.toStringTag](): string;
|
|
2947
|
+
/**
|
|
2948
|
+
* Returns the object types included in this union.
|
|
2949
|
+
* @returns The union member object types.
|
|
2950
|
+
* @example
|
|
2951
|
+
* ```ts
|
|
2952
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
2953
|
+
* import { assertUnionType } from 'graphql/type';
|
|
2954
|
+
*
|
|
2955
|
+
* const schema = buildSchema(`
|
|
2956
|
+
* type Photo {
|
|
2957
|
+
* url: String!
|
|
2958
|
+
* }
|
|
2959
|
+
*
|
|
2960
|
+
* type Video {
|
|
2961
|
+
* url: String!
|
|
2962
|
+
* }
|
|
2963
|
+
*
|
|
2964
|
+
* union Media = Photo | Video
|
|
2965
|
+
*
|
|
2966
|
+
* type Query {
|
|
2967
|
+
* media: [Media]
|
|
2968
|
+
* }
|
|
2969
|
+
* `);
|
|
2970
|
+
*
|
|
2971
|
+
* const Media = assertUnionType(schema.getType('Media'));
|
|
2972
|
+
*
|
|
2973
|
+
* Media.getTypes().map((type) => type.name); // => ['Photo', 'Video']
|
|
2974
|
+
* ```
|
|
2975
|
+
*/
|
|
684
2976
|
getTypes(): ReadonlyArray<GraphQLObjectType>;
|
|
2977
|
+
/**
|
|
2978
|
+
* Returns a normalized configuration object for this object.
|
|
2979
|
+
* @returns A configuration object that can be used to recreate this object.
|
|
2980
|
+
* @example
|
|
2981
|
+
* ```ts
|
|
2982
|
+
* import { GraphQLObjectType, GraphQLString, GraphQLUnionType } from 'graphql/type';
|
|
2983
|
+
*
|
|
2984
|
+
* const Photo = new GraphQLObjectType({
|
|
2985
|
+
* name: 'Photo',
|
|
2986
|
+
* fields: { url: { type: GraphQLString } },
|
|
2987
|
+
* });
|
|
2988
|
+
* const Video = new GraphQLObjectType({
|
|
2989
|
+
* name: 'Video',
|
|
2990
|
+
* fields: { url: { type: GraphQLString } },
|
|
2991
|
+
* });
|
|
2992
|
+
* const Media = new GraphQLUnionType({
|
|
2993
|
+
* name: 'Media',
|
|
2994
|
+
* types: [Photo, Video],
|
|
2995
|
+
* });
|
|
2996
|
+
*
|
|
2997
|
+
* const config = Media.toConfig();
|
|
2998
|
+
* const MediaCopy = new GraphQLUnionType(config);
|
|
2999
|
+
*
|
|
3000
|
+
* MediaCopy.getTypes().map((type) => type.name); // => ['Photo', 'Video']
|
|
3001
|
+
* ```
|
|
3002
|
+
*/
|
|
685
3003
|
toConfig(): GraphQLUnionTypeNormalizedConfig<TSource, TContext>;
|
|
3004
|
+
/**
|
|
3005
|
+
* Returns the schema coordinate identifying this union type.
|
|
3006
|
+
* @returns The schema coordinate for this union type.
|
|
3007
|
+
* @example
|
|
3008
|
+
* ```ts
|
|
3009
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
3010
|
+
* import { assertUnionType } from 'graphql/type';
|
|
3011
|
+
*
|
|
3012
|
+
* const schema = buildSchema(`
|
|
3013
|
+
* type Photo {
|
|
3014
|
+
* url: String!
|
|
3015
|
+
* }
|
|
3016
|
+
*
|
|
3017
|
+
* union SearchResult = Photo
|
|
3018
|
+
*
|
|
3019
|
+
* type Query {
|
|
3020
|
+
* search: [SearchResult]
|
|
3021
|
+
* }
|
|
3022
|
+
* `);
|
|
3023
|
+
*
|
|
3024
|
+
* const SearchResult = assertUnionType(schema.getType('SearchResult'));
|
|
3025
|
+
*
|
|
3026
|
+
* SearchResult.toString(); // => 'SearchResult'
|
|
3027
|
+
* ```
|
|
3028
|
+
*/
|
|
686
3029
|
toString(): string;
|
|
3030
|
+
/**
|
|
3031
|
+
* Returns the JSON representation used when this object is serialized.
|
|
3032
|
+
* @returns The JSON-serializable representation.
|
|
3033
|
+
* @example
|
|
3034
|
+
* ```ts
|
|
3035
|
+
* import { GraphQLObjectType, GraphQLString, GraphQLUnionType } from 'graphql/type';
|
|
3036
|
+
*
|
|
3037
|
+
* const Photo = new GraphQLObjectType({
|
|
3038
|
+
* name: 'Photo',
|
|
3039
|
+
* fields: { url: { type: GraphQLString } },
|
|
3040
|
+
* });
|
|
3041
|
+
* const SearchResult = new GraphQLUnionType({
|
|
3042
|
+
* name: 'SearchResult',
|
|
3043
|
+
* types: [Photo],
|
|
3044
|
+
* });
|
|
3045
|
+
*
|
|
3046
|
+
* SearchResult.toJSON(); // => 'SearchResult'
|
|
3047
|
+
* JSON.stringify({ type: SearchResult }); // => '{"type":"SearchResult"}'
|
|
3048
|
+
* ```
|
|
3049
|
+
*/
|
|
687
3050
|
toJSON(): string;
|
|
688
3051
|
}
|
|
3052
|
+
/**
|
|
3053
|
+
* Configuration used to construct a GraphQLUnionType.
|
|
3054
|
+
* @typeParam TSource - Source object type passed to resolvers.
|
|
3055
|
+
* @typeParam TContext - Context object type passed to resolvers.
|
|
3056
|
+
*/
|
|
689
3057
|
export interface GraphQLUnionTypeConfig<TSource, TContext> {
|
|
3058
|
+
/** The GraphQL name for this schema element. */
|
|
690
3059
|
name: string;
|
|
3060
|
+
/** Human-readable description for this schema element, if provided. */
|
|
691
3061
|
description?: Maybe<string>;
|
|
3062
|
+
/** Object types that belong to this union type. */
|
|
692
3063
|
types: ThunkReadonlyArray<GraphQLObjectType>;
|
|
693
3064
|
/**
|
|
694
3065
|
* Optionally provide a custom type resolver function. If one is not provided,
|
|
@@ -696,10 +3067,14 @@ export interface GraphQLUnionTypeConfig<TSource, TContext> {
|
|
|
696
3067
|
* Object type.
|
|
697
3068
|
*/
|
|
698
3069
|
resolveType?: Maybe<GraphQLTypeResolver<TSource, TContext>>;
|
|
3070
|
+
/** Extension fields to include in the formatted result. */
|
|
699
3071
|
extensions?: Maybe<Readonly<GraphQLUnionTypeExtensions>>;
|
|
3072
|
+
/** AST node from which this schema element was built, if available. */
|
|
700
3073
|
astNode?: Maybe<UnionTypeDefinitionNode>;
|
|
3074
|
+
/** AST extension nodes applied to this schema element. */
|
|
701
3075
|
extensionASTNodes?: Maybe<ReadonlyArray<UnionTypeExtensionNode>>;
|
|
702
3076
|
}
|
|
3077
|
+
/** @internal */
|
|
703
3078
|
export interface GraphQLUnionTypeNormalizedConfig<TSource, TContext> extends GraphQLUnionTypeConfig<TSource, TContext> {
|
|
704
3079
|
types: ReadonlyArray<GraphQLObjectType>;
|
|
705
3080
|
extensions: Readonly<GraphQLUnionTypeExtensions>;
|
|
@@ -707,7 +3082,6 @@ export interface GraphQLUnionTypeNormalizedConfig<TSource, TContext> extends Gra
|
|
|
707
3082
|
}
|
|
708
3083
|
/**
|
|
709
3084
|
* Custom extensions
|
|
710
|
-
*
|
|
711
3085
|
* @remarks
|
|
712
3086
|
* Use a unique identifier name for your extension, for example the name of
|
|
713
3087
|
* your library or project. Do not use a shortened identifier as this increases
|
|
@@ -720,72 +3094,417 @@ export interface GraphQLEnumTypeExtensions {
|
|
|
720
3094
|
/**
|
|
721
3095
|
* Enum Type Definition
|
|
722
3096
|
*
|
|
723
|
-
*
|
|
724
|
-
*
|
|
725
|
-
*
|
|
726
|
-
*
|
|
727
|
-
* Example:
|
|
728
|
-
*
|
|
3097
|
+
* Enum types define leaf values whose serialized form is one of a fixed set
|
|
3098
|
+
* of GraphQL enum names. Internally, enum values can map to any runtime value,
|
|
3099
|
+
* often integers.
|
|
3100
|
+
* @example
|
|
729
3101
|
* ```ts
|
|
3102
|
+
* import { GraphQLEnumType } from 'graphql/type';
|
|
3103
|
+
*
|
|
730
3104
|
* const RGBType = new GraphQLEnumType({
|
|
731
3105
|
* name: 'RGB',
|
|
732
3106
|
* values: {
|
|
733
3107
|
* RED: { value: 0 },
|
|
734
3108
|
* GREEN: { value: 1 },
|
|
735
|
-
* BLUE: { value: 2 }
|
|
736
|
-
* }
|
|
3109
|
+
* BLUE: { value: 2 },
|
|
3110
|
+
* },
|
|
737
3111
|
* });
|
|
3112
|
+
*
|
|
3113
|
+
* RGBType.getValue('GREEN')?.value; // => 1
|
|
738
3114
|
* ```
|
|
739
3115
|
*
|
|
740
3116
|
* Note: If a value is not provided in a definition, the name of the enum value
|
|
741
3117
|
* will be used as its internal value.
|
|
742
3118
|
*/
|
|
743
3119
|
export declare class GraphQLEnumType/* <T> */ implements GraphQLSchemaElement {
|
|
744
|
-
|
|
3120
|
+
/** The GraphQL name for this schema element. */
|
|
745
3121
|
name: string;
|
|
3122
|
+
/** Human-readable description for this schema element, if provided. */
|
|
746
3123
|
description: Maybe<string>;
|
|
3124
|
+
/** Extension fields to include in the formatted result. */
|
|
747
3125
|
extensions: Readonly<GraphQLEnumTypeExtensions>;
|
|
3126
|
+
/** AST node from which this schema element was built, if available. */
|
|
748
3127
|
astNode: Maybe<EnumTypeDefinitionNode>;
|
|
3128
|
+
/** AST extension nodes applied to this schema element. */
|
|
749
3129
|
extensionASTNodes: ReadonlyArray<EnumTypeExtensionNode>;
|
|
750
3130
|
private _values;
|
|
751
3131
|
private _valueLookup;
|
|
752
3132
|
private _nameLookup;
|
|
3133
|
+
/**
|
|
3134
|
+
* Creates a GraphQLEnumType instance.
|
|
3135
|
+
* @param config - Configuration describing this object.
|
|
3136
|
+
* @example
|
|
3137
|
+
* ```ts
|
|
3138
|
+
* import { parse } from 'graphql/language';
|
|
3139
|
+
* import { GraphQLEnumType } from 'graphql/type';
|
|
3140
|
+
*
|
|
3141
|
+
* const document = parse(`
|
|
3142
|
+
* enum Episode {
|
|
3143
|
+
* NEW_HOPE
|
|
3144
|
+
* EMPIRE
|
|
3145
|
+
* JEDI
|
|
3146
|
+
* }
|
|
3147
|
+
*
|
|
3148
|
+
* extend enum Episode {
|
|
3149
|
+
* FORCE_AWAKENS
|
|
3150
|
+
* }
|
|
3151
|
+
* `);
|
|
3152
|
+
* const definition = document.definitions[0];
|
|
3153
|
+
*
|
|
3154
|
+
* const Episode = new GraphQLEnumType({
|
|
3155
|
+
* name: 'Episode',
|
|
3156
|
+
* description: 'A Star Wars film episode.',
|
|
3157
|
+
* values: {
|
|
3158
|
+
* NEW_HOPE: {
|
|
3159
|
+
* value: 4,
|
|
3160
|
+
* description: 'Released in 1977.',
|
|
3161
|
+
* extensions: { trilogy: 'original' },
|
|
3162
|
+
* astNode: definition.values[0],
|
|
3163
|
+
* },
|
|
3164
|
+
* EMPIRE: { value: 5, astNode: definition.values[1] },
|
|
3165
|
+
* JEDI: {
|
|
3166
|
+
* value: 6,
|
|
3167
|
+
* deprecationReason: 'Use RETURN_OF_THE_JEDI.',
|
|
3168
|
+
* astNode: definition.values[2],
|
|
3169
|
+
* },
|
|
3170
|
+
* },
|
|
3171
|
+
* extensions: { catalog: 'films' },
|
|
3172
|
+
* astNode: definition,
|
|
3173
|
+
* extensionASTNodes: [ document.definitions[1] ],
|
|
3174
|
+
* });
|
|
3175
|
+
*
|
|
3176
|
+
* Episode.description; // => 'A Star Wars film episode.'
|
|
3177
|
+
* Episode.coerceOutputValue(5); // => 'EMPIRE'
|
|
3178
|
+
* Episode.coerceInputValue('JEDI'); // => 6
|
|
3179
|
+
* Episode.getValue('JEDI').deprecationReason; // => 'Use RETURN_OF_THE_JEDI.'
|
|
3180
|
+
* Episode.extensions; // => { catalog: 'films' }
|
|
3181
|
+
* ```
|
|
3182
|
+
*/
|
|
753
3183
|
constructor(config: Readonly<GraphQLEnumTypeConfig>);
|
|
3184
|
+
/**
|
|
3185
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
3186
|
+
* @returns The built-in string tag for this object.
|
|
3187
|
+
*/
|
|
754
3188
|
get [Symbol.toStringTag](): string;
|
|
3189
|
+
/**
|
|
3190
|
+
* Returns the values defined by this enum type.
|
|
3191
|
+
* @returns Enum value definitions in schema order.
|
|
3192
|
+
* @example
|
|
3193
|
+
* ```ts
|
|
3194
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
3195
|
+
* import { assertEnumType } from 'graphql/type';
|
|
3196
|
+
*
|
|
3197
|
+
* const schema = buildSchema(`
|
|
3198
|
+
* enum Episode {
|
|
3199
|
+
* NEW_HOPE
|
|
3200
|
+
* EMPIRE
|
|
3201
|
+
* JEDI
|
|
3202
|
+
* }
|
|
3203
|
+
*
|
|
3204
|
+
* type Query {
|
|
3205
|
+
* episode: Episode
|
|
3206
|
+
* }
|
|
3207
|
+
* `);
|
|
3208
|
+
*
|
|
3209
|
+
* const Episode = assertEnumType(schema.getType('Episode'));
|
|
3210
|
+
*
|
|
3211
|
+
* Episode.getValues().map((value) => value.name); // => ['NEW_HOPE', 'EMPIRE', 'JEDI']
|
|
3212
|
+
* ```
|
|
3213
|
+
*/
|
|
755
3214
|
getValues(): ReadonlyArray<GraphQLEnumValue>;
|
|
3215
|
+
/**
|
|
3216
|
+
* Returns the enum value definition for a value name.
|
|
3217
|
+
* @param name - The GraphQL name to look up.
|
|
3218
|
+
* @returns The matching enum value definition, if it exists.
|
|
3219
|
+
* @example
|
|
3220
|
+
* ```ts
|
|
3221
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
3222
|
+
* import { assertEnumType } from 'graphql/type';
|
|
3223
|
+
*
|
|
3224
|
+
* const schema = buildSchema(`
|
|
3225
|
+
* enum Episode {
|
|
3226
|
+
* NEW_HOPE
|
|
3227
|
+
* EMPIRE
|
|
3228
|
+
* }
|
|
3229
|
+
*
|
|
3230
|
+
* type Query {
|
|
3231
|
+
* episode: Episode
|
|
3232
|
+
* }
|
|
3233
|
+
* `);
|
|
3234
|
+
*
|
|
3235
|
+
* const Episode = assertEnumType(schema.getType('Episode'));
|
|
3236
|
+
*
|
|
3237
|
+
* Episode.getValue('EMPIRE')?.name; // => 'EMPIRE'
|
|
3238
|
+
* Episode.getValue('JEDI'); // => undefined
|
|
3239
|
+
* ```
|
|
3240
|
+
*/
|
|
756
3241
|
getValue(name: string): Maybe<GraphQLEnumValue>;
|
|
757
|
-
/**
|
|
3242
|
+
/**
|
|
3243
|
+
* Serializes a runtime enum value as a GraphQL enum name.
|
|
3244
|
+
* @param outputValue - Runtime enum value to serialize.
|
|
3245
|
+
* @returns The GraphQL enum name for the runtime value.
|
|
3246
|
+
*
|
|
3247
|
+
* This deprecated method delegates to `coerceOutputValue()`; call
|
|
3248
|
+
* `coerceOutputValue()` directly instead.
|
|
3249
|
+
* @example
|
|
3250
|
+
* ```ts
|
|
3251
|
+
* import { GraphQLEnumType } from 'graphql/type';
|
|
3252
|
+
*
|
|
3253
|
+
* const RGB = new GraphQLEnumType({
|
|
3254
|
+
* name: 'RGB',
|
|
3255
|
+
* values: {
|
|
3256
|
+
* RED: { value: 0 },
|
|
3257
|
+
* GREEN: { value: 1 },
|
|
3258
|
+
* BLUE: { value: 2 },
|
|
3259
|
+
* },
|
|
3260
|
+
* });
|
|
3261
|
+
*
|
|
3262
|
+
* RGB.serialize(1); // => 'GREEN'
|
|
3263
|
+
* RGB.serialize(3); // throws an error
|
|
3264
|
+
* ```
|
|
3265
|
+
* @deprecated use `coerceOutputValue()` instead, `serialize()` will be removed in v18
|
|
3266
|
+
*/
|
|
758
3267
|
serialize(outputValue: unknown): Maybe<string>;
|
|
3268
|
+
/**
|
|
3269
|
+
* Coerces a runtime enum value to a GraphQL enum name.
|
|
3270
|
+
* @param outputValue - Runtime enum value to coerce.
|
|
3271
|
+
* @returns The GraphQL enum name for the runtime value.
|
|
3272
|
+
* @example
|
|
3273
|
+
* ```ts
|
|
3274
|
+
* import { GraphQLEnumType } from 'graphql/type';
|
|
3275
|
+
*
|
|
3276
|
+
* const RGB = new GraphQLEnumType({
|
|
3277
|
+
* name: 'RGB',
|
|
3278
|
+
* values: {
|
|
3279
|
+
* RED: { value: 0 },
|
|
3280
|
+
* GREEN: { value: 1 },
|
|
3281
|
+
* BLUE: { value: 2 },
|
|
3282
|
+
* },
|
|
3283
|
+
* });
|
|
3284
|
+
*
|
|
3285
|
+
* RGB.coerceOutputValue(1); // => 'GREEN'
|
|
3286
|
+
* RGB.coerceOutputValue(3); // throws an error
|
|
3287
|
+
* ```
|
|
3288
|
+
*/
|
|
759
3289
|
coerceOutputValue(outputValue: unknown): Maybe<string>;
|
|
760
|
-
/**
|
|
3290
|
+
/**
|
|
3291
|
+
* Deprecated legacy enum parser for externally provided input values. Use
|
|
3292
|
+
* `coerceInputValue()` instead.
|
|
3293
|
+
* @param inputValue - External enum name to parse.
|
|
3294
|
+
* @param hideSuggestions - Whether suggestion text should be omitted from errors.
|
|
3295
|
+
* @returns The internal runtime value for the enum name.
|
|
3296
|
+
* @example
|
|
3297
|
+
* ```ts
|
|
3298
|
+
* import { GraphQLEnumType } from 'graphql/type';
|
|
3299
|
+
*
|
|
3300
|
+
* const RGB = new GraphQLEnumType({
|
|
3301
|
+
* name: 'RGB',
|
|
3302
|
+
* values: {
|
|
3303
|
+
* RED: { value: 0 },
|
|
3304
|
+
* GREEN: { value: 1 },
|
|
3305
|
+
* BLUE: { value: 2 },
|
|
3306
|
+
* },
|
|
3307
|
+
* });
|
|
3308
|
+
*
|
|
3309
|
+
* RGB.parseValue('BLUE'); // => 2
|
|
3310
|
+
* RGB.parseValue('PURPLE', true); // throws an error
|
|
3311
|
+
* ```
|
|
3312
|
+
* @deprecated use `coerceInputValue()` instead, `parseValue()` will be removed in v18
|
|
3313
|
+
*/
|
|
761
3314
|
parseValue(inputValue: unknown, hideSuggestions?: Maybe<boolean>): Maybe<any>;
|
|
3315
|
+
/**
|
|
3316
|
+
* Coerces an external enum name to its internal runtime value.
|
|
3317
|
+
* @param inputValue - External enum name to coerce.
|
|
3318
|
+
* @param hideSuggestions - Whether suggestion text should be omitted from errors.
|
|
3319
|
+
* @returns The internal runtime value for the enum name.
|
|
3320
|
+
* @example
|
|
3321
|
+
* ```ts
|
|
3322
|
+
* import { GraphQLEnumType } from 'graphql/type';
|
|
3323
|
+
*
|
|
3324
|
+
* const RGB = new GraphQLEnumType({
|
|
3325
|
+
* name: 'RGB',
|
|
3326
|
+
* values: {
|
|
3327
|
+
* RED: { value: 0 },
|
|
3328
|
+
* GREEN: { value: 1 },
|
|
3329
|
+
* BLUE: { value: 2 },
|
|
3330
|
+
* },
|
|
3331
|
+
* });
|
|
3332
|
+
*
|
|
3333
|
+
* RGB.coerceInputValue('BLUE'); // => 2
|
|
3334
|
+
* RGB.coerceInputValue('PURPLE'); // throws an error
|
|
3335
|
+
* RGB.coerceInputValue(2); // throws an error
|
|
3336
|
+
* ```
|
|
3337
|
+
*/
|
|
762
3338
|
coerceInputValue(inputValue: unknown, hideSuggestions?: Maybe<boolean>): Maybe<any>;
|
|
763
|
-
/**
|
|
3339
|
+
/**
|
|
3340
|
+
* Deprecated legacy enum parser for externally provided input literals. Use
|
|
3341
|
+
* `coerceInputLiteral()` instead.
|
|
3342
|
+
* @param valueNode - Enum value AST node to parse.
|
|
3343
|
+
* @param _variables - Deprecated variable values parameter that is no longer used.
|
|
3344
|
+
* @param hideSuggestions - Whether suggestion text should be omitted from errors.
|
|
3345
|
+
* @returns The internal runtime value for the enum literal.
|
|
3346
|
+
* @example
|
|
3347
|
+
* ```ts
|
|
3348
|
+
* import { parseValue } from 'graphql/language';
|
|
3349
|
+
* import { GraphQLEnumType } from 'graphql/type';
|
|
3350
|
+
*
|
|
3351
|
+
* const RGB = new GraphQLEnumType({
|
|
3352
|
+
* name: 'RGB',
|
|
3353
|
+
* values: {
|
|
3354
|
+
* RED: { value: 0 },
|
|
3355
|
+
* GREEN: { value: 1 },
|
|
3356
|
+
* BLUE: { value: 2 },
|
|
3357
|
+
* },
|
|
3358
|
+
* });
|
|
3359
|
+
*
|
|
3360
|
+
* RGB.parseLiteral(parseValue('RED')); // => 0
|
|
3361
|
+
* RGB.parseLiteral(parseValue('"RED"')); // throws an error
|
|
3362
|
+
* ```
|
|
3363
|
+
* @deprecated use `coerceInputLiteral()` instead, `parseLiteral()` will be removed in v18
|
|
3364
|
+
*/
|
|
764
3365
|
parseLiteral(valueNode: ValueNode, _variables: Maybe<ObjMap<unknown>>, hideSuggestions?: Maybe<boolean>): Maybe<any>;
|
|
3366
|
+
/**
|
|
3367
|
+
* Coerces an enum value AST node to its internal runtime value.
|
|
3368
|
+
* @param valueNode - Enum value AST node to coerce.
|
|
3369
|
+
* @param hideSuggestions - Whether suggestion text should be omitted from errors.
|
|
3370
|
+
* @returns The internal runtime value for the enum literal.
|
|
3371
|
+
* @example
|
|
3372
|
+
* ```ts
|
|
3373
|
+
* import { parseConstValue } from 'graphql/language';
|
|
3374
|
+
* import { GraphQLEnumType } from 'graphql/type';
|
|
3375
|
+
*
|
|
3376
|
+
* const RGB = new GraphQLEnumType({
|
|
3377
|
+
* name: 'RGB',
|
|
3378
|
+
* values: {
|
|
3379
|
+
* RED: { value: 0 },
|
|
3380
|
+
* GREEN: { value: 1 },
|
|
3381
|
+
* BLUE: { value: 2 },
|
|
3382
|
+
* },
|
|
3383
|
+
* });
|
|
3384
|
+
*
|
|
3385
|
+
* RGB.coerceInputLiteral(parseConstValue('RED')); // => 0
|
|
3386
|
+
* RGB.coerceInputLiteral(parseConstValue('"RED"'), true); // throws an error
|
|
3387
|
+
* ```
|
|
3388
|
+
*/
|
|
765
3389
|
coerceInputLiteral(valueNode: ConstValueNode, hideSuggestions?: Maybe<boolean>): Maybe<any>;
|
|
3390
|
+
/**
|
|
3391
|
+
* Converts a runtime enum value to a GraphQL enum value AST node.
|
|
3392
|
+
* @param value - Runtime enum value to convert.
|
|
3393
|
+
* @returns Enum value AST node, or undefined if the value is invalid.
|
|
3394
|
+
* @example
|
|
3395
|
+
* ```ts
|
|
3396
|
+
* import { print } from 'graphql/language';
|
|
3397
|
+
* import { GraphQLEnumType } from 'graphql/type';
|
|
3398
|
+
*
|
|
3399
|
+
* const RGB = new GraphQLEnumType({
|
|
3400
|
+
* name: 'RGB',
|
|
3401
|
+
* values: {
|
|
3402
|
+
* RED: { value: 0 },
|
|
3403
|
+
* GREEN: { value: 1 },
|
|
3404
|
+
* BLUE: { value: 2 },
|
|
3405
|
+
* },
|
|
3406
|
+
* });
|
|
3407
|
+
*
|
|
3408
|
+
* print(RGB.valueToLiteral(2)); // => 'BLUE'
|
|
3409
|
+
* RGB.valueToLiteral(3); // => undefined
|
|
3410
|
+
* ```
|
|
3411
|
+
*/
|
|
766
3412
|
valueToLiteral(value: unknown): ConstValueNode | undefined;
|
|
3413
|
+
/**
|
|
3414
|
+
* Returns a normalized configuration object for this object.
|
|
3415
|
+
* @returns A configuration object that can be used to recreate this object.
|
|
3416
|
+
* @example
|
|
3417
|
+
* ```ts
|
|
3418
|
+
* import { GraphQLEnumType } from 'graphql/type';
|
|
3419
|
+
*
|
|
3420
|
+
* const RGB = new GraphQLEnumType({
|
|
3421
|
+
* name: 'RGB',
|
|
3422
|
+
* values: {
|
|
3423
|
+
* RED: { value: 0 },
|
|
3424
|
+
* GREEN: { value: 1 },
|
|
3425
|
+
* BLUE: { value: 2 },
|
|
3426
|
+
* },
|
|
3427
|
+
* });
|
|
3428
|
+
*
|
|
3429
|
+
* const config = RGB.toConfig();
|
|
3430
|
+
* const RGBCopy = new GraphQLEnumType(config);
|
|
3431
|
+
*
|
|
3432
|
+
* config.values.GREEN.value; // => 1
|
|
3433
|
+
* RGBCopy.coerceOutputValue(2); // => 'BLUE'
|
|
3434
|
+
* ```
|
|
3435
|
+
*/
|
|
767
3436
|
toConfig(): GraphQLEnumTypeNormalizedConfig;
|
|
3437
|
+
/**
|
|
3438
|
+
* Returns the schema coordinate identifying this enum type.
|
|
3439
|
+
* @returns The schema coordinate for this enum type.
|
|
3440
|
+
* @example
|
|
3441
|
+
* ```ts
|
|
3442
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
3443
|
+
* import { assertEnumType } from 'graphql/type';
|
|
3444
|
+
*
|
|
3445
|
+
* const schema = buildSchema(`
|
|
3446
|
+
* enum Episode {
|
|
3447
|
+
* NEW_HOPE
|
|
3448
|
+
* }
|
|
3449
|
+
*
|
|
3450
|
+
* type Query {
|
|
3451
|
+
* episode: Episode
|
|
3452
|
+
* }
|
|
3453
|
+
* `);
|
|
3454
|
+
*
|
|
3455
|
+
* const Episode = assertEnumType(schema.getType('Episode'));
|
|
3456
|
+
*
|
|
3457
|
+
* Episode.toString(); // => 'Episode'
|
|
3458
|
+
* ```
|
|
3459
|
+
*/
|
|
768
3460
|
toString(): string;
|
|
3461
|
+
/**
|
|
3462
|
+
* Returns the JSON representation used when this object is serialized.
|
|
3463
|
+
* @returns The JSON-serializable representation.
|
|
3464
|
+
* @example
|
|
3465
|
+
* ```ts
|
|
3466
|
+
* import { GraphQLEnumType } from 'graphql/type';
|
|
3467
|
+
*
|
|
3468
|
+
* const Episode = new GraphQLEnumType({
|
|
3469
|
+
* name: 'Episode',
|
|
3470
|
+
* values: {
|
|
3471
|
+
* NEW_HOPE: {},
|
|
3472
|
+
* },
|
|
3473
|
+
* });
|
|
3474
|
+
*
|
|
3475
|
+
* Episode.toJSON(); // => 'Episode'
|
|
3476
|
+
* JSON.stringify({ type: Episode }); // => '{"type":"Episode"}'
|
|
3477
|
+
* ```
|
|
3478
|
+
*/
|
|
769
3479
|
toJSON(): string;
|
|
770
3480
|
}
|
|
3481
|
+
/** Configuration used to construct a GraphQLEnumType. */
|
|
771
3482
|
export interface GraphQLEnumTypeConfig {
|
|
3483
|
+
/** The GraphQL name for this schema element. */
|
|
772
3484
|
name: string;
|
|
3485
|
+
/** Human-readable description for this schema element, if provided. */
|
|
773
3486
|
description?: Maybe<string>;
|
|
3487
|
+
/** Values contained in this enum, list, or input-object definition. */
|
|
774
3488
|
values: ThunkObjMap<GraphQLEnumValueConfig>;
|
|
3489
|
+
/** Extension fields to include in the formatted result. */
|
|
775
3490
|
extensions?: Maybe<Readonly<GraphQLEnumTypeExtensions>>;
|
|
3491
|
+
/** AST node from which this schema element was built, if available. */
|
|
776
3492
|
astNode?: Maybe<EnumTypeDefinitionNode>;
|
|
3493
|
+
/** AST extension nodes applied to this schema element. */
|
|
777
3494
|
extensionASTNodes?: Maybe<ReadonlyArray<EnumTypeExtensionNode>>;
|
|
778
3495
|
}
|
|
3496
|
+
/** @internal */
|
|
779
3497
|
export interface GraphQLEnumTypeNormalizedConfig extends GraphQLEnumTypeConfig {
|
|
780
3498
|
values: GraphQLEnumValueNormalizedConfigMap;
|
|
781
3499
|
extensions: Readonly<GraphQLEnumTypeExtensions>;
|
|
782
3500
|
extensionASTNodes: ReadonlyArray<EnumTypeExtensionNode>;
|
|
783
3501
|
}
|
|
3502
|
+
/** A map of enum value names to enum value configuration objects. */
|
|
784
3503
|
export type GraphQLEnumValueConfigMap = ObjMap<GraphQLEnumValueConfig>;
|
|
3504
|
+
/** @internal */
|
|
785
3505
|
export type GraphQLEnumValueNormalizedConfigMap = ObjMap<GraphQLEnumValueNormalizedConfig>;
|
|
786
3506
|
/**
|
|
787
3507
|
* Custom extensions
|
|
788
|
-
*
|
|
789
3508
|
* @remarks
|
|
790
3509
|
* Use a unique identifier name for your extension, for example the name of
|
|
791
3510
|
* your library or project. Do not use a shortened identifier as this increases
|
|
@@ -795,34 +3514,125 @@ export type GraphQLEnumValueNormalizedConfigMap = ObjMap<GraphQLEnumValueNormali
|
|
|
795
3514
|
export interface GraphQLEnumValueExtensions {
|
|
796
3515
|
[attributeName: string | symbol]: unknown;
|
|
797
3516
|
}
|
|
3517
|
+
/** Configuration used to define a GraphQL enum value. */
|
|
798
3518
|
export interface GraphQLEnumValueConfig {
|
|
3519
|
+
/** Human-readable description for this schema element, if provided. */
|
|
799
3520
|
description?: Maybe<string>;
|
|
3521
|
+
/** Parsed value represented by this node. */
|
|
800
3522
|
value?: any;
|
|
3523
|
+
/** Reason this element is deprecated, if one was provided. */
|
|
801
3524
|
deprecationReason?: Maybe<string>;
|
|
3525
|
+
/** Extension fields to include in the formatted result. */
|
|
802
3526
|
extensions?: Maybe<Readonly<GraphQLEnumValueExtensions>>;
|
|
3527
|
+
/** AST node from which this schema element was built, if available. */
|
|
803
3528
|
astNode?: Maybe<EnumValueDefinitionNode>;
|
|
804
3529
|
}
|
|
3530
|
+
/** @internal */
|
|
805
3531
|
export interface GraphQLEnumValueNormalizedConfig extends GraphQLEnumValueConfig {
|
|
806
3532
|
extensions: Readonly<GraphQLEnumValueExtensions>;
|
|
807
3533
|
}
|
|
3534
|
+
/** A resolved GraphQL enum value definition. */
|
|
808
3535
|
export declare class GraphQLEnumValue implements GraphQLSchemaElement {
|
|
809
|
-
|
|
3536
|
+
/** Enum type that owns this enum value. */
|
|
810
3537
|
parentEnum: GraphQLEnumType;
|
|
3538
|
+
/** The GraphQL name for this schema element. */
|
|
811
3539
|
name: string;
|
|
3540
|
+
/** Human-readable description for this schema element, if provided. */
|
|
812
3541
|
description: Maybe<string>;
|
|
3542
|
+
/** Parsed value represented by this node. */
|
|
813
3543
|
value: any;
|
|
3544
|
+
/** Reason this element is deprecated, if one was provided. */
|
|
814
3545
|
deprecationReason: Maybe<string>;
|
|
3546
|
+
/** Extension fields to include in the formatted result. */
|
|
815
3547
|
extensions: Readonly<GraphQLEnumValueExtensions>;
|
|
3548
|
+
/** AST node from which this schema element was built, if available. */
|
|
816
3549
|
astNode: Maybe<EnumValueDefinitionNode>;
|
|
3550
|
+
/**
|
|
3551
|
+
* Creates a resolved GraphQL enum value definition.
|
|
3552
|
+
* @param parentEnum - Enum type that owns this enum value.
|
|
3553
|
+
* @param name - Enum value name.
|
|
3554
|
+
* @param config - Enum value configuration.
|
|
3555
|
+
* @example
|
|
3556
|
+
* ```ts
|
|
3557
|
+
* import { GraphQLEnumType, GraphQLEnumValue } from 'graphql/type';
|
|
3558
|
+
*
|
|
3559
|
+
* const Episode = new GraphQLEnumType({
|
|
3560
|
+
* name: 'Episode',
|
|
3561
|
+
* values: { NEW_HOPE: { value: 4 } },
|
|
3562
|
+
* });
|
|
3563
|
+
* const enumValue = new GraphQLEnumValue(Episode, 'EMPIRE', {
|
|
3564
|
+
* value: 5,
|
|
3565
|
+
* description: 'Released in 1980.',
|
|
3566
|
+
* });
|
|
3567
|
+
*
|
|
3568
|
+
* enumValue.parentEnum; // => Episode
|
|
3569
|
+
* enumValue.name; // => 'EMPIRE'
|
|
3570
|
+
* enumValue.value; // => 5
|
|
3571
|
+
* ```
|
|
3572
|
+
*/
|
|
817
3573
|
constructor(parentEnum: GraphQLEnumType, name: string, config: GraphQLEnumValueConfig);
|
|
3574
|
+
/**
|
|
3575
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
3576
|
+
* @returns The built-in string tag for this object.
|
|
3577
|
+
*/
|
|
818
3578
|
get [Symbol.toStringTag](): string;
|
|
3579
|
+
/**
|
|
3580
|
+
* Returns a normalized configuration object for this enum value.
|
|
3581
|
+
* @returns A configuration object that can be used to recreate this enum value.
|
|
3582
|
+
* @example
|
|
3583
|
+
* ```ts
|
|
3584
|
+
* import { GraphQLEnumType, GraphQLEnumValue } from 'graphql/type';
|
|
3585
|
+
*
|
|
3586
|
+
* const Episode = new GraphQLEnumType({
|
|
3587
|
+
* name: 'Episode',
|
|
3588
|
+
* values: { NEW_HOPE: { value: 4 } },
|
|
3589
|
+
* });
|
|
3590
|
+
* const enumValue = new GraphQLEnumValue(Episode, 'EMPIRE', {
|
|
3591
|
+
* value: 5,
|
|
3592
|
+
* extensions: { trilogy: 'original' },
|
|
3593
|
+
* });
|
|
3594
|
+
*
|
|
3595
|
+
* enumValue.toConfig(); // => { description: undefined, value: 5, deprecationReason: undefined, extensions: { trilogy: 'original' }, astNode: undefined }
|
|
3596
|
+
* ```
|
|
3597
|
+
*/
|
|
819
3598
|
toConfig(): GraphQLEnumValueNormalizedConfig;
|
|
3599
|
+
/**
|
|
3600
|
+
* Returns this enum value as a schema coordinate string.
|
|
3601
|
+
* @returns Enum value coordinate.
|
|
3602
|
+
* @example
|
|
3603
|
+
* ```ts
|
|
3604
|
+
* import { GraphQLEnumType, GraphQLEnumValue } from 'graphql/type';
|
|
3605
|
+
*
|
|
3606
|
+
* const Episode = new GraphQLEnumType({
|
|
3607
|
+
* name: 'Episode',
|
|
3608
|
+
* values: { NEW_HOPE: { value: 4 } },
|
|
3609
|
+
* });
|
|
3610
|
+
* const enumValue = new GraphQLEnumValue(Episode, 'EMPIRE', { value: 5 });
|
|
3611
|
+
*
|
|
3612
|
+
* enumValue.toString(); // => 'Episode.EMPIRE'
|
|
3613
|
+
* ```
|
|
3614
|
+
*/
|
|
820
3615
|
toString(): string;
|
|
3616
|
+
/**
|
|
3617
|
+
* Returns the JSON representation used when this object is serialized.
|
|
3618
|
+
* @returns Enum value coordinate.
|
|
3619
|
+
* @example
|
|
3620
|
+
* ```ts
|
|
3621
|
+
* import { GraphQLEnumType, GraphQLEnumValue } from 'graphql/type';
|
|
3622
|
+
*
|
|
3623
|
+
* const Episode = new GraphQLEnumType({
|
|
3624
|
+
* name: 'Episode',
|
|
3625
|
+
* values: { NEW_HOPE: { value: 4 } },
|
|
3626
|
+
* });
|
|
3627
|
+
* const enumValue = new GraphQLEnumValue(Episode, 'EMPIRE', { value: 5 });
|
|
3628
|
+
*
|
|
3629
|
+
* JSON.stringify(enumValue); // => '"Episode.EMPIRE"'
|
|
3630
|
+
* ```
|
|
3631
|
+
*/
|
|
821
3632
|
toJSON(): string;
|
|
822
3633
|
}
|
|
823
3634
|
/**
|
|
824
3635
|
* Custom extensions
|
|
825
|
-
*
|
|
826
3636
|
* @remarks
|
|
827
3637
|
* Use a unique identifier name for your extension, for example the name of
|
|
828
3638
|
* your library or project. Do not use a shortened identifier as this increases
|
|
@@ -839,45 +3649,221 @@ export interface GraphQLInputObjectTypeExtensions {
|
|
|
839
3649
|
* supplied to a field argument.
|
|
840
3650
|
*
|
|
841
3651
|
* Using `NonNull` will ensure that a value must be provided by the query
|
|
842
|
-
*
|
|
843
|
-
* Example:
|
|
844
|
-
*
|
|
3652
|
+
* @example
|
|
845
3653
|
* ```ts
|
|
846
3654
|
* const GeoPoint = new GraphQLInputObjectType({
|
|
847
3655
|
* name: 'GeoPoint',
|
|
848
3656
|
* fields: {
|
|
849
3657
|
* lat: { type: new GraphQLNonNull(GraphQLFloat) },
|
|
850
3658
|
* lon: { type: new GraphQLNonNull(GraphQLFloat) },
|
|
851
|
-
* alt: { type: GraphQLFloat,
|
|
3659
|
+
* alt: { type: GraphQLFloat, default: { value: 0 } },
|
|
852
3660
|
* }
|
|
853
3661
|
* });
|
|
854
3662
|
* ```
|
|
855
3663
|
*/
|
|
856
3664
|
export declare class GraphQLInputObjectType implements GraphQLSchemaElement {
|
|
857
|
-
|
|
3665
|
+
/** The GraphQL name for this schema element. */
|
|
858
3666
|
name: string;
|
|
3667
|
+
/** Human-readable description for this schema element, if provided. */
|
|
859
3668
|
description: Maybe<string>;
|
|
3669
|
+
/** Extension fields to include in the formatted result. */
|
|
860
3670
|
extensions: Readonly<GraphQLInputObjectTypeExtensions>;
|
|
3671
|
+
/** AST node from which this schema element was built, if available. */
|
|
861
3672
|
astNode: Maybe<InputObjectTypeDefinitionNode>;
|
|
3673
|
+
/** AST extension nodes applied to this schema element. */
|
|
862
3674
|
extensionASTNodes: ReadonlyArray<InputObjectTypeExtensionNode>;
|
|
3675
|
+
/** Whether this input object uses the experimental OneOf input object semantics. */
|
|
863
3676
|
isOneOf: boolean;
|
|
864
3677
|
private _fields;
|
|
3678
|
+
/**
|
|
3679
|
+
* Creates a GraphQLInputObjectType instance.
|
|
3680
|
+
* @param config - Configuration describing this object.
|
|
3681
|
+
* @example
|
|
3682
|
+
* ```ts
|
|
3683
|
+
* import { parse } from 'graphql/language';
|
|
3684
|
+
* import {
|
|
3685
|
+
* GraphQLID,
|
|
3686
|
+
* GraphQLInputObjectType,
|
|
3687
|
+
* GraphQLInt,
|
|
3688
|
+
* GraphQLNonNull,
|
|
3689
|
+
* GraphQLString,
|
|
3690
|
+
* } from 'graphql/type';
|
|
3691
|
+
*
|
|
3692
|
+
* const document = parse(`
|
|
3693
|
+
* input ReviewInput {
|
|
3694
|
+
* stars: Int!
|
|
3695
|
+
* commentary: String
|
|
3696
|
+
* }
|
|
3697
|
+
*
|
|
3698
|
+
* extend input ReviewInput {
|
|
3699
|
+
* body: String
|
|
3700
|
+
* }
|
|
3701
|
+
* `);
|
|
3702
|
+
* const definition = document.definitions[0];
|
|
3703
|
+
*
|
|
3704
|
+
* const ReviewInput = new GraphQLInputObjectType({
|
|
3705
|
+
* name: 'ReviewInput',
|
|
3706
|
+
* description: 'Input collected when reviewing a product.',
|
|
3707
|
+
* fields: {
|
|
3708
|
+
* stars: {
|
|
3709
|
+
* description: 'Star rating from one to five.',
|
|
3710
|
+
* type: new GraphQLNonNull(GraphQLInt),
|
|
3711
|
+
* extensions: { min: 1, max: 5 },
|
|
3712
|
+
* astNode: definition.fields[0],
|
|
3713
|
+
* },
|
|
3714
|
+
* commentary: {
|
|
3715
|
+
* type: GraphQLString,
|
|
3716
|
+
* default: { value: '' },
|
|
3717
|
+
* deprecationReason: 'Use body.',
|
|
3718
|
+
* astNode: definition.fields[1],
|
|
3719
|
+
* },
|
|
3720
|
+
* },
|
|
3721
|
+
* extensions: { form: 'review' },
|
|
3722
|
+
* astNode: definition,
|
|
3723
|
+
* extensionASTNodes: [ document.definitions[1] ],
|
|
3724
|
+
* isOneOf: false,
|
|
3725
|
+
* });
|
|
3726
|
+
* const SearchBy = new GraphQLInputObjectType({
|
|
3727
|
+
* name: 'SearchBy',
|
|
3728
|
+
* fields: {
|
|
3729
|
+
* id: { type: GraphQLID },
|
|
3730
|
+
* slug: { type: GraphQLString },
|
|
3731
|
+
* },
|
|
3732
|
+
* isOneOf: true,
|
|
3733
|
+
* });
|
|
3734
|
+
*
|
|
3735
|
+
* const fields = ReviewInput.getFields();
|
|
3736
|
+
*
|
|
3737
|
+
* ReviewInput.description; // => 'Input collected when reviewing a product.'
|
|
3738
|
+
* String(fields.stars.type); // => 'Int!'
|
|
3739
|
+
* fields.stars.extensions; // => { min: 1, max: 5 }
|
|
3740
|
+
* fields.commentary.default.value; // => ''
|
|
3741
|
+
* fields.commentary.deprecationReason; // => 'Use body.'
|
|
3742
|
+
* ReviewInput.isOneOf; // => false
|
|
3743
|
+
* SearchBy.isOneOf; // => true
|
|
3744
|
+
* ```
|
|
3745
|
+
*/
|
|
865
3746
|
constructor(config: Readonly<GraphQLInputObjectTypeConfig>);
|
|
3747
|
+
/**
|
|
3748
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
3749
|
+
* @returns The built-in string tag for this object.
|
|
3750
|
+
*/
|
|
866
3751
|
get [Symbol.toStringTag](): string;
|
|
3752
|
+
/**
|
|
3753
|
+
* Returns the fields defined by this type.
|
|
3754
|
+
* @returns The fields keyed by field name.
|
|
3755
|
+
* @example
|
|
3756
|
+
* ```ts
|
|
3757
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
3758
|
+
* import { assertInputObjectType } from 'graphql/type';
|
|
3759
|
+
*
|
|
3760
|
+
* const schema = buildSchema(`
|
|
3761
|
+
* input ReviewInput {
|
|
3762
|
+
* stars: Int!
|
|
3763
|
+
* commentary: String = ""
|
|
3764
|
+
* }
|
|
3765
|
+
*
|
|
3766
|
+
* type Query {
|
|
3767
|
+
* reviews(filter: ReviewInput): [String]
|
|
3768
|
+
* }
|
|
3769
|
+
* `);
|
|
3770
|
+
*
|
|
3771
|
+
* const ReviewInput = assertInputObjectType(schema.getType('ReviewInput'));
|
|
3772
|
+
* const fields = ReviewInput.getFields();
|
|
3773
|
+
*
|
|
3774
|
+
* Object.keys(fields); // => ['stars', 'commentary']
|
|
3775
|
+
* fields.commentary.default; // => { literal: { kind: 'StringValue', value: '' } }
|
|
3776
|
+
* ```
|
|
3777
|
+
*/
|
|
867
3778
|
getFields(): GraphQLInputFieldMap;
|
|
3779
|
+
/**
|
|
3780
|
+
* Returns a normalized configuration object for this object.
|
|
3781
|
+
* @returns A configuration object that can be used to recreate this object.
|
|
3782
|
+
* @example
|
|
3783
|
+
* ```ts
|
|
3784
|
+
* import {
|
|
3785
|
+
* GraphQLInputObjectType,
|
|
3786
|
+
* GraphQLInt,
|
|
3787
|
+
* GraphQLNonNull,
|
|
3788
|
+
* } from 'graphql/type';
|
|
3789
|
+
*
|
|
3790
|
+
* const ReviewInput = new GraphQLInputObjectType({
|
|
3791
|
+
* name: 'ReviewInput',
|
|
3792
|
+
* fields: {
|
|
3793
|
+
* stars: { type: new GraphQLNonNull(GraphQLInt) },
|
|
3794
|
+
* },
|
|
3795
|
+
* });
|
|
3796
|
+
*
|
|
3797
|
+
* const config = ReviewInput.toConfig();
|
|
3798
|
+
* const ReviewInputCopy = new GraphQLInputObjectType(config);
|
|
3799
|
+
*
|
|
3800
|
+
* String(config.fields.stars.type); // => 'Int!'
|
|
3801
|
+
* String(ReviewInputCopy.getFields().stars.type); // => 'Int!'
|
|
3802
|
+
* ```
|
|
3803
|
+
*/
|
|
868
3804
|
toConfig(): GraphQLInputObjectTypeNormalizedConfig;
|
|
3805
|
+
/**
|
|
3806
|
+
* Returns the schema coordinate identifying this input object type.
|
|
3807
|
+
* @returns The schema coordinate for this input object type.
|
|
3808
|
+
* @example
|
|
3809
|
+
* ```ts
|
|
3810
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
3811
|
+
* import { assertInputObjectType } from 'graphql/type';
|
|
3812
|
+
*
|
|
3813
|
+
* const schema = buildSchema(`
|
|
3814
|
+
* input ReviewInput {
|
|
3815
|
+
* stars: Int!
|
|
3816
|
+
* }
|
|
3817
|
+
*
|
|
3818
|
+
* type Query {
|
|
3819
|
+
* reviews(filter: ReviewInput): [String]
|
|
3820
|
+
* }
|
|
3821
|
+
* `);
|
|
3822
|
+
*
|
|
3823
|
+
* const ReviewInput = assertInputObjectType(schema.getType('ReviewInput'));
|
|
3824
|
+
*
|
|
3825
|
+
* ReviewInput.toString(); // => 'ReviewInput'
|
|
3826
|
+
* ```
|
|
3827
|
+
*/
|
|
869
3828
|
toString(): string;
|
|
3829
|
+
/**
|
|
3830
|
+
* Returns the JSON representation used when this object is serialized.
|
|
3831
|
+
* @returns The JSON-serializable representation.
|
|
3832
|
+
* @example
|
|
3833
|
+
* ```ts
|
|
3834
|
+
* import { GraphQLInputObjectType, GraphQLString } from 'graphql/type';
|
|
3835
|
+
*
|
|
3836
|
+
* const ReviewInput = new GraphQLInputObjectType({
|
|
3837
|
+
* name: 'ReviewInput',
|
|
3838
|
+
* fields: {
|
|
3839
|
+
* commentary: { type: GraphQLString },
|
|
3840
|
+
* },
|
|
3841
|
+
* });
|
|
3842
|
+
*
|
|
3843
|
+
* ReviewInput.toJSON(); // => 'ReviewInput'
|
|
3844
|
+
* JSON.stringify({ type: ReviewInput }); // => '{"type":"ReviewInput"}'
|
|
3845
|
+
* ```
|
|
3846
|
+
*/
|
|
870
3847
|
toJSON(): string;
|
|
871
3848
|
}
|
|
3849
|
+
/** Configuration used to construct a GraphQLInputObjectType. */
|
|
872
3850
|
export interface GraphQLInputObjectTypeConfig {
|
|
3851
|
+
/** The GraphQL name for this schema element. */
|
|
873
3852
|
name: string;
|
|
3853
|
+
/** Human-readable description for this schema element, if provided. */
|
|
874
3854
|
description?: Maybe<string>;
|
|
3855
|
+
/** Fields declared by this object, interface, input object, or literal. */
|
|
875
3856
|
fields: ThunkObjMap<GraphQLInputFieldConfig>;
|
|
3857
|
+
/** Extension fields to include in the formatted result. */
|
|
876
3858
|
extensions?: Maybe<Readonly<GraphQLInputObjectTypeExtensions>>;
|
|
3859
|
+
/** AST node from which this schema element was built, if available. */
|
|
877
3860
|
astNode?: Maybe<InputObjectTypeDefinitionNode>;
|
|
3861
|
+
/** AST extension nodes applied to this schema element. */
|
|
878
3862
|
extensionASTNodes?: Maybe<ReadonlyArray<InputObjectTypeExtensionNode>>;
|
|
3863
|
+
/** Whether this input object uses the experimental OneOf input object semantics. */
|
|
879
3864
|
isOneOf?: boolean;
|
|
880
3865
|
}
|
|
3866
|
+
/** @internal */
|
|
881
3867
|
export interface GraphQLInputObjectTypeNormalizedConfig extends GraphQLInputObjectTypeConfig {
|
|
882
3868
|
fields: GraphQLInputFieldNormalizedConfigMap;
|
|
883
3869
|
extensions: Readonly<GraphQLInputObjectTypeExtensions>;
|
|
@@ -885,7 +3871,6 @@ export interface GraphQLInputObjectTypeNormalizedConfig extends GraphQLInputObje
|
|
|
885
3871
|
}
|
|
886
3872
|
/**
|
|
887
3873
|
* Custom extensions
|
|
888
|
-
*
|
|
889
3874
|
* @remarks
|
|
890
3875
|
* Use a unique identifier name for your extension, for example the name of
|
|
891
3876
|
* your library or project. Do not use a shortened identifier as this increases
|
|
@@ -895,39 +3880,184 @@ export interface GraphQLInputObjectTypeNormalizedConfig extends GraphQLInputObje
|
|
|
895
3880
|
export interface GraphQLInputFieldExtensions {
|
|
896
3881
|
[attributeName: string | symbol]: unknown;
|
|
897
3882
|
}
|
|
3883
|
+
/** Configuration used to define a GraphQL input field. */
|
|
898
3884
|
export interface GraphQLInputFieldConfig {
|
|
3885
|
+
/** Human-readable description for this schema element, if provided. */
|
|
899
3886
|
description?: Maybe<string>;
|
|
3887
|
+
/** The GraphQL type reference or runtime type for this element. */
|
|
900
3888
|
type: GraphQLInputType;
|
|
901
|
-
/**
|
|
3889
|
+
/**
|
|
3890
|
+
* Deprecated legacy default value for this input field. Use `default`
|
|
3891
|
+
* instead.
|
|
3892
|
+
* @deprecated use `default` instead, `defaultValue` will be removed in v18
|
|
3893
|
+
*/
|
|
902
3894
|
defaultValue?: unknown;
|
|
3895
|
+
/** Default value represented as either a runtime value or a GraphQL literal. */
|
|
903
3896
|
default?: GraphQLDefaultInput | undefined;
|
|
3897
|
+
/** Reason this element is deprecated, if one was provided. */
|
|
904
3898
|
deprecationReason?: Maybe<string>;
|
|
3899
|
+
/** Extension fields to include in the formatted result. */
|
|
905
3900
|
extensions?: Maybe<Readonly<GraphQLInputFieldExtensions>>;
|
|
3901
|
+
/** AST node from which this schema element was built, if available. */
|
|
906
3902
|
astNode?: Maybe<InputValueDefinitionNode>;
|
|
907
3903
|
}
|
|
3904
|
+
/** A map of input field names to input field configuration objects. */
|
|
908
3905
|
export type GraphQLInputFieldConfigMap = ObjMap<GraphQLInputFieldConfig>;
|
|
3906
|
+
/** @internal */
|
|
909
3907
|
export interface GraphQLInputFieldNormalizedConfig extends GraphQLInputFieldConfig {
|
|
910
3908
|
default: GraphQLDefaultInput | undefined;
|
|
911
3909
|
extensions: Readonly<GraphQLInputFieldExtensions>;
|
|
912
3910
|
}
|
|
3911
|
+
/** @internal */
|
|
913
3912
|
export type GraphQLInputFieldNormalizedConfigMap = ObjMap<GraphQLInputFieldNormalizedConfig>;
|
|
3913
|
+
/** A resolved GraphQL input field definition. */
|
|
914
3914
|
export declare class GraphQLInputField implements GraphQLSchemaElement {
|
|
915
|
-
|
|
3915
|
+
/** Input object type that owns this input field. */
|
|
916
3916
|
parentType: GraphQLInputObjectType;
|
|
3917
|
+
/** The GraphQL name for this schema element. */
|
|
917
3918
|
name: string;
|
|
3919
|
+
/** Human-readable description for this schema element, if provided. */
|
|
918
3920
|
description: Maybe<string>;
|
|
3921
|
+
/** The GraphQL type reference or runtime type for this element. */
|
|
919
3922
|
type: GraphQLInputType;
|
|
3923
|
+
/**
|
|
3924
|
+
* Deprecated legacy default value used when no explicit value is supplied.
|
|
3925
|
+
* Use `default` instead.
|
|
3926
|
+
* @deprecated use `default` instead, `defaultValue` will be removed in v18
|
|
3927
|
+
*/
|
|
920
3928
|
defaultValue: unknown;
|
|
3929
|
+
/** Default value represented as either a runtime value or a GraphQL literal. */
|
|
921
3930
|
default: GraphQLDefaultInput | undefined;
|
|
3931
|
+
/** Reason this element is deprecated, if one was provided. */
|
|
922
3932
|
deprecationReason: Maybe<string>;
|
|
3933
|
+
/** Extension fields to include in the formatted result. */
|
|
923
3934
|
extensions: Readonly<GraphQLInputFieldExtensions>;
|
|
3935
|
+
/** AST node from which this schema element was built, if available. */
|
|
924
3936
|
astNode: Maybe<InputValueDefinitionNode>;
|
|
3937
|
+
/**
|
|
3938
|
+
* Creates a resolved GraphQL input field definition.
|
|
3939
|
+
* @param parentType - Input object type that owns this field.
|
|
3940
|
+
* @param name - Input field name.
|
|
3941
|
+
* @param config - Input field configuration.
|
|
3942
|
+
* @example
|
|
3943
|
+
* ```ts
|
|
3944
|
+
* import { GraphQLInputField, GraphQLInputObjectType, GraphQLString } from 'graphql/type';
|
|
3945
|
+
*
|
|
3946
|
+
* const ReviewInput = new GraphQLInputObjectType({
|
|
3947
|
+
* name: 'ReviewInput',
|
|
3948
|
+
* fields: {},
|
|
3949
|
+
* });
|
|
3950
|
+
* const field = new GraphQLInputField(ReviewInput, 'commentary', {
|
|
3951
|
+
* type: GraphQLString,
|
|
3952
|
+
* default: { value: '' },
|
|
3953
|
+
* });
|
|
3954
|
+
*
|
|
3955
|
+
* field.parentType; // => ReviewInput
|
|
3956
|
+
* field.name; // => 'commentary'
|
|
3957
|
+
* field.default.value; // => ''
|
|
3958
|
+
* ```
|
|
3959
|
+
*/
|
|
925
3960
|
constructor(parentType: GraphQLInputObjectType, name: string, config: GraphQLInputFieldConfig);
|
|
3961
|
+
/**
|
|
3962
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
3963
|
+
* @returns The built-in string tag for this object.
|
|
3964
|
+
*/
|
|
926
3965
|
get [Symbol.toStringTag](): string;
|
|
3966
|
+
/**
|
|
3967
|
+
* Returns a normalized configuration object for this input field.
|
|
3968
|
+
* @returns A configuration object that can be used to recreate this input field.
|
|
3969
|
+
* @example
|
|
3970
|
+
* ```ts
|
|
3971
|
+
* import { GraphQLInputField, GraphQLInputObjectType, GraphQLString } from 'graphql/type';
|
|
3972
|
+
*
|
|
3973
|
+
* const ReviewInput = new GraphQLInputObjectType({
|
|
3974
|
+
* name: 'ReviewInput',
|
|
3975
|
+
* fields: {},
|
|
3976
|
+
* });
|
|
3977
|
+
* const field = new GraphQLInputField(ReviewInput, 'commentary', {
|
|
3978
|
+
* type: GraphQLString,
|
|
3979
|
+
* extensions: { form: 'review' },
|
|
3980
|
+
* });
|
|
3981
|
+
*
|
|
3982
|
+
* field.toConfig().extensions; // => { form: 'review' }
|
|
3983
|
+
* ```
|
|
3984
|
+
*/
|
|
927
3985
|
toConfig(): GraphQLInputFieldNormalizedConfig;
|
|
3986
|
+
/**
|
|
3987
|
+
* Returns this input field as a schema coordinate string.
|
|
3988
|
+
* @returns The input field coordinate.
|
|
3989
|
+
* @example
|
|
3990
|
+
* ```ts
|
|
3991
|
+
* import { GraphQLInputField, GraphQLInputObjectType, GraphQLString } from 'graphql/type';
|
|
3992
|
+
*
|
|
3993
|
+
* const ReviewInput = new GraphQLInputObjectType({
|
|
3994
|
+
* name: 'ReviewInput',
|
|
3995
|
+
* fields: {},
|
|
3996
|
+
* });
|
|
3997
|
+
* const field = new GraphQLInputField(ReviewInput, 'commentary', {
|
|
3998
|
+
* type: GraphQLString,
|
|
3999
|
+
* });
|
|
4000
|
+
*
|
|
4001
|
+
* field.toString(); // => 'ReviewInput.commentary'
|
|
4002
|
+
* ```
|
|
4003
|
+
*/
|
|
928
4004
|
toString(): string;
|
|
4005
|
+
/**
|
|
4006
|
+
* Returns the JSON representation used when this object is serialized.
|
|
4007
|
+
* @returns The input field coordinate.
|
|
4008
|
+
* @example
|
|
4009
|
+
* ```ts
|
|
4010
|
+
* import { GraphQLInputField, GraphQLInputObjectType, GraphQLString } from 'graphql/type';
|
|
4011
|
+
*
|
|
4012
|
+
* const ReviewInput = new GraphQLInputObjectType({
|
|
4013
|
+
* name: 'ReviewInput',
|
|
4014
|
+
* fields: {},
|
|
4015
|
+
* });
|
|
4016
|
+
* const field = new GraphQLInputField(ReviewInput, 'commentary', {
|
|
4017
|
+
* type: GraphQLString,
|
|
4018
|
+
* });
|
|
4019
|
+
*
|
|
4020
|
+
* JSON.stringify(field); // => '"ReviewInput.commentary"'
|
|
4021
|
+
* ```
|
|
4022
|
+
*/
|
|
929
4023
|
toJSON(): string;
|
|
930
4024
|
}
|
|
4025
|
+
/**
|
|
4026
|
+
* Returns true when the input field is non-null and has no default value.
|
|
4027
|
+
* @param field - The input field definition to inspect.
|
|
4028
|
+
* @returns True when the input field is non-null and has no default value.
|
|
4029
|
+
* @example
|
|
4030
|
+
* ```ts
|
|
4031
|
+
* import {
|
|
4032
|
+
* GraphQLInputField,
|
|
4033
|
+
* GraphQLInputObjectType,
|
|
4034
|
+
* GraphQLInt,
|
|
4035
|
+
* GraphQLNonNull,
|
|
4036
|
+
* GraphQLString,
|
|
4037
|
+
* isRequiredInputField,
|
|
4038
|
+
* } from 'graphql/type';
|
|
4039
|
+
*
|
|
4040
|
+
* const ReviewInput = new GraphQLInputObjectType({
|
|
4041
|
+
* name: 'ReviewInput',
|
|
4042
|
+
* fields: {},
|
|
4043
|
+
* });
|
|
4044
|
+
* const requiredField = new GraphQLInputField(ReviewInput, 'id', {
|
|
4045
|
+
* type: new GraphQLNonNull(GraphQLInt),
|
|
4046
|
+
* });
|
|
4047
|
+
* const optionalField = new GraphQLInputField(ReviewInput, 'name', {
|
|
4048
|
+
* type: GraphQLString,
|
|
4049
|
+
* });
|
|
4050
|
+
* const fieldWithDefault = new GraphQLInputField(ReviewInput, 'limit', {
|
|
4051
|
+
* type: new GraphQLNonNull(GraphQLInt),
|
|
4052
|
+
* default: { value: 10 },
|
|
4053
|
+
* });
|
|
4054
|
+
*
|
|
4055
|
+
* isRequiredInputField(requiredField); // => true
|
|
4056
|
+
* isRequiredInputField(optionalField); // => false
|
|
4057
|
+
* isRequiredInputField(fieldWithDefault); // => false
|
|
4058
|
+
* ```
|
|
4059
|
+
*/
|
|
931
4060
|
export declare function isRequiredInputField(field: GraphQLInputField): boolean;
|
|
4061
|
+
/** A map of input field names to resolved input field definitions. */
|
|
932
4062
|
export type GraphQLInputFieldMap = ObjMap<GraphQLInputField>;
|
|
933
4063
|
export {};
|