graphql 0.12.3 → 0.13.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/error/GraphQLError.js +2 -3
- package/error/GraphQLError.js.flow +3 -4
- package/{module/error/GraphQLError.js → error/GraphQLError.mjs} +2 -3
- package/error/formatError.js +1 -1
- package/error/formatError.js.flow +1 -1
- package/{module/error/formatError.js → error/formatError.mjs} +1 -1
- package/error/index.js.flow +1 -1
- package/{module/error/index.js → error/index.mjs} +1 -1
- package/error/locatedError.js +2 -1
- package/error/locatedError.js.flow +2 -1
- package/{module/error/locatedError.js → error/locatedError.mjs} +2 -1
- package/error/printError.js +1 -1
- package/error/printError.js.flow +1 -1
- package/{module/error/printError.js → error/printError.mjs} +1 -1
- package/error/syntaxError.js +1 -1
- package/error/syntaxError.js.flow +1 -1
- package/{module/error/syntaxError.js → error/syntaxError.mjs} +1 -1
- package/execution/execute.js +70 -90
- package/execution/execute.js.flow +83 -106
- package/{module/execution/execute.js → execution/execute.mjs} +53 -81
- package/execution/index.js.flow +1 -1
- package/{module/execution/index.js → execution/index.mjs} +1 -1
- package/execution/values.js +2 -6
- package/execution/values.js.flow +6 -7
- package/{module/execution/values.js → execution/values.mjs} +2 -2
- package/graphql.js +1 -1
- package/graphql.js.flow +3 -2
- package/{module/graphql.js → graphql.mjs} +1 -1
- package/index.js +24 -6
- package/index.js.flow +16 -2
- package/{module/index.js → index.mjs} +10 -2
- package/jsutils/MaybePromise.js +1 -0
- package/{module/jsutils/ObjMap.js.flow → jsutils/MaybePromise.js.flow} +2 -2
- package/{module/jsutils/ObjMap.js → jsutils/MaybePromise.mjs} +0 -0
- package/jsutils/ObjMap.js.flow +1 -1
- package/{module/language/ast.js → jsutils/ObjMap.mjs} +0 -0
- package/jsutils/dedent.js +23 -18
- package/jsutils/dedent.js.flow +21 -20
- package/jsutils/dedent.mjs +50 -0
- package/jsutils/find.js +1 -1
- package/jsutils/find.js.flow +1 -1
- package/{module/jsutils/find.js → jsutils/find.mjs} +1 -1
- package/jsutils/instanceOf.js +17 -16
- package/jsutils/instanceOf.js.flow +21 -15
- package/jsutils/instanceOf.mjs +31 -0
- package/jsutils/invariant.js +1 -1
- package/jsutils/invariant.js.flow +1 -1
- package/{module/jsutils/invariant.js → jsutils/invariant.mjs} +1 -1
- package/jsutils/isInvalid.js +1 -1
- package/jsutils/isInvalid.js.flow +1 -1
- package/{module/jsutils/isInvalid.js → jsutils/isInvalid.mjs} +1 -1
- package/jsutils/isNullish.js +1 -1
- package/jsutils/isNullish.js.flow +1 -1
- package/{module/jsutils/isNullish.js → jsutils/isNullish.mjs} +1 -1
- package/jsutils/isPromise.js +24 -0
- package/jsutils/isPromise.js.flow +20 -0
- package/jsutils/isPromise.mjs +18 -0
- package/jsutils/keyMap.js +1 -1
- package/jsutils/keyMap.js.flow +1 -1
- package/{module/jsutils/keyMap.js → jsutils/keyMap.mjs} +1 -1
- package/jsutils/keyValMap.js +1 -1
- package/jsutils/keyValMap.js.flow +1 -1
- package/{module/jsutils/keyValMap.js → jsutils/keyValMap.mjs} +1 -1
- package/jsutils/memoize3.js +48 -0
- package/jsutils/memoize3.js.flow +44 -0
- package/jsutils/memoize3.mjs +42 -0
- package/jsutils/objectValues.js +24 -0
- package/jsutils/objectValues.js.flow +18 -0
- package/jsutils/objectValues.mjs +19 -0
- package/jsutils/orList.js +1 -1
- package/jsutils/orList.js.flow +1 -1
- package/{module/jsutils/orList.js → jsutils/orList.mjs} +1 -1
- package/jsutils/promiseForObject.js +34 -0
- package/jsutils/promiseForObject.js.flow +30 -0
- package/jsutils/promiseForObject.mjs +28 -0
- package/jsutils/promiseReduce.js +34 -0
- package/jsutils/promiseReduce.js.flow +32 -0
- package/jsutils/promiseReduce.mjs +26 -0
- package/jsutils/quotedOrList.js +1 -1
- package/jsutils/quotedOrList.js.flow +1 -1
- package/{module/jsutils/quotedOrList.js → jsutils/quotedOrList.mjs} +1 -1
- package/jsutils/suggestionList.js +1 -1
- package/jsutils/suggestionList.js.flow +1 -1
- package/{module/jsutils/suggestionList.js → jsutils/suggestionList.mjs} +1 -1
- package/language/ast.js.flow +3 -30
- package/language/ast.mjs +0 -0
- package/language/blockStringValue.js +1 -1
- package/language/blockStringValue.js.flow +1 -1
- package/{module/language/blockStringValue.js → language/blockStringValue.mjs} +1 -1
- package/language/directiveLocation.js +3 -3
- package/language/directiveLocation.js.flow +4 -4
- package/{module/language/directiveLocation.js → language/directiveLocation.mjs} +3 -3
- package/language/index.js +10 -10
- package/language/index.js.flow +5 -4
- package/{module/language/index.js → language/index.mjs} +3 -3
- package/language/kinds.js +70 -71
- package/language/kinds.js.flow +71 -71
- package/language/kinds.mjs +79 -0
- package/language/lexer.js +73 -87
- package/language/lexer.js.flow +87 -93
- package/{module/language/lexer.js → language/lexer.mjs} +73 -87
- package/language/location.js +1 -1
- package/language/location.js.flow +1 -1
- package/{module/language/location.js → language/location.mjs} +1 -1
- package/language/parser.js +68 -58
- package/language/parser.js.flow +104 -110
- package/{module/language/parser.js → language/parser.mjs} +69 -59
- package/language/printer.js +52 -55
- package/language/printer.js.flow +74 -120
- package/{module/language/printer.js → language/printer.mjs} +52 -55
- package/language/source.js +1 -1
- package/language/source.js.flow +1 -1
- package/{module/language/source.js → language/source.mjs} +1 -1
- package/language/visitor.js +1 -1
- package/language/visitor.js.flow +1 -1
- package/{module/language/visitor.js → language/visitor.mjs} +1 -1
- package/package.json +4 -9
- package/subscription/asyncIteratorReject.js +1 -1
- package/subscription/asyncIteratorReject.js.flow +1 -1
- package/{module/subscription/asyncIteratorReject.js → subscription/asyncIteratorReject.mjs} +1 -1
- package/subscription/index.js.flow +1 -1
- package/{module/subscription/index.js → subscription/index.mjs} +1 -1
- package/subscription/mapAsyncIterator.js +3 -1
- package/subscription/mapAsyncIterator.js.flow +7 -4
- package/{module/subscription/mapAsyncIterator.js → subscription/mapAsyncIterator.mjs} +4 -1
- package/subscription/subscribe.js +1 -1
- package/subscription/subscribe.js.flow +1 -1
- package/{module/subscription/subscribe.js → subscription/subscribe.mjs} +1 -1
- package/type/definition.js +76 -10
- package/type/definition.js.flow +105 -13
- package/{module/type/definition.js → type/definition.mjs} +72 -4
- package/type/directives.js +4 -4
- package/type/directives.js.flow +3 -3
- package/{module/type/directives.js → type/directives.mjs} +8 -8
- package/type/index.js +2 -5
- package/type/index.js.flow +6 -5
- package/{module/type/index.js → type/index.mjs} +3 -5
- package/type/introspection.js +34 -41
- package/type/introspection.js.flow +7 -10
- package/{module/type/introspection.js → type/introspection.mjs} +6 -15
- package/type/scalars.js +6 -10
- package/type/scalars.js.flow +2 -2
- package/{module/type/scalars.js → type/scalars.mjs} +2 -2
- package/type/schema.js +39 -15
- package/type/schema.js.flow +73 -22
- package/{module/type/schema.js → type/schema.mjs} +37 -16
- package/type/validate.js +33 -30
- package/type/validate.js.flow +40 -37
- package/{module/type/validate.js → type/validate.mjs} +30 -30
- package/utilities/TypeInfo.js +23 -27
- package/utilities/TypeInfo.js.flow +2 -2
- package/{module/utilities/TypeInfo.js → utilities/TypeInfo.mjs} +2 -2
- package/utilities/assertValidName.js +2 -6
- package/utilities/assertValidName.js.flow +2 -10
- package/{module/utilities/assertValidName.js → utilities/assertValidName.mjs} +2 -6
- package/utilities/astFromValue.js +37 -37
- package/utilities/astFromValue.js.flow +36 -44
- package/{module/utilities/astFromValue.js → utilities/astFromValue.mjs} +26 -25
- package/utilities/buildASTSchema.js +65 -82
- package/utilities/buildASTSchema.js.flow +52 -59
- package/{module/utilities/buildASTSchema.js → utilities/buildASTSchema.mjs} +48 -62
- package/utilities/buildClientSchema.js +12 -15
- package/utilities/buildClientSchema.js.flow +7 -11
- package/{module/utilities/buildClientSchema.js → utilities/buildClientSchema.mjs} +4 -5
- package/utilities/coerceValue.js +1 -1
- package/utilities/coerceValue.js.flow +1 -1
- package/{module/utilities/coerceValue.js → utilities/coerceValue.mjs} +1 -1
- package/utilities/concatAST.js +1 -1
- package/utilities/concatAST.js.flow +1 -1
- package/{module/utilities/concatAST.js → utilities/concatAST.mjs} +1 -1
- package/utilities/extendSchema.js +91 -77
- package/utilities/extendSchema.js.flow +93 -68
- package/{module/utilities/extendSchema.js → utilities/extendSchema.mjs} +65 -52
- package/utilities/findBreakingChanges.js +1 -1
- package/utilities/findBreakingChanges.js.flow +1 -1
- package/{module/utilities/findBreakingChanges.js → utilities/findBreakingChanges.mjs} +1 -1
- package/utilities/findDeprecatedUsages.js +1 -1
- package/utilities/findDeprecatedUsages.js.flow +1 -1
- package/{module/utilities/findDeprecatedUsages.js → utilities/findDeprecatedUsages.mjs} +1 -1
- package/utilities/getOperationAST.js +2 -2
- package/utilities/getOperationAST.js.flow +3 -3
- package/{module/utilities/getOperationAST.js → utilities/getOperationAST.mjs} +3 -3
- package/utilities/index.js +30 -0
- package/utilities/index.js.flow +10 -3
- package/{module/utilities/index.js → utilities/index.mjs} +10 -3
- package/utilities/introspectionFromSchema.js +43 -0
- package/utilities/introspectionFromSchema.js.flow +37 -0
- package/utilities/introspectionFromSchema.mjs +31 -0
- package/utilities/introspectionQuery.js +1 -1
- package/utilities/introspectionQuery.js.flow +1 -1
- package/{module/utilities/introspectionQuery.js → utilities/introspectionQuery.mjs} +1 -1
- package/utilities/isValidJSValue.js +1 -1
- package/utilities/isValidJSValue.js.flow +1 -1
- package/{module/utilities/isValidJSValue.js → utilities/isValidJSValue.mjs} +1 -1
- package/utilities/isValidLiteralValue.js +8 -4
- package/utilities/isValidLiteralValue.js.flow +4 -4
- package/{module/utilities/isValidLiteralValue.js → utilities/isValidLiteralValue.mjs} +4 -4
- package/utilities/lexicographicSortSchema.js +243 -0
- package/utilities/lexicographicSortSchema.js.flow +198 -0
- package/utilities/lexicographicSortSchema.mjs +225 -0
- package/utilities/schemaPrinter.js +31 -29
- package/utilities/schemaPrinter.js.flow +28 -15
- package/{module/utilities/schemaPrinter.js → utilities/schemaPrinter.mjs} +21 -20
- package/utilities/separateOperations.js +1 -1
- package/utilities/separateOperations.js.flow +1 -1
- package/{module/utilities/separateOperations.js → utilities/separateOperations.mjs} +1 -1
- package/utilities/typeComparators.js +7 -10
- package/utilities/typeComparators.js.flow +7 -10
- package/{module/utilities/typeComparators.js → utilities/typeComparators.mjs} +7 -10
- package/utilities/typeFromAST.js +7 -11
- package/utilities/typeFromAST.js.flow +3 -3
- package/{module/utilities/typeFromAST.js → utilities/typeFromAST.mjs} +3 -3
- package/utilities/valueFromAST.js +26 -28
- package/utilities/valueFromAST.js.flow +14 -23
- package/{module/utilities/valueFromAST.js → utilities/valueFromAST.mjs} +9 -10
- package/utilities/valueFromASTUntyped.js +17 -22
- package/utilities/valueFromASTUntyped.js.flow +6 -7
- package/{module/utilities/valueFromASTUntyped.js → utilities/valueFromASTUntyped.mjs} +6 -7
- package/validation/ValidationContext.js +184 -0
- package/{module/validation/validate.js.flow → validation/ValidationContext.js.flow} +4 -60
- package/{module/validation/validate.js → validation/ValidationContext.mjs} +15 -57
- package/validation/index.js +12 -7
- package/validation/index.js.flow +6 -2
- package/{module/validation/index.js → validation/index.mjs} +6 -2
- package/validation/rules/ExecutableDefinitions.js +3 -3
- package/validation/rules/ExecutableDefinitions.js.flow +6 -10
- package/{module/validation/rules/ExecutableDefinitions.js → validation/rules/ExecutableDefinitions.mjs} +4 -4
- package/validation/rules/FieldsOnCorrectType.js +1 -1
- package/validation/rules/FieldsOnCorrectType.js.flow +2 -2
- package/{module/validation/rules/FieldsOnCorrectType.js → validation/rules/FieldsOnCorrectType.mjs} +1 -1
- package/validation/rules/FragmentsOnCompositeTypes.js +1 -1
- package/validation/rules/FragmentsOnCompositeTypes.js.flow +2 -2
- package/{module/validation/rules/FragmentsOnCompositeTypes.js → validation/rules/FragmentsOnCompositeTypes.mjs} +1 -1
- package/validation/rules/KnownArgumentNames.js +3 -3
- package/validation/rules/KnownArgumentNames.js.flow +6 -8
- package/{module/validation/rules/KnownArgumentNames.js → validation/rules/KnownArgumentNames.mjs} +4 -4
- package/validation/rules/KnownDirectives.js +23 -27
- package/validation/rules/KnownDirectives.js.flow +3 -3
- package/{module/validation/rules/KnownDirectives.js → validation/rules/KnownDirectives.mjs} +2 -2
- package/validation/rules/KnownFragmentNames.js +1 -1
- package/validation/rules/KnownFragmentNames.js.flow +2 -2
- package/{module/validation/rules/KnownFragmentNames.js → validation/rules/KnownFragmentNames.mjs} +1 -1
- package/validation/rules/KnownTypeNames.js +1 -1
- package/validation/rules/KnownTypeNames.js.flow +2 -2
- package/{module/validation/rules/KnownTypeNames.js → validation/rules/KnownTypeNames.mjs} +1 -1
- package/validation/rules/LoneAnonymousOperation.js +2 -2
- package/validation/rules/LoneAnonymousOperation.js.flow +4 -4
- package/{module/validation/rules/LoneAnonymousOperation.js → validation/rules/LoneAnonymousOperation.mjs} +3 -3
- package/validation/rules/NoFragmentCycles.js +1 -1
- package/validation/rules/NoFragmentCycles.js.flow +2 -2
- package/{module/validation/rules/NoFragmentCycles.js → validation/rules/NoFragmentCycles.mjs} +1 -1
- package/validation/rules/NoUndefinedVariables.js +1 -1
- package/validation/rules/NoUndefinedVariables.js.flow +2 -2
- package/{module/validation/rules/NoUndefinedVariables.js → validation/rules/NoUndefinedVariables.mjs} +1 -1
- package/validation/rules/NoUnusedFragments.js +1 -1
- package/validation/rules/NoUnusedFragments.js.flow +2 -2
- package/{module/validation/rules/NoUnusedFragments.js → validation/rules/NoUnusedFragments.mjs} +1 -1
- package/validation/rules/NoUnusedVariables.js +1 -1
- package/validation/rules/NoUnusedVariables.js.flow +2 -2
- package/{module/validation/rules/NoUnusedVariables.js → validation/rules/NoUnusedVariables.mjs} +1 -1
- package/validation/rules/OverlappingFieldsCanBeMerged.js +4 -8
- package/validation/rules/OverlappingFieldsCanBeMerged.js.flow +3 -3
- package/{module/validation/rules/OverlappingFieldsCanBeMerged.js → validation/rules/OverlappingFieldsCanBeMerged.mjs} +2 -2
- package/validation/rules/PossibleFragmentSpreads.js +1 -1
- package/validation/rules/PossibleFragmentSpreads.js.flow +2 -2
- package/{module/validation/rules/PossibleFragmentSpreads.js → validation/rules/PossibleFragmentSpreads.mjs} +1 -1
- package/validation/rules/ProvidedNonNullArguments.js +1 -1
- package/validation/rules/ProvidedNonNullArguments.js.flow +2 -2
- package/{module/validation/rules/ProvidedNonNullArguments.js → validation/rules/ProvidedNonNullArguments.mjs} +1 -1
- package/validation/rules/ScalarLeafs.js +1 -1
- package/validation/rules/ScalarLeafs.js.flow +2 -2
- package/{module/validation/rules/ScalarLeafs.js → validation/rules/ScalarLeafs.mjs} +1 -1
- package/validation/rules/SingleFieldSubscriptions.js +1 -1
- package/validation/rules/SingleFieldSubscriptions.js.flow +2 -2
- package/{module/validation/rules/SingleFieldSubscriptions.js → validation/rules/SingleFieldSubscriptions.mjs} +1 -1
- package/validation/rules/UniqueArgumentNames.js +1 -1
- package/validation/rules/UniqueArgumentNames.js.flow +2 -2
- package/{module/validation/rules/UniqueArgumentNames.js → validation/rules/UniqueArgumentNames.mjs} +1 -1
- package/validation/rules/UniqueDirectivesPerLocation.js +1 -1
- package/validation/rules/UniqueDirectivesPerLocation.js.flow +2 -2
- package/{module/validation/rules/UniqueDirectivesPerLocation.js → validation/rules/UniqueDirectivesPerLocation.mjs} +1 -1
- package/validation/rules/UniqueFragmentNames.js +1 -1
- package/validation/rules/UniqueFragmentNames.js.flow +2 -2
- package/{module/validation/rules/UniqueFragmentNames.js → validation/rules/UniqueFragmentNames.mjs} +1 -1
- package/validation/rules/UniqueInputFieldNames.js +1 -1
- package/validation/rules/UniqueInputFieldNames.js.flow +2 -2
- package/{module/validation/rules/UniqueInputFieldNames.js → validation/rules/UniqueInputFieldNames.mjs} +1 -1
- package/validation/rules/UniqueOperationNames.js +1 -1
- package/validation/rules/UniqueOperationNames.js.flow +2 -2
- package/{module/validation/rules/UniqueOperationNames.js → validation/rules/UniqueOperationNames.mjs} +1 -1
- package/validation/rules/UniqueVariableNames.js +1 -1
- package/validation/rules/UniqueVariableNames.js.flow +2 -2
- package/{module/validation/rules/UniqueVariableNames.js → validation/rules/UniqueVariableNames.mjs} +1 -1
- package/validation/rules/ValuesOfCorrectType.js +1 -1
- package/validation/rules/ValuesOfCorrectType.js.flow +2 -2
- package/{module/validation/rules/ValuesOfCorrectType.js → validation/rules/ValuesOfCorrectType.mjs} +1 -1
- package/validation/rules/VariablesAreInputTypes.js +1 -1
- package/validation/rules/VariablesAreInputTypes.js.flow +2 -2
- package/{module/validation/rules/VariablesAreInputTypes.js → validation/rules/VariablesAreInputTypes.mjs} +1 -1
- package/validation/rules/VariablesDefaultValueAllowed.js +1 -1
- package/validation/rules/VariablesDefaultValueAllowed.js.flow +2 -2
- package/{module/validation/rules/VariablesDefaultValueAllowed.js → validation/rules/VariablesDefaultValueAllowed.mjs} +1 -1
- package/validation/rules/VariablesInAllowedPosition.js +9 -11
- package/validation/rules/VariablesInAllowedPosition.js.flow +3 -4
- package/{module/validation/rules/VariablesInAllowedPosition.js → validation/rules/VariablesInAllowedPosition.mjs} +2 -3
- package/validation/specifiedRules.js +1 -1
- package/validation/specifiedRules.js.flow +2 -2
- package/{module/validation/specifiedRules.js → validation/specifiedRules.mjs} +1 -1
- package/validation/validate.js +14 -175
- package/validation/validate.js.flow +3 -209
- package/validation/validate.mjs +57 -0
- package/module/error/GraphQLError.js.flow +0 -209
- package/module/error/formatError.js.flow +0 -34
- package/module/error/index.js.flow +0 -16
- package/module/error/locatedError.js.flow +0 -37
- package/module/error/printError.js.flow +0 -82
- package/module/error/syntaxError.js.flow +0 -25
- package/module/execution/execute.js.flow +0 -1375
- package/module/execution/index.js.flow +0 -13
- package/module/execution/values.js.flow +0 -206
- package/module/graphql.js.flow +0 -202
- package/module/index.js.flow +0 -389
- package/module/jsutils/dedent.js +0 -45
- package/module/jsutils/dedent.js.flow +0 -49
- package/module/jsutils/find.js.flow +0 -19
- package/module/jsutils/instanceOf.js +0 -27
- package/module/jsutils/instanceOf.js.flow +0 -44
- package/module/jsutils/invariant.js.flow +0 -15
- package/module/jsutils/isInvalid.js.flow +0 -15
- package/module/jsutils/isNullish.js.flow +0 -15
- package/module/jsutils/keyMap.js.flow +0 -43
- package/module/jsutils/keyValMap.js.flow +0 -38
- package/module/jsutils/orList.js.flow +0 -24
- package/module/jsutils/quotedOrList.js.flow +0 -17
- package/module/jsutils/suggestionList.js.flow +0 -94
- package/module/language/ast.js.flow +0 -594
- package/module/language/blockStringValue.js.flow +0 -64
- package/module/language/directiveLocation.js.flow +0 -39
- package/module/language/index.js.flow +0 -84
- package/module/language/kinds.js +0 -80
- package/module/language/kinds.js.flow +0 -80
- package/module/language/lexer.js.flow +0 -762
- package/module/language/location.js.flow +0 -34
- package/module/language/parser.js.flow +0 -1537
- package/module/language/printer.js.flow +0 -311
- package/module/language/source.js.flow +0 -43
- package/module/language/visitor.js.flow +0 -476
- package/module/subscription/asyncIteratorReject.js.flow +0 -41
- package/module/subscription/index.js.flow +0 -10
- package/module/subscription/mapAsyncIterator.js.flow +0 -78
- package/module/subscription/subscribe.js.flow +0 -288
- package/module/type/definition.js.flow +0 -1225
- package/module/type/directives.js.flow +0 -168
- package/module/type/index.js.flow +0 -156
- package/module/type/introspection.js.flow +0 -482
- package/module/type/scalars.js.flow +0 -158
- package/module/type/schema.js.flow +0 -271
- package/module/type/validate.js.flow +0 -723
- package/module/type/wrappers.js +0 -80
- package/module/type/wrappers.js.flow +0 -91
- package/module/utilities/TypeInfo.js.flow +0 -296
- package/module/utilities/assertValidName.js.flow +0 -56
- package/module/utilities/astFromValue.js.flow +0 -159
- package/module/utilities/buildASTSchema.js.flow +0 -518
- package/module/utilities/buildClientSchema.js.flow +0 -418
- package/module/utilities/coerceValue.js.flow +0 -257
- package/module/utilities/concatAST.js.flow +0 -29
- package/module/utilities/extendSchema.js.flow +0 -374
- package/module/utilities/findBreakingChanges.js.flow +0 -851
- package/module/utilities/findDeprecatedUsages.js.flow +0 -68
- package/module/utilities/getOperationAST.js.flow +0 -40
- package/module/utilities/index.js.flow +0 -111
- package/module/utilities/introspectionQuery.js.flow +0 -271
- package/module/utilities/isValidJSValue.js.flow +0 -22
- package/module/utilities/isValidLiteralValue.js.flow +0 -36
- package/module/utilities/schemaPrinter.js.flow +0 -402
- package/module/utilities/separateOperations.js.flow +0 -100
- package/module/utilities/typeComparators.js.flow +0 -135
- package/module/utilities/typeFromAST.js.flow +0 -56
- package/module/utilities/valueFromAST.js.flow +0 -184
- package/module/utilities/valueFromASTUntyped.js.flow +0 -64
- package/module/validation/index.js.flow +0 -138
- package/module/validation/rules/ExecutableDefinitions.js.flow +0 -52
- package/module/validation/rules/FieldsOnCorrectType.js.flow +0 -144
- package/module/validation/rules/FragmentsOnCompositeTypes.js.flow +0 -74
- package/module/validation/rules/KnownArgumentNames.js.flow +0 -98
- package/module/validation/rules/KnownDirectives.js.flow +0 -116
- package/module/validation/rules/KnownFragmentNames.js.flow +0 -36
- package/module/validation/rules/KnownTypeNames.js.flow +0 -59
- package/module/validation/rules/LoneAnonymousOperation.js.flow +0 -41
- package/module/validation/rules/NoFragmentCycles.js.flow +0 -85
- package/module/validation/rules/NoUndefinedVariables.js.flow +0 -57
- package/module/validation/rules/NoUnusedFragments.js.flow +0 -59
- package/module/validation/rules/NoUnusedVariables.js.flow +0 -62
- package/module/validation/rules/OverlappingFieldsCanBeMerged.js.flow +0 -847
- package/module/validation/rules/PossibleFragmentSpreads.js.flow +0 -94
- package/module/validation/rules/ProvidedNonNullArguments.js.flow +0 -105
- package/module/validation/rules/ScalarLeafs.js.flow +0 -69
- package/module/validation/rules/SingleFieldSubscriptions.js.flow +0 -44
- package/module/validation/rules/UniqueArgumentNames.js.flow +0 -48
- package/module/validation/rules/UniqueDirectivesPerLocation.js.flow +0 -57
- package/module/validation/rules/UniqueFragmentNames.js.flow +0 -42
- package/module/validation/rules/UniqueInputFieldNames.js.flow +0 -53
- package/module/validation/rules/UniqueOperationNames.js.flow +0 -44
- package/module/validation/rules/UniqueVariableNames.js.flow +0 -44
- package/module/validation/rules/ValuesOfCorrectType.js.flow +0 -218
- package/module/validation/rules/VariablesAreInputTypes.js.flow +0 -48
- package/module/validation/rules/VariablesDefaultValueAllowed.js.flow +0 -55
- package/module/validation/rules/VariablesInAllowedPosition.js.flow +0 -83
- package/module/validation/specifiedRules.js.flow +0 -127
- package/type/wrappers.js +0 -89
- package/type/wrappers.js.flow +0 -91
|
@@ -1,518 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2015-present, Facebook, Inc.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @flow
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import keyMap from '../jsutils/keyMap';
|
|
11
|
-
import keyValMap from '../jsutils/keyValMap';
|
|
12
|
-
import type { ObjMap } from '../jsutils/ObjMap';
|
|
13
|
-
import { valueFromAST } from './valueFromAST';
|
|
14
|
-
import blockStringValue from '../language/blockStringValue';
|
|
15
|
-
import { TokenKind } from '../language/lexer';
|
|
16
|
-
import { parse } from '../language/parser';
|
|
17
|
-
import type { Source } from '../language/source';
|
|
18
|
-
import { getDirectiveValues } from '../execution/values';
|
|
19
|
-
|
|
20
|
-
import * as Kind from '../language/kinds';
|
|
21
|
-
|
|
22
|
-
import type {
|
|
23
|
-
DocumentNode,
|
|
24
|
-
TypeNode,
|
|
25
|
-
NamedTypeNode,
|
|
26
|
-
SchemaDefinitionNode,
|
|
27
|
-
TypeDefinitionNode,
|
|
28
|
-
ScalarTypeDefinitionNode,
|
|
29
|
-
ObjectTypeDefinitionNode,
|
|
30
|
-
FieldDefinitionNode,
|
|
31
|
-
InputValueDefinitionNode,
|
|
32
|
-
InterfaceTypeDefinitionNode,
|
|
33
|
-
UnionTypeDefinitionNode,
|
|
34
|
-
EnumTypeDefinitionNode,
|
|
35
|
-
EnumValueDefinitionNode,
|
|
36
|
-
InputObjectTypeDefinitionNode,
|
|
37
|
-
DirectiveDefinitionNode,
|
|
38
|
-
} from '../language/ast';
|
|
39
|
-
|
|
40
|
-
import type { DirectiveLocationEnum } from '../language/directiveLocation';
|
|
41
|
-
|
|
42
|
-
import {
|
|
43
|
-
assertNullableType,
|
|
44
|
-
GraphQLScalarType,
|
|
45
|
-
GraphQLObjectType,
|
|
46
|
-
GraphQLInterfaceType,
|
|
47
|
-
GraphQLUnionType,
|
|
48
|
-
GraphQLEnumType,
|
|
49
|
-
GraphQLInputObjectType,
|
|
50
|
-
} from '../type/definition';
|
|
51
|
-
|
|
52
|
-
import { GraphQLList, GraphQLNonNull } from '../type/wrappers';
|
|
53
|
-
|
|
54
|
-
import {
|
|
55
|
-
GraphQLDirective,
|
|
56
|
-
GraphQLSkipDirective,
|
|
57
|
-
GraphQLIncludeDirective,
|
|
58
|
-
GraphQLDeprecatedDirective,
|
|
59
|
-
} from '../type/directives';
|
|
60
|
-
|
|
61
|
-
import { introspectionTypes } from '../type/introspection';
|
|
62
|
-
|
|
63
|
-
import { specifiedScalarTypes } from '../type/scalars';
|
|
64
|
-
|
|
65
|
-
import { GraphQLSchema } from '../type/schema';
|
|
66
|
-
|
|
67
|
-
import type {
|
|
68
|
-
GraphQLType,
|
|
69
|
-
GraphQLNamedType,
|
|
70
|
-
GraphQLFieldConfig,
|
|
71
|
-
} from '../type/definition';
|
|
72
|
-
|
|
73
|
-
type Options = {|
|
|
74
|
-
/**
|
|
75
|
-
* When building a schema from a GraphQL service's introspection result, it
|
|
76
|
-
* might be safe to assume the schema is valid. Set to true to assume the
|
|
77
|
-
* produced schema is valid.
|
|
78
|
-
*
|
|
79
|
-
* Default: false
|
|
80
|
-
*/
|
|
81
|
-
assumeValid?: boolean,
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Descriptions are defined as preceding string literals, however an older
|
|
85
|
-
* experimental version of the SDL supported preceding comments as
|
|
86
|
-
* descriptions. Set to true to enable this deprecated behavior.
|
|
87
|
-
*
|
|
88
|
-
* Default: false
|
|
89
|
-
*/
|
|
90
|
-
commentDescriptions?: boolean,
|
|
91
|
-
|};
|
|
92
|
-
|
|
93
|
-
function buildWrappedType(
|
|
94
|
-
innerType: GraphQLType,
|
|
95
|
-
inputTypeNode: TypeNode,
|
|
96
|
-
): GraphQLType {
|
|
97
|
-
if (inputTypeNode.kind === Kind.LIST_TYPE) {
|
|
98
|
-
return GraphQLList(buildWrappedType(innerType, inputTypeNode.type));
|
|
99
|
-
}
|
|
100
|
-
if (inputTypeNode.kind === Kind.NON_NULL_TYPE) {
|
|
101
|
-
const wrappedType = buildWrappedType(innerType, inputTypeNode.type);
|
|
102
|
-
return GraphQLNonNull(assertNullableType(wrappedType));
|
|
103
|
-
}
|
|
104
|
-
return innerType;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function getNamedTypeNode(typeNode: TypeNode): NamedTypeNode {
|
|
108
|
-
let namedType = typeNode;
|
|
109
|
-
while (
|
|
110
|
-
namedType.kind === Kind.LIST_TYPE ||
|
|
111
|
-
namedType.kind === Kind.NON_NULL_TYPE
|
|
112
|
-
) {
|
|
113
|
-
namedType = namedType.type;
|
|
114
|
-
}
|
|
115
|
-
return namedType;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* This takes the ast of a schema document produced by the parse function in
|
|
120
|
-
* src/language/parser.js.
|
|
121
|
-
*
|
|
122
|
-
* If no schema definition is provided, then it will look for types named Query
|
|
123
|
-
* and Mutation.
|
|
124
|
-
*
|
|
125
|
-
* Given that AST it constructs a GraphQLSchema. The resulting schema
|
|
126
|
-
* has no resolve methods, so execution will use default resolvers.
|
|
127
|
-
*
|
|
128
|
-
* Accepts options as a second argument:
|
|
129
|
-
*
|
|
130
|
-
* - commentDescriptions:
|
|
131
|
-
* Provide true to use preceding comments as the description.
|
|
132
|
-
*
|
|
133
|
-
*/
|
|
134
|
-
export function buildASTSchema(
|
|
135
|
-
ast: DocumentNode,
|
|
136
|
-
options?: Options,
|
|
137
|
-
): GraphQLSchema {
|
|
138
|
-
if (!ast || ast.kind !== Kind.DOCUMENT) {
|
|
139
|
-
throw new Error('Must provide a document ast.');
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
let schemaDef: ?SchemaDefinitionNode;
|
|
143
|
-
|
|
144
|
-
const typeDefs: Array<TypeDefinitionNode> = [];
|
|
145
|
-
const nodeMap: ObjMap<TypeDefinitionNode> = Object.create(null);
|
|
146
|
-
const directiveDefs: Array<DirectiveDefinitionNode> = [];
|
|
147
|
-
for (let i = 0; i < ast.definitions.length; i++) {
|
|
148
|
-
const d = ast.definitions[i];
|
|
149
|
-
switch (d.kind) {
|
|
150
|
-
case Kind.SCHEMA_DEFINITION:
|
|
151
|
-
if (schemaDef) {
|
|
152
|
-
throw new Error('Must provide only one schema definition.');
|
|
153
|
-
}
|
|
154
|
-
schemaDef = d;
|
|
155
|
-
break;
|
|
156
|
-
case Kind.SCALAR_TYPE_DEFINITION:
|
|
157
|
-
case Kind.OBJECT_TYPE_DEFINITION:
|
|
158
|
-
case Kind.INTERFACE_TYPE_DEFINITION:
|
|
159
|
-
case Kind.ENUM_TYPE_DEFINITION:
|
|
160
|
-
case Kind.UNION_TYPE_DEFINITION:
|
|
161
|
-
case Kind.INPUT_OBJECT_TYPE_DEFINITION:
|
|
162
|
-
const typeName = d.name.value;
|
|
163
|
-
if (nodeMap[typeName]) {
|
|
164
|
-
throw new Error(`Type "${typeName}" was defined more than once.`);
|
|
165
|
-
}
|
|
166
|
-
typeDefs.push(d);
|
|
167
|
-
nodeMap[typeName] = d;
|
|
168
|
-
break;
|
|
169
|
-
case Kind.DIRECTIVE_DEFINITION:
|
|
170
|
-
directiveDefs.push(d);
|
|
171
|
-
break;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const operationTypes = schemaDef
|
|
176
|
-
? getOperationTypes(schemaDef)
|
|
177
|
-
: {
|
|
178
|
-
query: nodeMap.Query ? 'Query' : null,
|
|
179
|
-
mutation: nodeMap.Mutation ? 'Mutation' : null,
|
|
180
|
-
subscription: nodeMap.Subscription ? 'Subscription' : null,
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
const definitionBuilder = new ASTDefinitionBuilder(
|
|
184
|
-
nodeMap,
|
|
185
|
-
options,
|
|
186
|
-
typeName => {
|
|
187
|
-
throw new Error(`Type "${typeName}" not found in document.`);
|
|
188
|
-
},
|
|
189
|
-
);
|
|
190
|
-
|
|
191
|
-
const types = typeDefs.map(def =>
|
|
192
|
-
definitionBuilder.buildType(def.name.value),
|
|
193
|
-
);
|
|
194
|
-
|
|
195
|
-
const directives = directiveDefs.map(def =>
|
|
196
|
-
definitionBuilder.buildDirective(def),
|
|
197
|
-
);
|
|
198
|
-
|
|
199
|
-
// If specified directives were not explicitly declared, add them.
|
|
200
|
-
if (!directives.some(directive => directive.name === 'skip')) {
|
|
201
|
-
directives.push(GraphQLSkipDirective);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
if (!directives.some(directive => directive.name === 'include')) {
|
|
205
|
-
directives.push(GraphQLIncludeDirective);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
if (!directives.some(directive => directive.name === 'deprecated')) {
|
|
209
|
-
directives.push(GraphQLDeprecatedDirective);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// Note: While this could make early assertions to get the correctly
|
|
213
|
-
// typed values below, that would throw immediately while type system
|
|
214
|
-
// validation with validateSchema() will produce more actionable results.
|
|
215
|
-
return new GraphQLSchema({
|
|
216
|
-
query: operationTypes.query
|
|
217
|
-
? (definitionBuilder.buildType(operationTypes.query): any)
|
|
218
|
-
: null,
|
|
219
|
-
mutation: operationTypes.mutation
|
|
220
|
-
? (definitionBuilder.buildType(operationTypes.mutation): any)
|
|
221
|
-
: null,
|
|
222
|
-
subscription: operationTypes.subscription
|
|
223
|
-
? (definitionBuilder.buildType(operationTypes.subscription): any)
|
|
224
|
-
: null,
|
|
225
|
-
types,
|
|
226
|
-
directives,
|
|
227
|
-
astNode: schemaDef,
|
|
228
|
-
assumeValid: options && options.assumeValid,
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
function getOperationTypes(schema: SchemaDefinitionNode) {
|
|
232
|
-
const opTypes = {};
|
|
233
|
-
schema.operationTypes.forEach(operationType => {
|
|
234
|
-
const typeName = operationType.type.name.value;
|
|
235
|
-
const operation = operationType.operation;
|
|
236
|
-
if (opTypes[operation]) {
|
|
237
|
-
throw new Error(`Must provide only one ${operation} type in schema.`);
|
|
238
|
-
}
|
|
239
|
-
if (!nodeMap[typeName]) {
|
|
240
|
-
throw new Error(
|
|
241
|
-
`Specified ${operation} type "${typeName}" not found in document.`,
|
|
242
|
-
);
|
|
243
|
-
}
|
|
244
|
-
opTypes[operation] = typeName;
|
|
245
|
-
});
|
|
246
|
-
return opTypes;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
type TypeDefinitionsMap = ObjMap<TypeDefinitionNode>;
|
|
251
|
-
type TypeResolver = (
|
|
252
|
-
typeName: string,
|
|
253
|
-
node?: ?NamedTypeNode,
|
|
254
|
-
) => GraphQLNamedType;
|
|
255
|
-
|
|
256
|
-
export class ASTDefinitionBuilder {
|
|
257
|
-
_typeDefinitionsMap: TypeDefinitionsMap;
|
|
258
|
-
_options: ?Options;
|
|
259
|
-
_resolveType: TypeResolver;
|
|
260
|
-
_cache: ObjMap<GraphQLNamedType>;
|
|
261
|
-
|
|
262
|
-
constructor(
|
|
263
|
-
typeDefinitionsMap: TypeDefinitionsMap,
|
|
264
|
-
options: ?Options,
|
|
265
|
-
resolveType: TypeResolver,
|
|
266
|
-
) {
|
|
267
|
-
this._typeDefinitionsMap = typeDefinitionsMap;
|
|
268
|
-
this._options = options;
|
|
269
|
-
this._resolveType = resolveType;
|
|
270
|
-
// Initialize to the GraphQL built in scalars and introspection types.
|
|
271
|
-
this._cache = keyMap(
|
|
272
|
-
specifiedScalarTypes.concat(introspectionTypes),
|
|
273
|
-
type => type.name,
|
|
274
|
-
);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
_buildType(typeName: string, typeNode?: ?NamedTypeNode): GraphQLNamedType {
|
|
278
|
-
if (!this._cache[typeName]) {
|
|
279
|
-
const defNode = this._typeDefinitionsMap[typeName];
|
|
280
|
-
if (defNode) {
|
|
281
|
-
this._cache[typeName] = this._makeSchemaDef(defNode);
|
|
282
|
-
} else {
|
|
283
|
-
this._cache[typeName] = this._resolveType(typeName, typeNode);
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
return this._cache[typeName];
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
buildType(ref: string | NamedTypeNode): GraphQLNamedType {
|
|
290
|
-
if (typeof ref === 'string') {
|
|
291
|
-
return this._buildType(ref);
|
|
292
|
-
}
|
|
293
|
-
return this._buildType(ref.name.value, ref);
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
_buildWrappedType(typeNode: TypeNode): GraphQLType {
|
|
297
|
-
const typeDef = this.buildType(getNamedTypeNode(typeNode));
|
|
298
|
-
return buildWrappedType(typeDef, typeNode);
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
buildDirective(directiveNode: DirectiveDefinitionNode): GraphQLDirective {
|
|
302
|
-
return new GraphQLDirective({
|
|
303
|
-
name: directiveNode.name.value,
|
|
304
|
-
description: getDescription(directiveNode, this._options),
|
|
305
|
-
locations: directiveNode.locations.map(
|
|
306
|
-
node => ((node.value: any): DirectiveLocationEnum),
|
|
307
|
-
),
|
|
308
|
-
args:
|
|
309
|
-
directiveNode.arguments &&
|
|
310
|
-
this._makeInputValues(directiveNode.arguments),
|
|
311
|
-
astNode: directiveNode,
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
buildField(field: FieldDefinitionNode): GraphQLFieldConfig<*, *> {
|
|
316
|
-
return {
|
|
317
|
-
// Note: While this could make assertions to get the correctly typed
|
|
318
|
-
// value, that would throw immediately while type system validation
|
|
319
|
-
// with validateSchema() will produce more actionable results.
|
|
320
|
-
type: (this._buildWrappedType(field.type): any),
|
|
321
|
-
description: getDescription(field, this._options),
|
|
322
|
-
args: field.arguments && this._makeInputValues(field.arguments),
|
|
323
|
-
deprecationReason: getDeprecationReason(field),
|
|
324
|
-
astNode: field,
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
_makeSchemaDef(def: TypeDefinitionNode): GraphQLNamedType {
|
|
329
|
-
switch (def.kind) {
|
|
330
|
-
case Kind.OBJECT_TYPE_DEFINITION:
|
|
331
|
-
return this._makeTypeDef(def);
|
|
332
|
-
case Kind.INTERFACE_TYPE_DEFINITION:
|
|
333
|
-
return this._makeInterfaceDef(def);
|
|
334
|
-
case Kind.ENUM_TYPE_DEFINITION:
|
|
335
|
-
return this._makeEnumDef(def);
|
|
336
|
-
case Kind.UNION_TYPE_DEFINITION:
|
|
337
|
-
return this._makeUnionDef(def);
|
|
338
|
-
case Kind.SCALAR_TYPE_DEFINITION:
|
|
339
|
-
return this._makeScalarDef(def);
|
|
340
|
-
case Kind.INPUT_OBJECT_TYPE_DEFINITION:
|
|
341
|
-
return this._makeInputObjectDef(def);
|
|
342
|
-
default:
|
|
343
|
-
throw new Error(`Type kind "${def.kind}" not supported.`);
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
_makeTypeDef(def: ObjectTypeDefinitionNode) {
|
|
348
|
-
const typeName = def.name.value;
|
|
349
|
-
return new GraphQLObjectType({
|
|
350
|
-
name: typeName,
|
|
351
|
-
description: getDescription(def, this._options),
|
|
352
|
-
fields: () => this._makeFieldDefMap(def),
|
|
353
|
-
interfaces: () => this._makeImplementedInterfaces(def),
|
|
354
|
-
astNode: def,
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
_makeFieldDefMap(
|
|
359
|
-
def: ObjectTypeDefinitionNode | InterfaceTypeDefinitionNode,
|
|
360
|
-
) {
|
|
361
|
-
return def.fields
|
|
362
|
-
? keyValMap(
|
|
363
|
-
def.fields,
|
|
364
|
-
field => field.name.value,
|
|
365
|
-
field => this.buildField(field),
|
|
366
|
-
)
|
|
367
|
-
: {};
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
_makeImplementedInterfaces(def: ObjectTypeDefinitionNode) {
|
|
371
|
-
return (
|
|
372
|
-
def.interfaces &&
|
|
373
|
-
// Note: While this could make early assertions to get the correctly
|
|
374
|
-
// typed values, that would throw immediately while type system
|
|
375
|
-
// validation with validateSchema() will produce more actionable results.
|
|
376
|
-
def.interfaces.map(iface => (this.buildType(iface): any))
|
|
377
|
-
);
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
_makeInputValues(values: $ReadOnlyArray<InputValueDefinitionNode>) {
|
|
381
|
-
return keyValMap(
|
|
382
|
-
values,
|
|
383
|
-
value => value.name.value,
|
|
384
|
-
value => {
|
|
385
|
-
// Note: While this could make assertions to get the correctly typed
|
|
386
|
-
// value, that would throw immediately while type system validation
|
|
387
|
-
// with validateSchema() will produce more actionable results.
|
|
388
|
-
const type: any = this._buildWrappedType(value.type);
|
|
389
|
-
return {
|
|
390
|
-
type,
|
|
391
|
-
description: getDescription(value, this._options),
|
|
392
|
-
defaultValue: valueFromAST(value.defaultValue, type),
|
|
393
|
-
astNode: value,
|
|
394
|
-
};
|
|
395
|
-
},
|
|
396
|
-
);
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
_makeInterfaceDef(def: InterfaceTypeDefinitionNode) {
|
|
400
|
-
return new GraphQLInterfaceType({
|
|
401
|
-
name: def.name.value,
|
|
402
|
-
description: getDescription(def, this._options),
|
|
403
|
-
fields: () => this._makeFieldDefMap(def),
|
|
404
|
-
astNode: def,
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
_makeEnumDef(def: EnumTypeDefinitionNode) {
|
|
409
|
-
return new GraphQLEnumType({
|
|
410
|
-
name: def.name.value,
|
|
411
|
-
description: getDescription(def, this._options),
|
|
412
|
-
values: def.values
|
|
413
|
-
? keyValMap(
|
|
414
|
-
def.values,
|
|
415
|
-
enumValue => enumValue.name.value,
|
|
416
|
-
enumValue => ({
|
|
417
|
-
description: getDescription(enumValue, this._options),
|
|
418
|
-
deprecationReason: getDeprecationReason(enumValue),
|
|
419
|
-
astNode: enumValue,
|
|
420
|
-
}),
|
|
421
|
-
)
|
|
422
|
-
: {},
|
|
423
|
-
astNode: def,
|
|
424
|
-
});
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
_makeUnionDef(def: UnionTypeDefinitionNode) {
|
|
428
|
-
return new GraphQLUnionType({
|
|
429
|
-
name: def.name.value,
|
|
430
|
-
description: getDescription(def, this._options),
|
|
431
|
-
// Note: While this could make assertions to get the correctly typed
|
|
432
|
-
// values below, that would throw immediately while type system
|
|
433
|
-
// validation with validateSchema() will produce more actionable results.
|
|
434
|
-
types: def.types ? def.types.map(t => (this.buildType(t): any)) : [],
|
|
435
|
-
astNode: def,
|
|
436
|
-
});
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
_makeScalarDef(def: ScalarTypeDefinitionNode) {
|
|
440
|
-
return new GraphQLScalarType({
|
|
441
|
-
name: def.name.value,
|
|
442
|
-
description: getDescription(def, this._options),
|
|
443
|
-
astNode: def,
|
|
444
|
-
serialize: value => value,
|
|
445
|
-
});
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
_makeInputObjectDef(def: InputObjectTypeDefinitionNode) {
|
|
449
|
-
return new GraphQLInputObjectType({
|
|
450
|
-
name: def.name.value,
|
|
451
|
-
description: getDescription(def, this._options),
|
|
452
|
-
fields: () => (def.fields ? this._makeInputValues(def.fields) : {}),
|
|
453
|
-
astNode: def,
|
|
454
|
-
});
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
/**
|
|
459
|
-
* Given a field or enum value node, returns the string value for the
|
|
460
|
-
* deprecation reason.
|
|
461
|
-
*/
|
|
462
|
-
function getDeprecationReason(
|
|
463
|
-
node: EnumValueDefinitionNode | FieldDefinitionNode,
|
|
464
|
-
): ?string {
|
|
465
|
-
const deprecated = getDirectiveValues(GraphQLDeprecatedDirective, node);
|
|
466
|
-
return deprecated && (deprecated.reason: any);
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
/**
|
|
470
|
-
* Given an ast node, returns its string description.
|
|
471
|
-
*
|
|
472
|
-
* Accepts options as a second argument:
|
|
473
|
-
*
|
|
474
|
-
* - commentDescriptions:
|
|
475
|
-
* Provide true to use preceding comments as the description.
|
|
476
|
-
*
|
|
477
|
-
*/
|
|
478
|
-
function getDescription(node, options: ?Options): void | string {
|
|
479
|
-
if (node.description) {
|
|
480
|
-
return node.description.value;
|
|
481
|
-
}
|
|
482
|
-
if (options && options.commentDescriptions) {
|
|
483
|
-
const rawValue = getLeadingCommentBlock(node);
|
|
484
|
-
if (rawValue !== undefined) {
|
|
485
|
-
return blockStringValue('\n' + rawValue);
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
function getLeadingCommentBlock(node): void | string {
|
|
491
|
-
const loc = node.loc;
|
|
492
|
-
if (!loc) {
|
|
493
|
-
return;
|
|
494
|
-
}
|
|
495
|
-
const comments = [];
|
|
496
|
-
let token = loc.startToken.prev;
|
|
497
|
-
while (
|
|
498
|
-
token &&
|
|
499
|
-
token.kind === TokenKind.COMMENT &&
|
|
500
|
-
token.next &&
|
|
501
|
-
token.prev &&
|
|
502
|
-
token.line + 1 === token.next.line &&
|
|
503
|
-
token.line !== token.prev.line
|
|
504
|
-
) {
|
|
505
|
-
const value = String(token.value);
|
|
506
|
-
comments.push(value);
|
|
507
|
-
token = token.prev;
|
|
508
|
-
}
|
|
509
|
-
return comments.reverse().join('\n');
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
/**
|
|
513
|
-
* A helper function to build a GraphQLSchema directly from a source
|
|
514
|
-
* document.
|
|
515
|
-
*/
|
|
516
|
-
export function buildSchema(source: string | Source): GraphQLSchema {
|
|
517
|
-
return buildASTSchema(parse(source));
|
|
518
|
-
}
|