graphql 0.0.1-test.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/NotSupportedTSVersion.d.ts +1 -0
- package/README.md +158 -0
- package/error/GraphQLError.d.ts +142 -0
- package/error/GraphQLError.js +267 -0
- package/error/GraphQLError.mjs +253 -0
- package/error/index.d.ts +7 -0
- package/error/index.js +41 -0
- package/error/index.mjs +3 -0
- package/error/locatedError.d.ts +13 -0
- package/error/locatedError.js +40 -0
- package/error/locatedError.mjs +32 -0
- package/error/syntaxError.d.ts +11 -0
- package/error/syntaxError.js +21 -0
- package/error/syntaxError.mjs +11 -0
- package/execution/collectFields.d.ts +45 -0
- package/execution/collectFields.js +229 -0
- package/execution/collectFields.mjs +213 -0
- package/execution/execute.d.ts +185 -0
- package/execution/execute.js +1016 -0
- package/execution/execute.mjs +988 -0
- package/execution/index.d.ts +14 -0
- package/execution/index.js +67 -0
- package/execution/index.mjs +9 -0
- package/execution/mapAsyncIterator.d.ts +9 -0
- package/execution/mapAsyncIterator.js +68 -0
- package/execution/mapAsyncIterator.mjs +61 -0
- package/execution/subscribe.d.ts +68 -0
- package/execution/subscribe.js +261 -0
- package/execution/subscribe.mjs +239 -0
- package/execution/values.d.ts +81 -0
- package/execution/values.js +292 -0
- package/execution/values.mjs +255 -0
- package/graphql.d.ts +67 -0
- package/graphql.js +96 -0
- package/graphql.mjs +122 -0
- package/index.d.ts +411 -0
- package/index.js +1263 -0
- package/index.mjs +254 -0
- package/jsutils/Maybe.d.ts +2 -0
- package/jsutils/Maybe.js +5 -0
- package/jsutils/Maybe.mjs +1 -0
- package/jsutils/ObjMap.d.ts +16 -0
- package/jsutils/ObjMap.js +5 -0
- package/jsutils/ObjMap.mjs +1 -0
- package/jsutils/Path.d.ts +20 -0
- package/jsutils/Path.js +33 -0
- package/jsutils/Path.mjs +25 -0
- package/jsutils/PromiseOrValue.d.ts +1 -0
- package/jsutils/PromiseOrValue.js +5 -0
- package/jsutils/PromiseOrValue.mjs +1 -0
- package/jsutils/devAssert.d.ts +1 -0
- package/jsutils/devAssert.js +14 -0
- package/jsutils/devAssert.mjs +7 -0
- package/jsutils/didYouMean.d.ts +8 -0
- package/jsutils/didYouMean.js +38 -0
- package/jsutils/didYouMean.mjs +32 -0
- package/jsutils/groupBy.d.ts +7 -0
- package/jsutils/groupBy.js +26 -0
- package/jsutils/groupBy.mjs +19 -0
- package/jsutils/identityFunc.d.ts +4 -0
- package/jsutils/identityFunc.js +13 -0
- package/jsutils/identityFunc.mjs +6 -0
- package/jsutils/inspect.d.ts +4 -0
- package/jsutils/inspect.js +121 -0
- package/jsutils/inspect.mjs +115 -0
- package/jsutils/instanceOf.d.ts +16 -0
- package/jsutils/instanceOf.js +60 -0
- package/jsutils/instanceOf.mjs +52 -0
- package/jsutils/invariant.d.ts +4 -0
- package/jsutils/invariant.js +16 -0
- package/jsutils/invariant.mjs +9 -0
- package/jsutils/isAsyncIterable.d.ts +7 -0
- package/jsutils/isAsyncIterable.js +18 -0
- package/jsutils/isAsyncIterable.mjs +11 -0
- package/jsutils/isIterableObject.d.ts +20 -0
- package/jsutils/isIterableObject.js +32 -0
- package/jsutils/isIterableObject.mjs +25 -0
- package/jsutils/isObjectLike.d.ts +7 -0
- package/jsutils/isObjectLike.js +14 -0
- package/jsutils/isObjectLike.mjs +7 -0
- package/jsutils/isPromise.d.ts +5 -0
- package/jsutils/isPromise.js +17 -0
- package/jsutils/isPromise.mjs +10 -0
- package/jsutils/keyMap.d.ts +32 -0
- package/jsutils/keyMap.js +43 -0
- package/jsutils/keyMap.mjs +36 -0
- package/jsutils/keyValMap.d.ts +23 -0
- package/jsutils/keyValMap.js +33 -0
- package/jsutils/keyValMap.mjs +26 -0
- package/jsutils/mapValue.d.ts +9 -0
- package/jsutils/mapValue.js +20 -0
- package/jsutils/mapValue.mjs +13 -0
- package/jsutils/memoize3.d.ts +9 -0
- package/jsutils/memoize3.js +41 -0
- package/jsutils/memoize3.mjs +34 -0
- package/jsutils/naturalCompare.d.ts +8 -0
- package/jsutils/naturalCompare.js +69 -0
- package/jsutils/naturalCompare.mjs +61 -0
- package/jsutils/printPathArray.d.ts +6 -0
- package/jsutils/printPathArray.js +17 -0
- package/jsutils/printPathArray.mjs +10 -0
- package/jsutils/promiseForObject.d.ts +11 -0
- package/jsutils/promiseForObject.js +25 -0
- package/jsutils/promiseForObject.mjs +18 -0
- package/jsutils/promiseReduce.d.ts +13 -0
- package/jsutils/promiseReduce.js +27 -0
- package/jsutils/promiseReduce.mjs +20 -0
- package/jsutils/suggestionList.d.ts +8 -0
- package/jsutils/suggestionList.js +139 -0
- package/jsutils/suggestionList.mjs +130 -0
- package/jsutils/toError.d.ts +4 -0
- package/jsutils/toError.js +25 -0
- package/jsutils/toError.mjs +18 -0
- package/jsutils/toObjMap.d.ts +5 -0
- package/jsutils/toObjMap.js +24 -0
- package/jsutils/toObjMap.mjs +17 -0
- package/language/ast.d.ts +536 -0
- package/language/ast.js +224 -0
- package/language/ast.mjs +206 -0
- package/language/blockString.d.ts +28 -0
- package/language/blockString.js +195 -0
- package/language/blockString.mjs +178 -0
- package/language/characterClasses.d.ts +47 -0
- package/language/characterClasses.js +75 -0
- package/language/characterClasses.mjs +64 -0
- package/language/directiveLocation.d.ts +32 -0
- package/language/directiveLocation.js +40 -0
- package/language/directiveLocation.mjs +31 -0
- package/language/index.d.ts +97 -0
- package/language/index.js +215 -0
- package/language/index.mjs +29 -0
- package/language/kinds.d.ts +65 -0
- package/language/kinds.js +64 -0
- package/language/kinds.mjs +55 -0
- package/language/lexer.d.ts +45 -0
- package/language/lexer.js +1006 -0
- package/language/lexer.mjs +902 -0
- package/language/location.d.ts +16 -0
- package/language/location.js +38 -0
- package/language/location.mjs +30 -0
- package/language/parser.d.ts +554 -0
- package/language/parser.js +1567 -0
- package/language/parser.mjs +1524 -0
- package/language/predicates.d.ts +33 -0
- package/language/predicates.js +109 -0
- package/language/predicates.mjs +81 -0
- package/language/printLocation.d.ts +14 -0
- package/language/printLocation.js +74 -0
- package/language/printLocation.mjs +66 -0
- package/language/printString.d.ts +5 -0
- package/language/printString.js +183 -0
- package/language/printString.mjs +176 -0
- package/language/printer.d.ts +6 -0
- package/language/printer.js +351 -0
- package/language/printer.mjs +339 -0
- package/language/source.d.ts +25 -0
- package/language/source.js +65 -0
- package/language/source.mjs +50 -0
- package/language/tokenKind.d.ts +34 -0
- package/language/tokenKind.js +44 -0
- package/language/tokenKind.mjs +35 -0
- package/language/visitor.d.ts +194 -0
- package/language/visitor.js +377 -0
- package/language/visitor.mjs +361 -0
- package/package.json +40 -0
- package/subscription/index.d.ts +19 -0
- package/subscription/index.js +19 -0
- package/subscription/index.mjs +19 -0
- package/type/assertName.d.ts +10 -0
- package/type/assertName.js +59 -0
- package/type/assertName.mjs +44 -0
- package/type/definition.d.ts +917 -0
- package/type/definition.js +1329 -0
- package/type/definition.mjs +1167 -0
- package/type/directives.d.ts +86 -0
- package/type/directives.js +224 -0
- package/type/directives.mjs +190 -0
- package/type/index.d.ts +150 -0
- package/type/index.js +547 -0
- package/type/index.mjs +103 -0
- package/type/introspection.d.ts +29 -0
- package/type/introspection.js +617 -0
- package/type/introspection.mjs +550 -0
- package/type/scalars.d.ts +19 -0
- package/type/scalars.js +359 -0
- package/type/scalars.mjs +299 -0
- package/type/schema.d.ts +170 -0
- package/type/schema.js +402 -0
- package/type/schema.mjs +381 -0
- package/type/validate.d.ts +17 -0
- package/type/validate.js +672 -0
- package/type/validate.mjs +647 -0
- package/utilities/TypeInfo.d.ts +67 -0
- package/utilities/TypeInfo.js +418 -0
- package/utilities/TypeInfo.mjs +395 -0
- package/utilities/assertValidName.d.ts +13 -0
- package/utilities/assertValidName.js +51 -0
- package/utilities/assertValidName.mjs +40 -0
- package/utilities/astFromValue.d.ts +28 -0
- package/utilities/astFromValue.js +190 -0
- package/utilities/astFromValue.mjs +177 -0
- package/utilities/buildASTSchema.d.ts +35 -0
- package/utilities/buildASTSchema.js +115 -0
- package/utilities/buildASTSchema.mjs +97 -0
- package/utilities/buildClientSchema.d.ts +19 -0
- package/utilities/buildClientSchema.js +386 -0
- package/utilities/buildClientSchema.mjs +363 -0
- package/utilities/coerceInputValue.d.ts +16 -0
- package/utilities/coerceInputValue.js +191 -0
- package/utilities/coerceInputValue.mjs +172 -0
- package/utilities/concatAST.d.ts +9 -0
- package/utilities/concatAST.js +26 -0
- package/utilities/concatAST.mjs +19 -0
- package/utilities/extendSchema.d.ts +40 -0
- package/utilities/extendSchema.js +798 -0
- package/utilities/extendSchema.mjs +789 -0
- package/utilities/findBreakingChanges.d.ts +51 -0
- package/utilities/findBreakingChanges.js +547 -0
- package/utilities/findBreakingChanges.mjs +516 -0
- package/utilities/getIntrospectionQuery.d.ts +182 -0
- package/utilities/getIntrospectionQuery.js +134 -0
- package/utilities/getIntrospectionQuery.mjs +127 -0
- package/utilities/getOperationAST.d.ts +11 -0
- package/utilities/getOperationAST.js +43 -0
- package/utilities/getOperationAST.mjs +36 -0
- package/utilities/getOperationRootType.d.ts +15 -0
- package/utilities/getOperationRootType.js +59 -0
- package/utilities/getOperationRootType.mjs +52 -0
- package/utilities/index.d.ts +61 -0
- package/utilities/index.js +233 -0
- package/utilities/index.mjs +55 -0
- package/utilities/introspectionFromSchema.d.ts +18 -0
- package/utilities/introspectionFromSchema.js +42 -0
- package/utilities/introspectionFromSchema.mjs +30 -0
- package/utilities/lexicographicSortSchema.d.ts +9 -0
- package/utilities/lexicographicSortSchema.js +177 -0
- package/utilities/lexicographicSortSchema.mjs +172 -0
- package/utilities/printSchema.d.ts +5 -0
- package/utilities/printSchema.js +333 -0
- package/utilities/printSchema.mjs +309 -0
- package/utilities/separateOperations.d.ts +11 -0
- package/utilities/separateOperations.js +88 -0
- package/utilities/separateOperations.mjs +80 -0
- package/utilities/sortValueNode.d.ts +9 -0
- package/utilities/sortValueNode.js +47 -0
- package/utilities/sortValueNode.mjs +39 -0
- package/utilities/stripIgnoredCharacters.d.ts +62 -0
- package/utilities/stripIgnoredCharacters.js +121 -0
- package/utilities/stripIgnoredCharacters.mjs +104 -0
- package/utilities/typeComparators.d.ts +32 -0
- package/utilities/typeComparators.js +116 -0
- package/utilities/typeComparators.mjs +106 -0
- package/utilities/typeFromAST.d.ts +32 -0
- package/utilities/typeFromAST.js +27 -0
- package/utilities/typeFromAST.mjs +18 -0
- package/utilities/typedQueryDocumentNode.d.ts +22 -0
- package/utilities/typedQueryDocumentNode.js +5 -0
- package/utilities/typedQueryDocumentNode.mjs +1 -0
- package/utilities/valueFromAST.d.ts +29 -0
- package/utilities/valueFromAST.js +185 -0
- package/utilities/valueFromAST.mjs +172 -0
- package/utilities/valueFromASTUntyped.d.ts +23 -0
- package/utilities/valueFromASTUntyped.js +61 -0
- package/utilities/valueFromASTUntyped.mjs +53 -0
- package/validation/ValidationContext.d.ts +95 -0
- package/validation/ValidationContext.js +232 -0
- package/validation/ValidationContext.mjs +212 -0
- package/validation/index.d.ts +40 -0
- package/validation/index.js +317 -0
- package/validation/index.mjs +68 -0
- package/validation/rules/ExecutableDefinitionsRule.d.ts +13 -0
- package/validation/rules/ExecutableDefinitionsRule.js +44 -0
- package/validation/rules/ExecutableDefinitionsRule.mjs +35 -0
- package/validation/rules/FieldsOnCorrectTypeRule.d.ts +13 -0
- package/validation/rules/FieldsOnCorrectTypeRule.js +143 -0
- package/validation/rules/FieldsOnCorrectTypeRule.mjs +125 -0
- package/validation/rules/FragmentsOnCompositeTypesRule.d.ts +14 -0
- package/validation/rules/FragmentsOnCompositeTypesRule.js +65 -0
- package/validation/rules/FragmentsOnCompositeTypesRule.mjs +49 -0
- package/validation/rules/KnownArgumentNamesRule.d.ts +23 -0
- package/validation/rules/KnownArgumentNamesRule.js +116 -0
- package/validation/rules/KnownArgumentNamesRule.mjs +98 -0
- package/validation/rules/KnownDirectivesRule.d.ts +16 -0
- package/validation/rules/KnownDirectivesRule.js +163 -0
- package/validation/rules/KnownDirectivesRule.mjs +146 -0
- package/validation/rules/KnownFragmentNamesRule.d.ts +13 -0
- package/validation/rules/KnownFragmentNamesRule.js +34 -0
- package/validation/rules/KnownFragmentNamesRule.mjs +24 -0
- package/validation/rules/KnownTypeNamesRule.d.ts +16 -0
- package/validation/rules/KnownTypeNamesRule.js +87 -0
- package/validation/rules/KnownTypeNamesRule.mjs +75 -0
- package/validation/rules/LoneAnonymousOperationRule.d.ts +13 -0
- package/validation/rules/LoneAnonymousOperationRule.js +40 -0
- package/validation/rules/LoneAnonymousOperationRule.mjs +32 -0
- package/validation/rules/LoneSchemaDefinitionRule.d.ts +10 -0
- package/validation/rules/LoneSchemaDefinitionRule.js +63 -0
- package/validation/rules/LoneSchemaDefinitionRule.mjs +53 -0
- package/validation/rules/NoFragmentCyclesRule.d.ts +13 -0
- package/validation/rules/NoFragmentCyclesRule.js +83 -0
- package/validation/rules/NoFragmentCyclesRule.mjs +76 -0
- package/validation/rules/NoUndefinedVariablesRule.d.ts +13 -0
- package/validation/rules/NoUndefinedVariablesRule.js +50 -0
- package/validation/rules/NoUndefinedVariablesRule.mjs +43 -0
- package/validation/rules/NoUnusedFragmentsRule.d.ts +13 -0
- package/validation/rules/NoUnusedFragmentsRule.js +59 -0
- package/validation/rules/NoUnusedFragmentsRule.mjs +52 -0
- package/validation/rules/NoUnusedVariablesRule.d.ts +13 -0
- package/validation/rules/NoUnusedVariablesRule.js +55 -0
- package/validation/rules/NoUnusedVariablesRule.mjs +48 -0
- package/validation/rules/OverlappingFieldsCanBeMergedRule-old.js +805 -0
- package/validation/rules/OverlappingFieldsCanBeMergedRule-old.mjs +788 -0
- package/validation/rules/OverlappingFieldsCanBeMergedRule.d.ts +14 -0
- package/validation/rules/OverlappingFieldsCanBeMergedRule.js +805 -0
- package/validation/rules/OverlappingFieldsCanBeMergedRule.mjs +788 -0
- package/validation/rules/PossibleFragmentSpreadsRule.d.ts +12 -0
- package/validation/rules/PossibleFragmentSpreadsRule.js +91 -0
- package/validation/rules/PossibleFragmentSpreadsRule.mjs +69 -0
- package/validation/rules/PossibleTypeExtensionsRule.d.ts +10 -0
- package/validation/rules/PossibleTypeExtensionsRule.js +167 -0
- package/validation/rules/PossibleTypeExtensionsRule.mjs +147 -0
- package/validation/rules/ProvidedRequiredArgumentsRule.d.ts +20 -0
- package/validation/rules/ProvidedRequiredArgumentsRule.js +158 -0
- package/validation/rules/ProvidedRequiredArgumentsRule.mjs +138 -0
- package/validation/rules/ScalarLeafsRule.d.ts +9 -0
- package/validation/rules/ScalarLeafsRule.js +51 -0
- package/validation/rules/ScalarLeafsRule.mjs +42 -0
- package/validation/rules/SingleFieldSubscriptionsRule.d.ts +13 -0
- package/validation/rules/SingleFieldSubscriptionsRule.js +82 -0
- package/validation/rules/SingleFieldSubscriptionsRule.mjs +73 -0
- package/validation/rules/UniqueArgumentDefinitionNamesRule.d.ts +11 -0
- package/validation/rules/UniqueArgumentDefinitionNamesRule.js +90 -0
- package/validation/rules/UniqueArgumentDefinitionNamesRule.mjs +79 -0
- package/validation/rules/UniqueArgumentNamesRule.d.ts +13 -0
- package/validation/rules/UniqueArgumentNamesRule.js +53 -0
- package/validation/rules/UniqueArgumentNamesRule.mjs +42 -0
- package/validation/rules/UniqueDirectiveNamesRule.d.ts +10 -0
- package/validation/rules/UniqueDirectiveNamesRule.js +50 -0
- package/validation/rules/UniqueDirectiveNamesRule.mjs +43 -0
- package/validation/rules/UniqueDirectivesPerLocationRule.d.ts +16 -0
- package/validation/rules/UniqueDirectivesPerLocationRule.js +93 -0
- package/validation/rules/UniqueDirectivesPerLocationRule.mjs +83 -0
- package/validation/rules/UniqueEnumValueNamesRule.d.ts +10 -0
- package/validation/rules/UniqueEnumValueNamesRule.js +71 -0
- package/validation/rules/UniqueEnumValueNamesRule.mjs +60 -0
- package/validation/rules/UniqueFieldDefinitionNamesRule.d.ts +10 -0
- package/validation/rules/UniqueFieldDefinitionNamesRule.js +83 -0
- package/validation/rules/UniqueFieldDefinitionNamesRule.mjs +75 -0
- package/validation/rules/UniqueFragmentNamesRule.d.ts +12 -0
- package/validation/rules/UniqueFragmentNamesRule.js +39 -0
- package/validation/rules/UniqueFragmentNamesRule.mjs +32 -0
- package/validation/rules/UniqueInputFieldNamesRule.d.ts +13 -0
- package/validation/rules/UniqueInputFieldNamesRule.js +52 -0
- package/validation/rules/UniqueInputFieldNamesRule.mjs +44 -0
- package/validation/rules/UniqueOperationNamesRule.d.ts +12 -0
- package/validation/rules/UniqueOperationNamesRule.js +41 -0
- package/validation/rules/UniqueOperationNamesRule.mjs +34 -0
- package/validation/rules/UniqueOperationTypesRule.d.ts +10 -0
- package/validation/rules/UniqueOperationTypesRule.js +67 -0
- package/validation/rules/UniqueOperationTypesRule.mjs +60 -0
- package/validation/rules/UniqueTypeNamesRule.d.ts +10 -0
- package/validation/rules/UniqueTypeNamesRule.js +53 -0
- package/validation/rules/UniqueTypeNamesRule.mjs +46 -0
- package/validation/rules/UniqueVariableNamesRule.d.ts +10 -0
- package/validation/rules/UniqueVariableNamesRule.js +47 -0
- package/validation/rules/UniqueVariableNamesRule.mjs +39 -0
- package/validation/rules/ValuesOfCorrectTypeRule.d.ts +13 -0
- package/validation/rules/ValuesOfCorrectTypeRule.js +183 -0
- package/validation/rules/ValuesOfCorrectTypeRule.mjs +164 -0
- package/validation/rules/VariablesAreInputTypesRule.d.ts +13 -0
- package/validation/rules/VariablesAreInputTypesRule.js +44 -0
- package/validation/rules/VariablesAreInputTypesRule.mjs +31 -0
- package/validation/rules/VariablesInAllowedPositionRule.d.ts +12 -0
- package/validation/rules/VariablesInAllowedPositionRule.js +114 -0
- package/validation/rules/VariablesInAllowedPositionRule.mjs +95 -0
- package/validation/rules/custom/NoDeprecatedCustomRule.d.ts +15 -0
- package/validation/rules/custom/NoDeprecatedCustomRule.js +121 -0
- package/validation/rules/custom/NoDeprecatedCustomRule.mjs +107 -0
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.d.ts +15 -0
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.js +39 -0
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.mjs +30 -0
- package/validation/specifiedRules.d.ts +12 -0
- package/validation/specifiedRules.js +160 -0
- package/validation/specifiedRules.mjs +123 -0
- package/validation/validate.d.ts +61 -0
- package/validation/validate.js +151 -0
- package/validation/validate.mjs +133 -0
- package/version.d.ts +13 -0
- package/version.js +25 -0
- package/version.mjs +17 -0
|
@@ -0,0 +1,1329 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.GraphQLUnionType =
|
|
7
|
+
exports.GraphQLScalarType =
|
|
8
|
+
exports.GraphQLObjectType =
|
|
9
|
+
exports.GraphQLNonNull =
|
|
10
|
+
exports.GraphQLList =
|
|
11
|
+
exports.GraphQLInterfaceType =
|
|
12
|
+
exports.GraphQLInputObjectType =
|
|
13
|
+
exports.GraphQLEnumType =
|
|
14
|
+
void 0;
|
|
15
|
+
exports.argsToArgsConfig = argsToArgsConfig;
|
|
16
|
+
exports.assertAbstractType = assertAbstractType;
|
|
17
|
+
exports.assertCompositeType = assertCompositeType;
|
|
18
|
+
exports.assertEnumType = assertEnumType;
|
|
19
|
+
exports.assertInputObjectType = assertInputObjectType;
|
|
20
|
+
exports.assertInputType = assertInputType;
|
|
21
|
+
exports.assertInterfaceType = assertInterfaceType;
|
|
22
|
+
exports.assertLeafType = assertLeafType;
|
|
23
|
+
exports.assertListType = assertListType;
|
|
24
|
+
exports.assertNamedType = assertNamedType;
|
|
25
|
+
exports.assertNonNullType = assertNonNullType;
|
|
26
|
+
exports.assertNullableType = assertNullableType;
|
|
27
|
+
exports.assertObjectType = assertObjectType;
|
|
28
|
+
exports.assertOutputType = assertOutputType;
|
|
29
|
+
exports.assertScalarType = assertScalarType;
|
|
30
|
+
exports.assertType = assertType;
|
|
31
|
+
exports.assertUnionType = assertUnionType;
|
|
32
|
+
exports.assertWrappingType = assertWrappingType;
|
|
33
|
+
exports.defineArguments = defineArguments;
|
|
34
|
+
exports.getNamedType = getNamedType;
|
|
35
|
+
exports.getNullableType = getNullableType;
|
|
36
|
+
exports.isAbstractType = isAbstractType;
|
|
37
|
+
exports.isCompositeType = isCompositeType;
|
|
38
|
+
exports.isEnumType = isEnumType;
|
|
39
|
+
exports.isInputObjectType = isInputObjectType;
|
|
40
|
+
exports.isInputType = isInputType;
|
|
41
|
+
exports.isInterfaceType = isInterfaceType;
|
|
42
|
+
exports.isLeafType = isLeafType;
|
|
43
|
+
exports.isListType = isListType;
|
|
44
|
+
exports.isNamedType = isNamedType;
|
|
45
|
+
exports.isNonNullType = isNonNullType;
|
|
46
|
+
exports.isNullableType = isNullableType;
|
|
47
|
+
exports.isObjectType = isObjectType;
|
|
48
|
+
exports.isOutputType = isOutputType;
|
|
49
|
+
exports.isRequiredArgument = isRequiredArgument;
|
|
50
|
+
exports.isRequiredInputField = isRequiredInputField;
|
|
51
|
+
exports.isScalarType = isScalarType;
|
|
52
|
+
exports.isType = isType;
|
|
53
|
+
exports.isUnionType = isUnionType;
|
|
54
|
+
exports.isWrappingType = isWrappingType;
|
|
55
|
+
exports.resolveObjMapThunk = resolveObjMapThunk;
|
|
56
|
+
exports.resolveReadonlyArrayThunk = resolveReadonlyArrayThunk;
|
|
57
|
+
|
|
58
|
+
var _devAssert = require('../jsutils/devAssert.js');
|
|
59
|
+
|
|
60
|
+
var _didYouMean = require('../jsutils/didYouMean.js');
|
|
61
|
+
|
|
62
|
+
var _identityFunc = require('../jsutils/identityFunc.js');
|
|
63
|
+
|
|
64
|
+
var _inspect = require('../jsutils/inspect.js');
|
|
65
|
+
|
|
66
|
+
var _instanceOf = require('../jsutils/instanceOf.js');
|
|
67
|
+
|
|
68
|
+
var _isObjectLike = require('../jsutils/isObjectLike.js');
|
|
69
|
+
|
|
70
|
+
var _keyMap = require('../jsutils/keyMap.js');
|
|
71
|
+
|
|
72
|
+
var _keyValMap = require('../jsutils/keyValMap.js');
|
|
73
|
+
|
|
74
|
+
var _mapValue = require('../jsutils/mapValue.js');
|
|
75
|
+
|
|
76
|
+
var _suggestionList = require('../jsutils/suggestionList.js');
|
|
77
|
+
|
|
78
|
+
var _toObjMap = require('../jsutils/toObjMap.js');
|
|
79
|
+
|
|
80
|
+
var _GraphQLError = require('../error/GraphQLError.js');
|
|
81
|
+
|
|
82
|
+
var _kinds = require('../language/kinds.js');
|
|
83
|
+
|
|
84
|
+
var _printer = require('../language/printer.js');
|
|
85
|
+
|
|
86
|
+
var _valueFromASTUntyped = require('../utilities/valueFromASTUntyped.js');
|
|
87
|
+
|
|
88
|
+
var _assertName = require('./assertName.js');
|
|
89
|
+
|
|
90
|
+
function isType(type) {
|
|
91
|
+
return (
|
|
92
|
+
isScalarType(type) ||
|
|
93
|
+
isObjectType(type) ||
|
|
94
|
+
isInterfaceType(type) ||
|
|
95
|
+
isUnionType(type) ||
|
|
96
|
+
isEnumType(type) ||
|
|
97
|
+
isInputObjectType(type) ||
|
|
98
|
+
isListType(type) ||
|
|
99
|
+
isNonNullType(type)
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function assertType(type) {
|
|
104
|
+
if (!isType(type)) {
|
|
105
|
+
throw new Error(
|
|
106
|
+
`Expected ${(0, _inspect.inspect)(type)} to be a GraphQL type.`,
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return type;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* There are predicates for each kind of GraphQL type.
|
|
114
|
+
*/
|
|
115
|
+
|
|
116
|
+
function isScalarType(type) {
|
|
117
|
+
return (0, _instanceOf.instanceOf)(type, GraphQLScalarType);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function assertScalarType(type) {
|
|
121
|
+
if (!isScalarType(type)) {
|
|
122
|
+
throw new Error(
|
|
123
|
+
`Expected ${(0, _inspect.inspect)(type)} to be a GraphQL Scalar type.`,
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return type;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function isObjectType(type) {
|
|
131
|
+
return (0, _instanceOf.instanceOf)(type, GraphQLObjectType);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function assertObjectType(type) {
|
|
135
|
+
if (!isObjectType(type)) {
|
|
136
|
+
throw new Error(
|
|
137
|
+
`Expected ${(0, _inspect.inspect)(type)} to be a GraphQL Object type.`,
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return type;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function isInterfaceType(type) {
|
|
145
|
+
return (0, _instanceOf.instanceOf)(type, GraphQLInterfaceType);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function assertInterfaceType(type) {
|
|
149
|
+
if (!isInterfaceType(type)) {
|
|
150
|
+
throw new Error(
|
|
151
|
+
`Expected ${(0, _inspect.inspect)(type)} to be a GraphQL Interface type.`,
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return type;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function isUnionType(type) {
|
|
159
|
+
return (0, _instanceOf.instanceOf)(type, GraphQLUnionType);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function assertUnionType(type) {
|
|
163
|
+
if (!isUnionType(type)) {
|
|
164
|
+
throw new Error(
|
|
165
|
+
`Expected ${(0, _inspect.inspect)(type)} to be a GraphQL Union type.`,
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return type;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function isEnumType(type) {
|
|
173
|
+
return (0, _instanceOf.instanceOf)(type, GraphQLEnumType);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function assertEnumType(type) {
|
|
177
|
+
if (!isEnumType(type)) {
|
|
178
|
+
throw new Error(
|
|
179
|
+
`Expected ${(0, _inspect.inspect)(type)} to be a GraphQL Enum type.`,
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return type;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function isInputObjectType(type) {
|
|
187
|
+
return (0, _instanceOf.instanceOf)(type, GraphQLInputObjectType);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function assertInputObjectType(type) {
|
|
191
|
+
if (!isInputObjectType(type)) {
|
|
192
|
+
throw new Error(
|
|
193
|
+
`Expected ${(0, _inspect.inspect)(
|
|
194
|
+
type,
|
|
195
|
+
)} to be a GraphQL Input Object type.`,
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return type;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function isListType(type) {
|
|
203
|
+
return (0, _instanceOf.instanceOf)(type, GraphQLList);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function assertListType(type) {
|
|
207
|
+
if (!isListType(type)) {
|
|
208
|
+
throw new Error(
|
|
209
|
+
`Expected ${(0, _inspect.inspect)(type)} to be a GraphQL List type.`,
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return type;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function isNonNullType(type) {
|
|
217
|
+
return (0, _instanceOf.instanceOf)(type, GraphQLNonNull);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function assertNonNullType(type) {
|
|
221
|
+
if (!isNonNullType(type)) {
|
|
222
|
+
throw new Error(
|
|
223
|
+
`Expected ${(0, _inspect.inspect)(type)} to be a GraphQL Non-Null type.`,
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return type;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* These types may be used as input types for arguments and directives.
|
|
231
|
+
*/
|
|
232
|
+
|
|
233
|
+
function isInputType(type) {
|
|
234
|
+
return (
|
|
235
|
+
isScalarType(type) ||
|
|
236
|
+
isEnumType(type) ||
|
|
237
|
+
isInputObjectType(type) ||
|
|
238
|
+
(isWrappingType(type) && isInputType(type.ofType))
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function assertInputType(type) {
|
|
243
|
+
if (!isInputType(type)) {
|
|
244
|
+
throw new Error(
|
|
245
|
+
`Expected ${(0, _inspect.inspect)(type)} to be a GraphQL input type.`,
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return type;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* These types may be used as output types as the result of fields.
|
|
253
|
+
*/
|
|
254
|
+
|
|
255
|
+
function isOutputType(type) {
|
|
256
|
+
return (
|
|
257
|
+
isScalarType(type) ||
|
|
258
|
+
isObjectType(type) ||
|
|
259
|
+
isInterfaceType(type) ||
|
|
260
|
+
isUnionType(type) ||
|
|
261
|
+
isEnumType(type) ||
|
|
262
|
+
(isWrappingType(type) && isOutputType(type.ofType))
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function assertOutputType(type) {
|
|
267
|
+
if (!isOutputType(type)) {
|
|
268
|
+
throw new Error(
|
|
269
|
+
`Expected ${(0, _inspect.inspect)(type)} to be a GraphQL output type.`,
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
return type;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* These types may describe types which may be leaf values.
|
|
277
|
+
*/
|
|
278
|
+
|
|
279
|
+
function isLeafType(type) {
|
|
280
|
+
return isScalarType(type) || isEnumType(type);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
function assertLeafType(type) {
|
|
284
|
+
if (!isLeafType(type)) {
|
|
285
|
+
throw new Error(
|
|
286
|
+
`Expected ${(0, _inspect.inspect)(type)} to be a GraphQL leaf type.`,
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
return type;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* These types may describe the parent context of a selection set.
|
|
294
|
+
*/
|
|
295
|
+
|
|
296
|
+
function isCompositeType(type) {
|
|
297
|
+
return isObjectType(type) || isInterfaceType(type) || isUnionType(type);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function assertCompositeType(type) {
|
|
301
|
+
if (!isCompositeType(type)) {
|
|
302
|
+
throw new Error(
|
|
303
|
+
`Expected ${(0, _inspect.inspect)(type)} to be a GraphQL composite type.`,
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
return type;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* These types may describe the parent context of a selection set.
|
|
311
|
+
*/
|
|
312
|
+
|
|
313
|
+
function isAbstractType(type) {
|
|
314
|
+
return isInterfaceType(type) || isUnionType(type);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function assertAbstractType(type) {
|
|
318
|
+
if (!isAbstractType(type)) {
|
|
319
|
+
throw new Error(
|
|
320
|
+
`Expected ${(0, _inspect.inspect)(type)} to be a GraphQL abstract type.`,
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
return type;
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* List Type Wrapper
|
|
328
|
+
*
|
|
329
|
+
* A list is a wrapping type which points to another type.
|
|
330
|
+
* Lists are often created within the context of defining the fields of
|
|
331
|
+
* an object type.
|
|
332
|
+
*
|
|
333
|
+
* Example:
|
|
334
|
+
*
|
|
335
|
+
* ```ts
|
|
336
|
+
* const PersonType = new GraphQLObjectType({
|
|
337
|
+
* name: 'Person',
|
|
338
|
+
* fields: () => ({
|
|
339
|
+
* parents: { type: new GraphQLList(PersonType) },
|
|
340
|
+
* children: { type: new GraphQLList(PersonType) },
|
|
341
|
+
* })
|
|
342
|
+
* })
|
|
343
|
+
* ```
|
|
344
|
+
*/
|
|
345
|
+
|
|
346
|
+
class GraphQLList {
|
|
347
|
+
constructor(ofType) {
|
|
348
|
+
isType(ofType) ||
|
|
349
|
+
(0, _devAssert.devAssert)(
|
|
350
|
+
false,
|
|
351
|
+
`Expected ${(0, _inspect.inspect)(ofType)} to be a GraphQL type.`,
|
|
352
|
+
);
|
|
353
|
+
this.ofType = ofType;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
get [Symbol.toStringTag]() {
|
|
357
|
+
return 'GraphQLList';
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
toString() {
|
|
361
|
+
return '[' + String(this.ofType) + ']';
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
toJSON() {
|
|
365
|
+
return this.toString();
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Non-Null Type Wrapper
|
|
370
|
+
*
|
|
371
|
+
* A non-null is a wrapping type which points to another type.
|
|
372
|
+
* Non-null types enforce that their values are never null and can ensure
|
|
373
|
+
* an error is raised if this ever occurs during a request. It is useful for
|
|
374
|
+
* fields which you can make a strong guarantee on non-nullability, for example
|
|
375
|
+
* usually the id field of a database row will never be null.
|
|
376
|
+
*
|
|
377
|
+
* Example:
|
|
378
|
+
*
|
|
379
|
+
* ```ts
|
|
380
|
+
* const RowType = new GraphQLObjectType({
|
|
381
|
+
* name: 'Row',
|
|
382
|
+
* fields: () => ({
|
|
383
|
+
* id: { type: new GraphQLNonNull(GraphQLString) },
|
|
384
|
+
* })
|
|
385
|
+
* })
|
|
386
|
+
* ```
|
|
387
|
+
* Note: the enforcement of non-nullability occurs within the executor.
|
|
388
|
+
*/
|
|
389
|
+
|
|
390
|
+
exports.GraphQLList = GraphQLList;
|
|
391
|
+
|
|
392
|
+
class GraphQLNonNull {
|
|
393
|
+
constructor(ofType) {
|
|
394
|
+
isNullableType(ofType) ||
|
|
395
|
+
(0, _devAssert.devAssert)(
|
|
396
|
+
false,
|
|
397
|
+
`Expected ${(0, _inspect.inspect)(
|
|
398
|
+
ofType,
|
|
399
|
+
)} to be a GraphQL nullable type.`,
|
|
400
|
+
);
|
|
401
|
+
this.ofType = ofType;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
get [Symbol.toStringTag]() {
|
|
405
|
+
return 'GraphQLNonNull';
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
toString() {
|
|
409
|
+
return String(this.ofType) + '!';
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
toJSON() {
|
|
413
|
+
return this.toString();
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* These types wrap and modify other types
|
|
418
|
+
*/
|
|
419
|
+
|
|
420
|
+
exports.GraphQLNonNull = GraphQLNonNull;
|
|
421
|
+
|
|
422
|
+
function isWrappingType(type) {
|
|
423
|
+
return isListType(type) || isNonNullType(type);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
function assertWrappingType(type) {
|
|
427
|
+
if (!isWrappingType(type)) {
|
|
428
|
+
throw new Error(
|
|
429
|
+
`Expected ${(0, _inspect.inspect)(type)} to be a GraphQL wrapping type.`,
|
|
430
|
+
);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
return type;
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* These types can all accept null as a value.
|
|
437
|
+
*/
|
|
438
|
+
|
|
439
|
+
function isNullableType(type) {
|
|
440
|
+
return isType(type) && !isNonNullType(type);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
function assertNullableType(type) {
|
|
444
|
+
if (!isNullableType(type)) {
|
|
445
|
+
throw new Error(
|
|
446
|
+
`Expected ${(0, _inspect.inspect)(type)} to be a GraphQL nullable type.`,
|
|
447
|
+
);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
return type;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
function getNullableType(type) {
|
|
454
|
+
if (type) {
|
|
455
|
+
return isNonNullType(type) ? type.ofType : type;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* These named types do not include modifiers like List or NonNull.
|
|
460
|
+
*/
|
|
461
|
+
|
|
462
|
+
function isNamedType(type) {
|
|
463
|
+
return (
|
|
464
|
+
isScalarType(type) ||
|
|
465
|
+
isObjectType(type) ||
|
|
466
|
+
isInterfaceType(type) ||
|
|
467
|
+
isUnionType(type) ||
|
|
468
|
+
isEnumType(type) ||
|
|
469
|
+
isInputObjectType(type)
|
|
470
|
+
);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
function assertNamedType(type) {
|
|
474
|
+
if (!isNamedType(type)) {
|
|
475
|
+
throw new Error(
|
|
476
|
+
`Expected ${(0, _inspect.inspect)(type)} to be a GraphQL named type.`,
|
|
477
|
+
);
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
return type;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
function getNamedType(type) {
|
|
484
|
+
if (type) {
|
|
485
|
+
let unwrappedType = type;
|
|
486
|
+
|
|
487
|
+
while (isWrappingType(unwrappedType)) {
|
|
488
|
+
unwrappedType = unwrappedType.ofType;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
return unwrappedType;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Used while defining GraphQL types to allow for circular references in
|
|
496
|
+
* otherwise immutable type definitions.
|
|
497
|
+
*/
|
|
498
|
+
|
|
499
|
+
function resolveReadonlyArrayThunk(thunk) {
|
|
500
|
+
return typeof thunk === 'function' ? thunk() : thunk;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
function resolveObjMapThunk(thunk) {
|
|
504
|
+
return typeof thunk === 'function' ? thunk() : thunk;
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Custom extensions
|
|
508
|
+
*
|
|
509
|
+
* @remarks
|
|
510
|
+
* Use a unique identifier name for your extension, for example the name of
|
|
511
|
+
* your library or project. Do not use a shortened identifier as this increases
|
|
512
|
+
* the risk of conflicts. We recommend you add at most one extension field,
|
|
513
|
+
* an object which can contain all the values you need.
|
|
514
|
+
*/
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* Scalar Type Definition
|
|
518
|
+
*
|
|
519
|
+
* The leaf values of any request and input values to arguments are
|
|
520
|
+
* Scalars (or Enums) and are defined with a name and a series of functions
|
|
521
|
+
* used to parse input from ast or variables and to ensure validity.
|
|
522
|
+
*
|
|
523
|
+
* If a type's serialize function does not return a value (i.e. it returns
|
|
524
|
+
* `undefined`) then an error will be raised and a `null` value will be returned
|
|
525
|
+
* in the response. If the serialize function returns `null`, then no error will
|
|
526
|
+
* be included in the response.
|
|
527
|
+
*
|
|
528
|
+
* Example:
|
|
529
|
+
*
|
|
530
|
+
* ```ts
|
|
531
|
+
* const OddType = new GraphQLScalarType({
|
|
532
|
+
* name: 'Odd',
|
|
533
|
+
* serialize(value) {
|
|
534
|
+
* if (value % 2 === 1) {
|
|
535
|
+
* return value;
|
|
536
|
+
* }
|
|
537
|
+
* }
|
|
538
|
+
* });
|
|
539
|
+
* ```
|
|
540
|
+
*/
|
|
541
|
+
class GraphQLScalarType {
|
|
542
|
+
constructor(config) {
|
|
543
|
+
var _config$parseValue,
|
|
544
|
+
_config$serialize,
|
|
545
|
+
_config$parseLiteral,
|
|
546
|
+
_config$extensionASTN;
|
|
547
|
+
|
|
548
|
+
const parseValue =
|
|
549
|
+
(_config$parseValue = config.parseValue) !== null &&
|
|
550
|
+
_config$parseValue !== void 0
|
|
551
|
+
? _config$parseValue
|
|
552
|
+
: _identityFunc.identityFunc;
|
|
553
|
+
this.name = (0, _assertName.assertName)(config.name);
|
|
554
|
+
this.description = config.description;
|
|
555
|
+
this.specifiedByURL = config.specifiedByURL;
|
|
556
|
+
this.serialize =
|
|
557
|
+
(_config$serialize = config.serialize) !== null &&
|
|
558
|
+
_config$serialize !== void 0
|
|
559
|
+
? _config$serialize
|
|
560
|
+
: _identityFunc.identityFunc;
|
|
561
|
+
this.parseValue = parseValue;
|
|
562
|
+
this.parseLiteral =
|
|
563
|
+
(_config$parseLiteral = config.parseLiteral) !== null &&
|
|
564
|
+
_config$parseLiteral !== void 0
|
|
565
|
+
? _config$parseLiteral
|
|
566
|
+
: (node, variables) =>
|
|
567
|
+
parseValue(
|
|
568
|
+
(0, _valueFromASTUntyped.valueFromASTUntyped)(node, variables),
|
|
569
|
+
);
|
|
570
|
+
this.extensions = (0, _toObjMap.toObjMap)(config.extensions);
|
|
571
|
+
this.astNode = config.astNode;
|
|
572
|
+
this.extensionASTNodes =
|
|
573
|
+
(_config$extensionASTN = config.extensionASTNodes) !== null &&
|
|
574
|
+
_config$extensionASTN !== void 0
|
|
575
|
+
? _config$extensionASTN
|
|
576
|
+
: [];
|
|
577
|
+
config.specifiedByURL == null ||
|
|
578
|
+
typeof config.specifiedByURL === 'string' ||
|
|
579
|
+
(0, _devAssert.devAssert)(
|
|
580
|
+
false,
|
|
581
|
+
`${this.name} must provide "specifiedByURL" as a string, ` +
|
|
582
|
+
`but got: ${(0, _inspect.inspect)(config.specifiedByURL)}.`,
|
|
583
|
+
);
|
|
584
|
+
config.serialize == null ||
|
|
585
|
+
typeof config.serialize === 'function' ||
|
|
586
|
+
(0, _devAssert.devAssert)(
|
|
587
|
+
false,
|
|
588
|
+
`${this.name} must provide "serialize" function. If this custom Scalar is also used as an input type, ensure "parseValue" and "parseLiteral" functions are also provided.`,
|
|
589
|
+
);
|
|
590
|
+
|
|
591
|
+
if (config.parseLiteral) {
|
|
592
|
+
(typeof config.parseValue === 'function' &&
|
|
593
|
+
typeof config.parseLiteral === 'function') ||
|
|
594
|
+
(0, _devAssert.devAssert)(
|
|
595
|
+
false,
|
|
596
|
+
`${this.name} must provide both "parseValue" and "parseLiteral" functions.`,
|
|
597
|
+
);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
get [Symbol.toStringTag]() {
|
|
602
|
+
return 'GraphQLScalarType';
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
toConfig() {
|
|
606
|
+
return {
|
|
607
|
+
name: this.name,
|
|
608
|
+
description: this.description,
|
|
609
|
+
specifiedByURL: this.specifiedByURL,
|
|
610
|
+
serialize: this.serialize,
|
|
611
|
+
parseValue: this.parseValue,
|
|
612
|
+
parseLiteral: this.parseLiteral,
|
|
613
|
+
extensions: this.extensions,
|
|
614
|
+
astNode: this.astNode,
|
|
615
|
+
extensionASTNodes: this.extensionASTNodes,
|
|
616
|
+
};
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
toString() {
|
|
620
|
+
return this.name;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
toJSON() {
|
|
624
|
+
return this.toString();
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
exports.GraphQLScalarType = GraphQLScalarType;
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
* Object Type Definition
|
|
632
|
+
*
|
|
633
|
+
* Almost all of the GraphQL types you define will be object types. Object types
|
|
634
|
+
* have a name, but most importantly describe their fields.
|
|
635
|
+
*
|
|
636
|
+
* Example:
|
|
637
|
+
*
|
|
638
|
+
* ```ts
|
|
639
|
+
* const AddressType = new GraphQLObjectType({
|
|
640
|
+
* name: 'Address',
|
|
641
|
+
* fields: {
|
|
642
|
+
* street: { type: GraphQLString },
|
|
643
|
+
* number: { type: GraphQLInt },
|
|
644
|
+
* formatted: {
|
|
645
|
+
* type: GraphQLString,
|
|
646
|
+
* resolve(obj) {
|
|
647
|
+
* return obj.number + ' ' + obj.street
|
|
648
|
+
* }
|
|
649
|
+
* }
|
|
650
|
+
* }
|
|
651
|
+
* });
|
|
652
|
+
* ```
|
|
653
|
+
*
|
|
654
|
+
* When two types need to refer to each other, or a type needs to refer to
|
|
655
|
+
* itself in a field, you can use a function expression (aka a closure or a
|
|
656
|
+
* thunk) to supply the fields lazily.
|
|
657
|
+
*
|
|
658
|
+
* Example:
|
|
659
|
+
*
|
|
660
|
+
* ```ts
|
|
661
|
+
* const PersonType = new GraphQLObjectType({
|
|
662
|
+
* name: 'Person',
|
|
663
|
+
* fields: () => ({
|
|
664
|
+
* name: { type: GraphQLString },
|
|
665
|
+
* bestFriend: { type: PersonType },
|
|
666
|
+
* })
|
|
667
|
+
* });
|
|
668
|
+
* ```
|
|
669
|
+
*/
|
|
670
|
+
class GraphQLObjectType {
|
|
671
|
+
constructor(config) {
|
|
672
|
+
var _config$extensionASTN2;
|
|
673
|
+
|
|
674
|
+
this.name = (0, _assertName.assertName)(config.name);
|
|
675
|
+
this.description = config.description;
|
|
676
|
+
this.isTypeOf = config.isTypeOf;
|
|
677
|
+
this.extensions = (0, _toObjMap.toObjMap)(config.extensions);
|
|
678
|
+
this.astNode = config.astNode;
|
|
679
|
+
this.extensionASTNodes =
|
|
680
|
+
(_config$extensionASTN2 = config.extensionASTNodes) !== null &&
|
|
681
|
+
_config$extensionASTN2 !== void 0
|
|
682
|
+
? _config$extensionASTN2
|
|
683
|
+
: [];
|
|
684
|
+
|
|
685
|
+
this._fields = () => defineFieldMap(config);
|
|
686
|
+
|
|
687
|
+
this._interfaces = () => defineInterfaces(config);
|
|
688
|
+
|
|
689
|
+
config.isTypeOf == null ||
|
|
690
|
+
typeof config.isTypeOf === 'function' ||
|
|
691
|
+
(0, _devAssert.devAssert)(
|
|
692
|
+
false,
|
|
693
|
+
`${this.name} must provide "isTypeOf" as a function, ` +
|
|
694
|
+
`but got: ${(0, _inspect.inspect)(config.isTypeOf)}.`,
|
|
695
|
+
);
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
get [Symbol.toStringTag]() {
|
|
699
|
+
return 'GraphQLObjectType';
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
getFields() {
|
|
703
|
+
if (typeof this._fields === 'function') {
|
|
704
|
+
this._fields = this._fields();
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
return this._fields;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
getInterfaces() {
|
|
711
|
+
if (typeof this._interfaces === 'function') {
|
|
712
|
+
this._interfaces = this._interfaces();
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
return this._interfaces;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
toConfig() {
|
|
719
|
+
return {
|
|
720
|
+
name: this.name,
|
|
721
|
+
description: this.description,
|
|
722
|
+
interfaces: this.getInterfaces(),
|
|
723
|
+
fields: fieldsToFieldsConfig(this.getFields()),
|
|
724
|
+
isTypeOf: this.isTypeOf,
|
|
725
|
+
extensions: this.extensions,
|
|
726
|
+
astNode: this.astNode,
|
|
727
|
+
extensionASTNodes: this.extensionASTNodes,
|
|
728
|
+
};
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
toString() {
|
|
732
|
+
return this.name;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
toJSON() {
|
|
736
|
+
return this.toString();
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
exports.GraphQLObjectType = GraphQLObjectType;
|
|
741
|
+
|
|
742
|
+
function defineInterfaces(config) {
|
|
743
|
+
var _config$interfaces;
|
|
744
|
+
|
|
745
|
+
const interfaces = resolveReadonlyArrayThunk(
|
|
746
|
+
(_config$interfaces = config.interfaces) !== null &&
|
|
747
|
+
_config$interfaces !== void 0
|
|
748
|
+
? _config$interfaces
|
|
749
|
+
: [],
|
|
750
|
+
);
|
|
751
|
+
Array.isArray(interfaces) ||
|
|
752
|
+
(0, _devAssert.devAssert)(
|
|
753
|
+
false,
|
|
754
|
+
`${config.name} interfaces must be an Array or a function which returns an Array.`,
|
|
755
|
+
);
|
|
756
|
+
return interfaces;
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
function defineFieldMap(config) {
|
|
760
|
+
const fieldMap = resolveObjMapThunk(config.fields);
|
|
761
|
+
isPlainObj(fieldMap) ||
|
|
762
|
+
(0, _devAssert.devAssert)(
|
|
763
|
+
false,
|
|
764
|
+
`${config.name} fields must be an object with field names as keys or a function which returns such an object.`,
|
|
765
|
+
);
|
|
766
|
+
return (0, _mapValue.mapValue)(fieldMap, (fieldConfig, fieldName) => {
|
|
767
|
+
var _fieldConfig$args;
|
|
768
|
+
|
|
769
|
+
isPlainObj(fieldConfig) ||
|
|
770
|
+
(0, _devAssert.devAssert)(
|
|
771
|
+
false,
|
|
772
|
+
`${config.name}.${fieldName} field config must be an object.`,
|
|
773
|
+
);
|
|
774
|
+
fieldConfig.resolve == null ||
|
|
775
|
+
typeof fieldConfig.resolve === 'function' ||
|
|
776
|
+
(0, _devAssert.devAssert)(
|
|
777
|
+
false,
|
|
778
|
+
`${config.name}.${fieldName} field resolver must be a function if ` +
|
|
779
|
+
`provided, but got: ${(0, _inspect.inspect)(fieldConfig.resolve)}.`,
|
|
780
|
+
);
|
|
781
|
+
const argsConfig =
|
|
782
|
+
(_fieldConfig$args = fieldConfig.args) !== null &&
|
|
783
|
+
_fieldConfig$args !== void 0
|
|
784
|
+
? _fieldConfig$args
|
|
785
|
+
: {};
|
|
786
|
+
isPlainObj(argsConfig) ||
|
|
787
|
+
(0, _devAssert.devAssert)(
|
|
788
|
+
false,
|
|
789
|
+
`${config.name}.${fieldName} args must be an object with argument names as keys.`,
|
|
790
|
+
);
|
|
791
|
+
return {
|
|
792
|
+
name: (0, _assertName.assertName)(fieldName),
|
|
793
|
+
description: fieldConfig.description,
|
|
794
|
+
type: fieldConfig.type,
|
|
795
|
+
args: defineArguments(argsConfig),
|
|
796
|
+
resolve: fieldConfig.resolve,
|
|
797
|
+
subscribe: fieldConfig.subscribe,
|
|
798
|
+
deprecationReason: fieldConfig.deprecationReason,
|
|
799
|
+
extensions: (0, _toObjMap.toObjMap)(fieldConfig.extensions),
|
|
800
|
+
astNode: fieldConfig.astNode,
|
|
801
|
+
};
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
function defineArguments(config) {
|
|
806
|
+
return Object.entries(config).map(([argName, argConfig]) => ({
|
|
807
|
+
name: (0, _assertName.assertName)(argName),
|
|
808
|
+
description: argConfig.description,
|
|
809
|
+
type: argConfig.type,
|
|
810
|
+
defaultValue: argConfig.defaultValue,
|
|
811
|
+
deprecationReason: argConfig.deprecationReason,
|
|
812
|
+
extensions: (0, _toObjMap.toObjMap)(argConfig.extensions),
|
|
813
|
+
astNode: argConfig.astNode,
|
|
814
|
+
}));
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
function isPlainObj(obj) {
|
|
818
|
+
return (0, _isObjectLike.isObjectLike)(obj) && !Array.isArray(obj);
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
function fieldsToFieldsConfig(fields) {
|
|
822
|
+
return (0, _mapValue.mapValue)(fields, (field) => ({
|
|
823
|
+
description: field.description,
|
|
824
|
+
type: field.type,
|
|
825
|
+
args: argsToArgsConfig(field.args),
|
|
826
|
+
resolve: field.resolve,
|
|
827
|
+
subscribe: field.subscribe,
|
|
828
|
+
deprecationReason: field.deprecationReason,
|
|
829
|
+
extensions: field.extensions,
|
|
830
|
+
astNode: field.astNode,
|
|
831
|
+
}));
|
|
832
|
+
}
|
|
833
|
+
/**
|
|
834
|
+
* @internal
|
|
835
|
+
*/
|
|
836
|
+
|
|
837
|
+
function argsToArgsConfig(args) {
|
|
838
|
+
return (0, _keyValMap.keyValMap)(
|
|
839
|
+
args,
|
|
840
|
+
(arg) => arg.name,
|
|
841
|
+
(arg) => ({
|
|
842
|
+
description: arg.description,
|
|
843
|
+
type: arg.type,
|
|
844
|
+
defaultValue: arg.defaultValue,
|
|
845
|
+
deprecationReason: arg.deprecationReason,
|
|
846
|
+
extensions: arg.extensions,
|
|
847
|
+
astNode: arg.astNode,
|
|
848
|
+
}),
|
|
849
|
+
);
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
function isRequiredArgument(arg) {
|
|
853
|
+
return isNonNullType(arg.type) && arg.defaultValue === undefined;
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
/**
|
|
857
|
+
* Interface Type Definition
|
|
858
|
+
*
|
|
859
|
+
* When a field can return one of a heterogeneous set of types, a Interface type
|
|
860
|
+
* is used to describe what types are possible, what fields are in common across
|
|
861
|
+
* all types, as well as a function to determine which type is actually used
|
|
862
|
+
* when the field is resolved.
|
|
863
|
+
*
|
|
864
|
+
* Example:
|
|
865
|
+
*
|
|
866
|
+
* ```ts
|
|
867
|
+
* const EntityType = new GraphQLInterfaceType({
|
|
868
|
+
* name: 'Entity',
|
|
869
|
+
* fields: {
|
|
870
|
+
* name: { type: GraphQLString }
|
|
871
|
+
* }
|
|
872
|
+
* });
|
|
873
|
+
* ```
|
|
874
|
+
*/
|
|
875
|
+
class GraphQLInterfaceType {
|
|
876
|
+
constructor(config) {
|
|
877
|
+
var _config$extensionASTN3;
|
|
878
|
+
|
|
879
|
+
this.name = (0, _assertName.assertName)(config.name);
|
|
880
|
+
this.description = config.description;
|
|
881
|
+
this.resolveType = config.resolveType;
|
|
882
|
+
this.extensions = (0, _toObjMap.toObjMap)(config.extensions);
|
|
883
|
+
this.astNode = config.astNode;
|
|
884
|
+
this.extensionASTNodes =
|
|
885
|
+
(_config$extensionASTN3 = config.extensionASTNodes) !== null &&
|
|
886
|
+
_config$extensionASTN3 !== void 0
|
|
887
|
+
? _config$extensionASTN3
|
|
888
|
+
: [];
|
|
889
|
+
this._fields = defineFieldMap.bind(undefined, config);
|
|
890
|
+
this._interfaces = defineInterfaces.bind(undefined, config);
|
|
891
|
+
config.resolveType == null ||
|
|
892
|
+
typeof config.resolveType === 'function' ||
|
|
893
|
+
(0, _devAssert.devAssert)(
|
|
894
|
+
false,
|
|
895
|
+
`${this.name} must provide "resolveType" as a function, ` +
|
|
896
|
+
`but got: ${(0, _inspect.inspect)(config.resolveType)}.`,
|
|
897
|
+
);
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
get [Symbol.toStringTag]() {
|
|
901
|
+
return 'GraphQLInterfaceType';
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
getFields() {
|
|
905
|
+
if (typeof this._fields === 'function') {
|
|
906
|
+
this._fields = this._fields();
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
return this._fields;
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
getInterfaces() {
|
|
913
|
+
if (typeof this._interfaces === 'function') {
|
|
914
|
+
this._interfaces = this._interfaces();
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
return this._interfaces;
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
toConfig() {
|
|
921
|
+
return {
|
|
922
|
+
name: this.name,
|
|
923
|
+
description: this.description,
|
|
924
|
+
interfaces: this.getInterfaces(),
|
|
925
|
+
fields: fieldsToFieldsConfig(this.getFields()),
|
|
926
|
+
resolveType: this.resolveType,
|
|
927
|
+
extensions: this.extensions,
|
|
928
|
+
astNode: this.astNode,
|
|
929
|
+
extensionASTNodes: this.extensionASTNodes,
|
|
930
|
+
};
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
toString() {
|
|
934
|
+
return this.name;
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
toJSON() {
|
|
938
|
+
return this.toString();
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
exports.GraphQLInterfaceType = GraphQLInterfaceType;
|
|
943
|
+
|
|
944
|
+
/**
|
|
945
|
+
* Union Type Definition
|
|
946
|
+
*
|
|
947
|
+
* When a field can return one of a heterogeneous set of types, a Union type
|
|
948
|
+
* is used to describe what types are possible as well as providing a function
|
|
949
|
+
* to determine which type is actually used when the field is resolved.
|
|
950
|
+
*
|
|
951
|
+
* Example:
|
|
952
|
+
*
|
|
953
|
+
* ```ts
|
|
954
|
+
* const PetType = new GraphQLUnionType({
|
|
955
|
+
* name: 'Pet',
|
|
956
|
+
* types: [ DogType, CatType ],
|
|
957
|
+
* resolveType(value) {
|
|
958
|
+
* if (value instanceof Dog) {
|
|
959
|
+
* return DogType;
|
|
960
|
+
* }
|
|
961
|
+
* if (value instanceof Cat) {
|
|
962
|
+
* return CatType;
|
|
963
|
+
* }
|
|
964
|
+
* }
|
|
965
|
+
* });
|
|
966
|
+
* ```
|
|
967
|
+
*/
|
|
968
|
+
class GraphQLUnionType {
|
|
969
|
+
constructor(config) {
|
|
970
|
+
var _config$extensionASTN4;
|
|
971
|
+
|
|
972
|
+
this.name = (0, _assertName.assertName)(config.name);
|
|
973
|
+
this.description = config.description;
|
|
974
|
+
this.resolveType = config.resolveType;
|
|
975
|
+
this.extensions = (0, _toObjMap.toObjMap)(config.extensions);
|
|
976
|
+
this.astNode = config.astNode;
|
|
977
|
+
this.extensionASTNodes =
|
|
978
|
+
(_config$extensionASTN4 = config.extensionASTNodes) !== null &&
|
|
979
|
+
_config$extensionASTN4 !== void 0
|
|
980
|
+
? _config$extensionASTN4
|
|
981
|
+
: [];
|
|
982
|
+
this._types = defineTypes.bind(undefined, config);
|
|
983
|
+
config.resolveType == null ||
|
|
984
|
+
typeof config.resolveType === 'function' ||
|
|
985
|
+
(0, _devAssert.devAssert)(
|
|
986
|
+
false,
|
|
987
|
+
`${this.name} must provide "resolveType" as a function, ` +
|
|
988
|
+
`but got: ${(0, _inspect.inspect)(config.resolveType)}.`,
|
|
989
|
+
);
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
get [Symbol.toStringTag]() {
|
|
993
|
+
return 'GraphQLUnionType';
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
getTypes() {
|
|
997
|
+
if (typeof this._types === 'function') {
|
|
998
|
+
this._types = this._types();
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
return this._types;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
toConfig() {
|
|
1005
|
+
return {
|
|
1006
|
+
name: this.name,
|
|
1007
|
+
description: this.description,
|
|
1008
|
+
types: this.getTypes(),
|
|
1009
|
+
resolveType: this.resolveType,
|
|
1010
|
+
extensions: this.extensions,
|
|
1011
|
+
astNode: this.astNode,
|
|
1012
|
+
extensionASTNodes: this.extensionASTNodes,
|
|
1013
|
+
};
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
toString() {
|
|
1017
|
+
return this.name;
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
toJSON() {
|
|
1021
|
+
return this.toString();
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
exports.GraphQLUnionType = GraphQLUnionType;
|
|
1026
|
+
|
|
1027
|
+
function defineTypes(config) {
|
|
1028
|
+
const types = resolveReadonlyArrayThunk(config.types);
|
|
1029
|
+
Array.isArray(types) ||
|
|
1030
|
+
(0, _devAssert.devAssert)(
|
|
1031
|
+
false,
|
|
1032
|
+
`Must provide Array of types or a function which returns such an array for Union ${config.name}.`,
|
|
1033
|
+
);
|
|
1034
|
+
return types;
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
/**
|
|
1038
|
+
* Enum Type Definition
|
|
1039
|
+
*
|
|
1040
|
+
* Some leaf values of requests and input values are Enums. GraphQL serializes
|
|
1041
|
+
* Enum values as strings, however internally Enums can be represented by any
|
|
1042
|
+
* kind of type, often integers.
|
|
1043
|
+
*
|
|
1044
|
+
* Example:
|
|
1045
|
+
*
|
|
1046
|
+
* ```ts
|
|
1047
|
+
* const RGBType = new GraphQLEnumType({
|
|
1048
|
+
* name: 'RGB',
|
|
1049
|
+
* values: {
|
|
1050
|
+
* RED: { value: 0 },
|
|
1051
|
+
* GREEN: { value: 1 },
|
|
1052
|
+
* BLUE: { value: 2 }
|
|
1053
|
+
* }
|
|
1054
|
+
* });
|
|
1055
|
+
* ```
|
|
1056
|
+
*
|
|
1057
|
+
* Note: If a value is not provided in a definition, the name of the enum value
|
|
1058
|
+
* will be used as its internal value.
|
|
1059
|
+
*/
|
|
1060
|
+
class GraphQLEnumType {
|
|
1061
|
+
/* <T> */
|
|
1062
|
+
constructor(config) {
|
|
1063
|
+
var _config$extensionASTN5;
|
|
1064
|
+
|
|
1065
|
+
this.name = (0, _assertName.assertName)(config.name);
|
|
1066
|
+
this.description = config.description;
|
|
1067
|
+
this.extensions = (0, _toObjMap.toObjMap)(config.extensions);
|
|
1068
|
+
this.astNode = config.astNode;
|
|
1069
|
+
this.extensionASTNodes =
|
|
1070
|
+
(_config$extensionASTN5 = config.extensionASTNodes) !== null &&
|
|
1071
|
+
_config$extensionASTN5 !== void 0
|
|
1072
|
+
? _config$extensionASTN5
|
|
1073
|
+
: [];
|
|
1074
|
+
this._values = defineEnumValues(this.name, config.values);
|
|
1075
|
+
this._valueLookup = new Map(
|
|
1076
|
+
this._values.map((enumValue) => [enumValue.value, enumValue]),
|
|
1077
|
+
);
|
|
1078
|
+
this._nameLookup = (0, _keyMap.keyMap)(this._values, (value) => value.name);
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
get [Symbol.toStringTag]() {
|
|
1082
|
+
return 'GraphQLEnumType';
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
getValues() {
|
|
1086
|
+
return this._values;
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
getValue(name) {
|
|
1090
|
+
return this._nameLookup[name];
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
serialize(outputValue) {
|
|
1094
|
+
const enumValue = this._valueLookup.get(outputValue);
|
|
1095
|
+
|
|
1096
|
+
if (enumValue === undefined) {
|
|
1097
|
+
throw new _GraphQLError.GraphQLError(
|
|
1098
|
+
`Enum "${this.name}" cannot represent value: ${(0, _inspect.inspect)(
|
|
1099
|
+
outputValue,
|
|
1100
|
+
)}`,
|
|
1101
|
+
);
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
return enumValue.name;
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
parseValue(inputValue) /* T */
|
|
1108
|
+
{
|
|
1109
|
+
if (typeof inputValue !== 'string') {
|
|
1110
|
+
const valueStr = (0, _inspect.inspect)(inputValue);
|
|
1111
|
+
throw new _GraphQLError.GraphQLError(
|
|
1112
|
+
`Enum "${this.name}" cannot represent non-string value: ${valueStr}.` +
|
|
1113
|
+
didYouMeanEnumValue(this, valueStr),
|
|
1114
|
+
);
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
const enumValue = this.getValue(inputValue);
|
|
1118
|
+
|
|
1119
|
+
if (enumValue == null) {
|
|
1120
|
+
throw new _GraphQLError.GraphQLError(
|
|
1121
|
+
`Value "${inputValue}" does not exist in "${this.name}" enum.` +
|
|
1122
|
+
didYouMeanEnumValue(this, inputValue),
|
|
1123
|
+
);
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
return enumValue.value;
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
parseLiteral(valueNode, _variables) /* T */
|
|
1130
|
+
{
|
|
1131
|
+
// Note: variables will be resolved to a value before calling this function.
|
|
1132
|
+
if (valueNode.kind !== _kinds.Kind.ENUM) {
|
|
1133
|
+
const valueStr = (0, _printer.print)(valueNode);
|
|
1134
|
+
throw new _GraphQLError.GraphQLError(
|
|
1135
|
+
`Enum "${this.name}" cannot represent non-enum value: ${valueStr}.` +
|
|
1136
|
+
didYouMeanEnumValue(this, valueStr),
|
|
1137
|
+
valueNode,
|
|
1138
|
+
);
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
const enumValue = this.getValue(valueNode.value);
|
|
1142
|
+
|
|
1143
|
+
if (enumValue == null) {
|
|
1144
|
+
const valueStr = (0, _printer.print)(valueNode);
|
|
1145
|
+
throw new _GraphQLError.GraphQLError(
|
|
1146
|
+
`Value "${valueStr}" does not exist in "${this.name}" enum.` +
|
|
1147
|
+
didYouMeanEnumValue(this, valueStr),
|
|
1148
|
+
valueNode,
|
|
1149
|
+
);
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
return enumValue.value;
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
toConfig() {
|
|
1156
|
+
const values = (0, _keyValMap.keyValMap)(
|
|
1157
|
+
this.getValues(),
|
|
1158
|
+
(value) => value.name,
|
|
1159
|
+
(value) => ({
|
|
1160
|
+
description: value.description,
|
|
1161
|
+
value: value.value,
|
|
1162
|
+
deprecationReason: value.deprecationReason,
|
|
1163
|
+
extensions: value.extensions,
|
|
1164
|
+
astNode: value.astNode,
|
|
1165
|
+
}),
|
|
1166
|
+
);
|
|
1167
|
+
return {
|
|
1168
|
+
name: this.name,
|
|
1169
|
+
description: this.description,
|
|
1170
|
+
values,
|
|
1171
|
+
extensions: this.extensions,
|
|
1172
|
+
astNode: this.astNode,
|
|
1173
|
+
extensionASTNodes: this.extensionASTNodes,
|
|
1174
|
+
};
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
toString() {
|
|
1178
|
+
return this.name;
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
toJSON() {
|
|
1182
|
+
return this.toString();
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
exports.GraphQLEnumType = GraphQLEnumType;
|
|
1187
|
+
|
|
1188
|
+
function didYouMeanEnumValue(enumType, unknownValueStr) {
|
|
1189
|
+
const allNames = enumType.getValues().map((value) => value.name);
|
|
1190
|
+
const suggestedValues = (0, _suggestionList.suggestionList)(
|
|
1191
|
+
unknownValueStr,
|
|
1192
|
+
allNames,
|
|
1193
|
+
);
|
|
1194
|
+
return (0, _didYouMean.didYouMean)('the enum value', suggestedValues);
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
function defineEnumValues(typeName, valueMap) {
|
|
1198
|
+
isPlainObj(valueMap) ||
|
|
1199
|
+
(0, _devAssert.devAssert)(
|
|
1200
|
+
false,
|
|
1201
|
+
`${typeName} values must be an object with value names as keys.`,
|
|
1202
|
+
);
|
|
1203
|
+
return Object.entries(valueMap).map(([valueName, valueConfig]) => {
|
|
1204
|
+
isPlainObj(valueConfig) ||
|
|
1205
|
+
(0, _devAssert.devAssert)(
|
|
1206
|
+
false,
|
|
1207
|
+
`${typeName}.${valueName} must refer to an object with a "value" key ` +
|
|
1208
|
+
`representing an internal value but got: ${(0, _inspect.inspect)(
|
|
1209
|
+
valueConfig,
|
|
1210
|
+
)}.`,
|
|
1211
|
+
);
|
|
1212
|
+
return {
|
|
1213
|
+
name: (0, _assertName.assertEnumValueName)(valueName),
|
|
1214
|
+
description: valueConfig.description,
|
|
1215
|
+
value: valueConfig.value !== undefined ? valueConfig.value : valueName,
|
|
1216
|
+
deprecationReason: valueConfig.deprecationReason,
|
|
1217
|
+
extensions: (0, _toObjMap.toObjMap)(valueConfig.extensions),
|
|
1218
|
+
astNode: valueConfig.astNode,
|
|
1219
|
+
};
|
|
1220
|
+
});
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
/**
|
|
1224
|
+
* Input Object Type Definition
|
|
1225
|
+
*
|
|
1226
|
+
* An input object defines a structured collection of fields which may be
|
|
1227
|
+
* supplied to a field argument.
|
|
1228
|
+
*
|
|
1229
|
+
* Using `NonNull` will ensure that a value must be provided by the query
|
|
1230
|
+
*
|
|
1231
|
+
* Example:
|
|
1232
|
+
*
|
|
1233
|
+
* ```ts
|
|
1234
|
+
* const GeoPoint = new GraphQLInputObjectType({
|
|
1235
|
+
* name: 'GeoPoint',
|
|
1236
|
+
* fields: {
|
|
1237
|
+
* lat: { type: new GraphQLNonNull(GraphQLFloat) },
|
|
1238
|
+
* lon: { type: new GraphQLNonNull(GraphQLFloat) },
|
|
1239
|
+
* alt: { type: GraphQLFloat, defaultValue: 0 },
|
|
1240
|
+
* }
|
|
1241
|
+
* });
|
|
1242
|
+
* ```
|
|
1243
|
+
*/
|
|
1244
|
+
class GraphQLInputObjectType {
|
|
1245
|
+
constructor(config) {
|
|
1246
|
+
var _config$extensionASTN6;
|
|
1247
|
+
|
|
1248
|
+
this.name = (0, _assertName.assertName)(config.name);
|
|
1249
|
+
this.description = config.description;
|
|
1250
|
+
this.extensions = (0, _toObjMap.toObjMap)(config.extensions);
|
|
1251
|
+
this.astNode = config.astNode;
|
|
1252
|
+
this.extensionASTNodes =
|
|
1253
|
+
(_config$extensionASTN6 = config.extensionASTNodes) !== null &&
|
|
1254
|
+
_config$extensionASTN6 !== void 0
|
|
1255
|
+
? _config$extensionASTN6
|
|
1256
|
+
: [];
|
|
1257
|
+
this._fields = defineInputFieldMap.bind(undefined, config);
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
get [Symbol.toStringTag]() {
|
|
1261
|
+
return 'GraphQLInputObjectType';
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
getFields() {
|
|
1265
|
+
if (typeof this._fields === 'function') {
|
|
1266
|
+
this._fields = this._fields();
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
return this._fields;
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
toConfig() {
|
|
1273
|
+
const fields = (0, _mapValue.mapValue)(this.getFields(), (field) => ({
|
|
1274
|
+
description: field.description,
|
|
1275
|
+
type: field.type,
|
|
1276
|
+
defaultValue: field.defaultValue,
|
|
1277
|
+
deprecationReason: field.deprecationReason,
|
|
1278
|
+
extensions: field.extensions,
|
|
1279
|
+
astNode: field.astNode,
|
|
1280
|
+
}));
|
|
1281
|
+
return {
|
|
1282
|
+
name: this.name,
|
|
1283
|
+
description: this.description,
|
|
1284
|
+
fields,
|
|
1285
|
+
extensions: this.extensions,
|
|
1286
|
+
astNode: this.astNode,
|
|
1287
|
+
extensionASTNodes: this.extensionASTNodes,
|
|
1288
|
+
};
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
toString() {
|
|
1292
|
+
return this.name;
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
toJSON() {
|
|
1296
|
+
return this.toString();
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
exports.GraphQLInputObjectType = GraphQLInputObjectType;
|
|
1301
|
+
|
|
1302
|
+
function defineInputFieldMap(config) {
|
|
1303
|
+
const fieldMap = resolveObjMapThunk(config.fields);
|
|
1304
|
+
isPlainObj(fieldMap) ||
|
|
1305
|
+
(0, _devAssert.devAssert)(
|
|
1306
|
+
false,
|
|
1307
|
+
`${config.name} fields must be an object with field names as keys or a function which returns such an object.`,
|
|
1308
|
+
);
|
|
1309
|
+
return (0, _mapValue.mapValue)(fieldMap, (fieldConfig, fieldName) => {
|
|
1310
|
+
!('resolve' in fieldConfig) ||
|
|
1311
|
+
(0, _devAssert.devAssert)(
|
|
1312
|
+
false,
|
|
1313
|
+
`${config.name}.${fieldName} field has a resolve property, but Input Types cannot define resolvers.`,
|
|
1314
|
+
);
|
|
1315
|
+
return {
|
|
1316
|
+
name: (0, _assertName.assertName)(fieldName),
|
|
1317
|
+
description: fieldConfig.description,
|
|
1318
|
+
type: fieldConfig.type,
|
|
1319
|
+
defaultValue: fieldConfig.defaultValue,
|
|
1320
|
+
deprecationReason: fieldConfig.deprecationReason,
|
|
1321
|
+
extensions: (0, _toObjMap.toObjMap)(fieldConfig.extensions),
|
|
1322
|
+
astNode: fieldConfig.astNode,
|
|
1323
|
+
};
|
|
1324
|
+
});
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
function isRequiredInputField(field) {
|
|
1328
|
+
return isNonNullType(field.type) && field.defaultValue === undefined;
|
|
1329
|
+
}
|