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
package/module/type/wrappers.js
DELETED
|
@@ -1,80 +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
|
-
*
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { assertType, assertNullableType } from './definition';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* List Type Wrapper
|
|
14
|
-
*
|
|
15
|
-
* A list is a wrapping type which points to another type.
|
|
16
|
-
* Lists are often created within the context of defining the fields of
|
|
17
|
-
* an object type.
|
|
18
|
-
*
|
|
19
|
-
* Example:
|
|
20
|
-
*
|
|
21
|
-
* const PersonType = new GraphQLObjectType({
|
|
22
|
-
* name: 'Person',
|
|
23
|
-
* fields: () => ({
|
|
24
|
-
* parents: { type: GraphQLList(PersonType) },
|
|
25
|
-
* children: { type: GraphQLList(PersonType) },
|
|
26
|
-
* })
|
|
27
|
-
* })
|
|
28
|
-
*
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
// eslint-disable-next-line no-redeclare
|
|
32
|
-
export function GraphQLList(ofType) {
|
|
33
|
-
if (this instanceof GraphQLList) {
|
|
34
|
-
this.ofType = assertType(ofType);
|
|
35
|
-
} else {
|
|
36
|
-
return new GraphQLList(ofType);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// Also provide toJSON and inspect aliases for toString.
|
|
41
|
-
var listProto = GraphQLList.prototype;
|
|
42
|
-
listProto.toString = listProto.toJSON = listProto.inspect = function toString() {
|
|
43
|
-
return '[' + String(this.ofType) + ']';
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Non-Null Type Wrapper
|
|
48
|
-
*
|
|
49
|
-
* A non-null is a wrapping type which points to another type.
|
|
50
|
-
* Non-null types enforce that their values are never null and can ensure
|
|
51
|
-
* an error is raised if this ever occurs during a request. It is useful for
|
|
52
|
-
* fields which you can make a strong guarantee on non-nullability, for example
|
|
53
|
-
* usually the id field of a database row will never be null.
|
|
54
|
-
*
|
|
55
|
-
* Example:
|
|
56
|
-
*
|
|
57
|
-
* const RowType = new GraphQLObjectType({
|
|
58
|
-
* name: 'Row',
|
|
59
|
-
* fields: () => ({
|
|
60
|
-
* id: { type: GraphQLNonNull(GraphQLString) },
|
|
61
|
-
* })
|
|
62
|
-
* })
|
|
63
|
-
*
|
|
64
|
-
* Note: the enforcement of non-nullability occurs within the executor.
|
|
65
|
-
*/
|
|
66
|
-
|
|
67
|
-
// eslint-disable-next-line no-redeclare
|
|
68
|
-
export function GraphQLNonNull(ofType) {
|
|
69
|
-
if (this instanceof GraphQLNonNull) {
|
|
70
|
-
this.ofType = assertNullableType(ofType);
|
|
71
|
-
} else {
|
|
72
|
-
return new GraphQLNonNull(ofType);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Also provide toJSON and inspect aliases for toString.
|
|
77
|
-
var nonNullProto = GraphQLNonNull.prototype;
|
|
78
|
-
nonNullProto.toString = nonNullProto.toJSON = nonNullProto.inspect = function toString() {
|
|
79
|
-
return String(this.ofType) + '!';
|
|
80
|
-
};
|
|
@@ -1,91 +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 { assertType, assertNullableType } from './definition';
|
|
11
|
-
import type { GraphQLType, GraphQLNullableType } from './definition';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* List Type Wrapper
|
|
15
|
-
*
|
|
16
|
-
* A list is a wrapping type which points to another type.
|
|
17
|
-
* Lists are often created within the context of defining the fields of
|
|
18
|
-
* an object type.
|
|
19
|
-
*
|
|
20
|
-
* Example:
|
|
21
|
-
*
|
|
22
|
-
* const PersonType = new GraphQLObjectType({
|
|
23
|
-
* name: 'Person',
|
|
24
|
-
* fields: () => ({
|
|
25
|
-
* parents: { type: GraphQLList(PersonType) },
|
|
26
|
-
* children: { type: GraphQLList(PersonType) },
|
|
27
|
-
* })
|
|
28
|
-
* })
|
|
29
|
-
*
|
|
30
|
-
*/
|
|
31
|
-
declare class GraphQLList<+T: GraphQLType> {
|
|
32
|
-
+ofType: T;
|
|
33
|
-
static <T>(ofType: T): GraphQLList<T>;
|
|
34
|
-
// Note: constructors cannot be used for covariant types. Drop the "new".
|
|
35
|
-
constructor(ofType: any): void;
|
|
36
|
-
}
|
|
37
|
-
// eslint-disable-next-line no-redeclare
|
|
38
|
-
export function GraphQLList(ofType) {
|
|
39
|
-
if (this instanceof GraphQLList) {
|
|
40
|
-
this.ofType = assertType(ofType);
|
|
41
|
-
} else {
|
|
42
|
-
return new GraphQLList(ofType);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Also provide toJSON and inspect aliases for toString.
|
|
47
|
-
const listProto: any = GraphQLList.prototype;
|
|
48
|
-
listProto.toString = listProto.toJSON = listProto.inspect = function toString() {
|
|
49
|
-
return '[' + String(this.ofType) + ']';
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Non-Null Type Wrapper
|
|
54
|
-
*
|
|
55
|
-
* A non-null is a wrapping type which points to another type.
|
|
56
|
-
* Non-null types enforce that their values are never null and can ensure
|
|
57
|
-
* an error is raised if this ever occurs during a request. It is useful for
|
|
58
|
-
* fields which you can make a strong guarantee on non-nullability, for example
|
|
59
|
-
* usually the id field of a database row will never be null.
|
|
60
|
-
*
|
|
61
|
-
* Example:
|
|
62
|
-
*
|
|
63
|
-
* const RowType = new GraphQLObjectType({
|
|
64
|
-
* name: 'Row',
|
|
65
|
-
* fields: () => ({
|
|
66
|
-
* id: { type: GraphQLNonNull(GraphQLString) },
|
|
67
|
-
* })
|
|
68
|
-
* })
|
|
69
|
-
*
|
|
70
|
-
* Note: the enforcement of non-nullability occurs within the executor.
|
|
71
|
-
*/
|
|
72
|
-
declare class GraphQLNonNull<+T: GraphQLNullableType> {
|
|
73
|
-
+ofType: T;
|
|
74
|
-
static <T>(ofType: T): GraphQLNonNull<T>;
|
|
75
|
-
// Note: constructors cannot be used for covariant types. Drop the "new".
|
|
76
|
-
constructor(ofType: any): void;
|
|
77
|
-
}
|
|
78
|
-
// eslint-disable-next-line no-redeclare
|
|
79
|
-
export function GraphQLNonNull(ofType) {
|
|
80
|
-
if (this instanceof GraphQLNonNull) {
|
|
81
|
-
this.ofType = assertNullableType(ofType);
|
|
82
|
-
} else {
|
|
83
|
-
return new GraphQLNonNull(ofType);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// Also provide toJSON and inspect aliases for toString.
|
|
88
|
-
const nonNullProto: any = GraphQLNonNull.prototype;
|
|
89
|
-
nonNullProto.toString = nonNullProto.toJSON = nonNullProto.inspect = function toString() {
|
|
90
|
-
return String(this.ofType) + '!';
|
|
91
|
-
};
|
|
@@ -1,296 +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 * as Kind from '../language/kinds';
|
|
11
|
-
import {
|
|
12
|
-
isObjectType,
|
|
13
|
-
isInterfaceType,
|
|
14
|
-
isEnumType,
|
|
15
|
-
isInputObjectType,
|
|
16
|
-
isListType,
|
|
17
|
-
isCompositeType,
|
|
18
|
-
isInputType,
|
|
19
|
-
isOutputType,
|
|
20
|
-
getNullableType,
|
|
21
|
-
getNamedType,
|
|
22
|
-
} from '../type/definition';
|
|
23
|
-
import type {
|
|
24
|
-
GraphQLType,
|
|
25
|
-
GraphQLInputType,
|
|
26
|
-
GraphQLOutputType,
|
|
27
|
-
GraphQLCompositeType,
|
|
28
|
-
GraphQLField,
|
|
29
|
-
GraphQLArgument,
|
|
30
|
-
GraphQLEnumValue,
|
|
31
|
-
} from '../type/definition';
|
|
32
|
-
import type { GraphQLDirective } from '../type/directives';
|
|
33
|
-
import {
|
|
34
|
-
SchemaMetaFieldDef,
|
|
35
|
-
TypeMetaFieldDef,
|
|
36
|
-
TypeNameMetaFieldDef,
|
|
37
|
-
} from '../type/introspection';
|
|
38
|
-
import type { GraphQLSchema } from '../type/schema';
|
|
39
|
-
import type { ASTNode, FieldNode } from '../language/ast';
|
|
40
|
-
import { typeFromAST } from './typeFromAST';
|
|
41
|
-
import find from '../jsutils/find';
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* TypeInfo is a utility class which, given a GraphQL schema, can keep track
|
|
45
|
-
* of the current field and type definitions at any point in a GraphQL document
|
|
46
|
-
* AST during a recursive descent by calling `enter(node)` and `leave(node)`.
|
|
47
|
-
*/
|
|
48
|
-
export class TypeInfo {
|
|
49
|
-
_schema: GraphQLSchema;
|
|
50
|
-
_typeStack: Array<?GraphQLOutputType>;
|
|
51
|
-
_parentTypeStack: Array<?GraphQLCompositeType>;
|
|
52
|
-
_inputTypeStack: Array<?GraphQLInputType>;
|
|
53
|
-
_fieldDefStack: Array<?GraphQLField<*, *>>;
|
|
54
|
-
_directive: ?GraphQLDirective;
|
|
55
|
-
_argument: ?GraphQLArgument;
|
|
56
|
-
_enumValue: ?GraphQLEnumValue;
|
|
57
|
-
_getFieldDef: typeof getFieldDef;
|
|
58
|
-
|
|
59
|
-
constructor(
|
|
60
|
-
schema: GraphQLSchema,
|
|
61
|
-
// NOTE: this experimental optional second parameter is only needed in order
|
|
62
|
-
// to support non-spec-compliant codebases. You should never need to use it.
|
|
63
|
-
// It may disappear in the future.
|
|
64
|
-
getFieldDefFn?: typeof getFieldDef,
|
|
65
|
-
// Initial type may be provided in rare cases to facilitate traversals
|
|
66
|
-
// beginning somewhere other than documents.
|
|
67
|
-
initialType?: GraphQLType,
|
|
68
|
-
): void {
|
|
69
|
-
this._schema = schema;
|
|
70
|
-
this._typeStack = [];
|
|
71
|
-
this._parentTypeStack = [];
|
|
72
|
-
this._inputTypeStack = [];
|
|
73
|
-
this._fieldDefStack = [];
|
|
74
|
-
this._directive = null;
|
|
75
|
-
this._argument = null;
|
|
76
|
-
this._enumValue = null;
|
|
77
|
-
this._getFieldDef = getFieldDefFn || getFieldDef;
|
|
78
|
-
if (initialType) {
|
|
79
|
-
if (isInputType(initialType)) {
|
|
80
|
-
this._inputTypeStack.push(initialType);
|
|
81
|
-
}
|
|
82
|
-
if (isCompositeType(initialType)) {
|
|
83
|
-
this._parentTypeStack.push(initialType);
|
|
84
|
-
}
|
|
85
|
-
if (isOutputType(initialType)) {
|
|
86
|
-
this._typeStack.push(initialType);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
getType(): ?GraphQLOutputType {
|
|
92
|
-
if (this._typeStack.length > 0) {
|
|
93
|
-
return this._typeStack[this._typeStack.length - 1];
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
getParentType(): ?GraphQLCompositeType {
|
|
98
|
-
if (this._parentTypeStack.length > 0) {
|
|
99
|
-
return this._parentTypeStack[this._parentTypeStack.length - 1];
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
getInputType(): ?GraphQLInputType {
|
|
104
|
-
if (this._inputTypeStack.length > 0) {
|
|
105
|
-
return this._inputTypeStack[this._inputTypeStack.length - 1];
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
getParentInputType(): ?GraphQLInputType {
|
|
110
|
-
if (this._inputTypeStack.length > 1) {
|
|
111
|
-
return this._inputTypeStack[this._inputTypeStack.length - 2];
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
getFieldDef(): ?GraphQLField<*, *> {
|
|
116
|
-
if (this._fieldDefStack.length > 0) {
|
|
117
|
-
return this._fieldDefStack[this._fieldDefStack.length - 1];
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
getDirective(): ?GraphQLDirective {
|
|
122
|
-
return this._directive;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
getArgument(): ?GraphQLArgument {
|
|
126
|
-
return this._argument;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
getEnumValue(): ?GraphQLEnumValue {
|
|
130
|
-
return this._enumValue;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// Flow does not yet handle this case.
|
|
134
|
-
enter(node: any /* ASTNode */) {
|
|
135
|
-
const schema = this._schema;
|
|
136
|
-
// Note: many of the types below are explicitly typed as "mixed" to drop
|
|
137
|
-
// any assumptions of a valid schema to ensure runtime types are properly
|
|
138
|
-
// checked before continuing since TypeInfo is used as part of validation
|
|
139
|
-
// which occurs before guarantees of schema and document validity.
|
|
140
|
-
switch (node.kind) {
|
|
141
|
-
case Kind.SELECTION_SET:
|
|
142
|
-
const namedType: mixed = getNamedType(this.getType());
|
|
143
|
-
this._parentTypeStack.push(
|
|
144
|
-
isCompositeType(namedType) ? namedType : undefined,
|
|
145
|
-
);
|
|
146
|
-
break;
|
|
147
|
-
case Kind.FIELD:
|
|
148
|
-
const parentType = this.getParentType();
|
|
149
|
-
let fieldDef;
|
|
150
|
-
let fieldType: mixed;
|
|
151
|
-
if (parentType) {
|
|
152
|
-
fieldDef = this._getFieldDef(schema, parentType, node);
|
|
153
|
-
if (fieldDef) {
|
|
154
|
-
fieldType = fieldDef.type;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
this._fieldDefStack.push(fieldDef);
|
|
158
|
-
this._typeStack.push(isOutputType(fieldType) ? fieldType : undefined);
|
|
159
|
-
break;
|
|
160
|
-
case Kind.DIRECTIVE:
|
|
161
|
-
this._directive = schema.getDirective(node.name.value);
|
|
162
|
-
break;
|
|
163
|
-
case Kind.OPERATION_DEFINITION:
|
|
164
|
-
let type: mixed;
|
|
165
|
-
if (node.operation === 'query') {
|
|
166
|
-
type = schema.getQueryType();
|
|
167
|
-
} else if (node.operation === 'mutation') {
|
|
168
|
-
type = schema.getMutationType();
|
|
169
|
-
} else if (node.operation === 'subscription') {
|
|
170
|
-
type = schema.getSubscriptionType();
|
|
171
|
-
}
|
|
172
|
-
this._typeStack.push(isObjectType(type) ? type : undefined);
|
|
173
|
-
break;
|
|
174
|
-
case Kind.INLINE_FRAGMENT:
|
|
175
|
-
case Kind.FRAGMENT_DEFINITION:
|
|
176
|
-
const typeConditionAST = node.typeCondition;
|
|
177
|
-
const outputType: mixed = typeConditionAST
|
|
178
|
-
? typeFromAST(schema, typeConditionAST)
|
|
179
|
-
: getNamedType(this.getType());
|
|
180
|
-
this._typeStack.push(isOutputType(outputType) ? outputType : undefined);
|
|
181
|
-
break;
|
|
182
|
-
case Kind.VARIABLE_DEFINITION:
|
|
183
|
-
const inputType: mixed = typeFromAST(schema, node.type);
|
|
184
|
-
this._inputTypeStack.push(
|
|
185
|
-
isInputType(inputType) ? inputType : undefined,
|
|
186
|
-
);
|
|
187
|
-
break;
|
|
188
|
-
case Kind.ARGUMENT:
|
|
189
|
-
let argDef;
|
|
190
|
-
let argType: mixed;
|
|
191
|
-
const fieldOrDirective = this.getDirective() || this.getFieldDef();
|
|
192
|
-
if (fieldOrDirective) {
|
|
193
|
-
argDef = find(
|
|
194
|
-
fieldOrDirective.args,
|
|
195
|
-
arg => arg.name === node.name.value,
|
|
196
|
-
);
|
|
197
|
-
if (argDef) {
|
|
198
|
-
argType = argDef.type;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
this._argument = argDef;
|
|
202
|
-
this._inputTypeStack.push(isInputType(argType) ? argType : undefined);
|
|
203
|
-
break;
|
|
204
|
-
case Kind.LIST:
|
|
205
|
-
const listType: mixed = getNullableType(this.getInputType());
|
|
206
|
-
const itemType: mixed = isListType(listType)
|
|
207
|
-
? listType.ofType
|
|
208
|
-
: listType;
|
|
209
|
-
this._inputTypeStack.push(isInputType(itemType) ? itemType : undefined);
|
|
210
|
-
break;
|
|
211
|
-
case Kind.OBJECT_FIELD:
|
|
212
|
-
const objectType: mixed = getNamedType(this.getInputType());
|
|
213
|
-
let inputFieldType: mixed;
|
|
214
|
-
if (isInputObjectType(objectType)) {
|
|
215
|
-
const inputField = objectType.getFields()[node.name.value];
|
|
216
|
-
if (inputField) {
|
|
217
|
-
inputFieldType = inputField.type;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
this._inputTypeStack.push(
|
|
221
|
-
isInputType(inputFieldType) ? inputFieldType : undefined,
|
|
222
|
-
);
|
|
223
|
-
break;
|
|
224
|
-
case Kind.ENUM:
|
|
225
|
-
const enumType: mixed = getNamedType(this.getInputType());
|
|
226
|
-
let enumValue;
|
|
227
|
-
if (isEnumType(enumType)) {
|
|
228
|
-
enumValue = enumType.getValue(node.value);
|
|
229
|
-
}
|
|
230
|
-
this._enumValue = enumValue;
|
|
231
|
-
break;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
leave(node: ASTNode) {
|
|
236
|
-
switch (node.kind) {
|
|
237
|
-
case Kind.SELECTION_SET:
|
|
238
|
-
this._parentTypeStack.pop();
|
|
239
|
-
break;
|
|
240
|
-
case Kind.FIELD:
|
|
241
|
-
this._fieldDefStack.pop();
|
|
242
|
-
this._typeStack.pop();
|
|
243
|
-
break;
|
|
244
|
-
case Kind.DIRECTIVE:
|
|
245
|
-
this._directive = null;
|
|
246
|
-
break;
|
|
247
|
-
case Kind.OPERATION_DEFINITION:
|
|
248
|
-
case Kind.INLINE_FRAGMENT:
|
|
249
|
-
case Kind.FRAGMENT_DEFINITION:
|
|
250
|
-
this._typeStack.pop();
|
|
251
|
-
break;
|
|
252
|
-
case Kind.VARIABLE_DEFINITION:
|
|
253
|
-
this._inputTypeStack.pop();
|
|
254
|
-
break;
|
|
255
|
-
case Kind.ARGUMENT:
|
|
256
|
-
this._argument = null;
|
|
257
|
-
this._inputTypeStack.pop();
|
|
258
|
-
break;
|
|
259
|
-
case Kind.LIST:
|
|
260
|
-
case Kind.OBJECT_FIELD:
|
|
261
|
-
this._inputTypeStack.pop();
|
|
262
|
-
break;
|
|
263
|
-
case Kind.ENUM:
|
|
264
|
-
this._enumValue = null;
|
|
265
|
-
break;
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* Not exactly the same as the executor's definition of getFieldDef, in this
|
|
272
|
-
* statically evaluated environment we do not always have an Object type,
|
|
273
|
-
* and need to handle Interface and Union types.
|
|
274
|
-
*/
|
|
275
|
-
function getFieldDef(
|
|
276
|
-
schema: GraphQLSchema,
|
|
277
|
-
parentType: GraphQLType,
|
|
278
|
-
fieldNode: FieldNode,
|
|
279
|
-
): ?GraphQLField<*, *> {
|
|
280
|
-
const name = fieldNode.name.value;
|
|
281
|
-
if (
|
|
282
|
-
name === SchemaMetaFieldDef.name &&
|
|
283
|
-
schema.getQueryType() === parentType
|
|
284
|
-
) {
|
|
285
|
-
return SchemaMetaFieldDef;
|
|
286
|
-
}
|
|
287
|
-
if (name === TypeMetaFieldDef.name && schema.getQueryType() === parentType) {
|
|
288
|
-
return TypeMetaFieldDef;
|
|
289
|
-
}
|
|
290
|
-
if (name === TypeNameMetaFieldDef.name && isCompositeType(parentType)) {
|
|
291
|
-
return TypeNameMetaFieldDef;
|
|
292
|
-
}
|
|
293
|
-
if (isObjectType(parentType) || isInterfaceType(parentType)) {
|
|
294
|
-
return parentType.getFields()[name];
|
|
295
|
-
}
|
|
296
|
-
}
|
|
@@ -1,56 +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 { GraphQLError } from '../error/GraphQLError';
|
|
11
|
-
import type { ASTNode } from '../language/ast';
|
|
12
|
-
import invariant from '../jsutils/invariant';
|
|
13
|
-
|
|
14
|
-
const NAME_RX = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Upholds the spec rules about naming.
|
|
18
|
-
*/
|
|
19
|
-
export function assertValidName(name: string): string {
|
|
20
|
-
const error = isValidNameError(name);
|
|
21
|
-
if (error) {
|
|
22
|
-
throw error;
|
|
23
|
-
}
|
|
24
|
-
return name;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Returns an Error if a name is invalid.
|
|
29
|
-
*/
|
|
30
|
-
export function isValidNameError(
|
|
31
|
-
name: string,
|
|
32
|
-
node?: ASTNode | void,
|
|
33
|
-
): GraphQLError | void {
|
|
34
|
-
invariant(typeof name === 'string', 'Expected string');
|
|
35
|
-
if (
|
|
36
|
-
name.length > 1 &&
|
|
37
|
-
name[0] === '_' &&
|
|
38
|
-
name[1] === '_' &&
|
|
39
|
-
// Note: this special case is not part of the spec and exists only to
|
|
40
|
-
// support legacy server configurations. Do not rely on this special case
|
|
41
|
-
// as it may be removed at any time.
|
|
42
|
-
name !== '__configs__'
|
|
43
|
-
) {
|
|
44
|
-
return new GraphQLError(
|
|
45
|
-
`Name "${name}" must not begin with "__", which is reserved by ` +
|
|
46
|
-
'GraphQL introspection.',
|
|
47
|
-
node,
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
if (!NAME_RX.test(name)) {
|
|
51
|
-
return new GraphQLError(
|
|
52
|
-
`Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but "${name}" does not.`,
|
|
53
|
-
node,
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
@@ -1,159 +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 { forEach, isCollection } from 'iterall';
|
|
11
|
-
|
|
12
|
-
import isNullish from '../jsutils/isNullish';
|
|
13
|
-
import isInvalid from '../jsutils/isInvalid';
|
|
14
|
-
import type {
|
|
15
|
-
ValueNode,
|
|
16
|
-
IntValueNode,
|
|
17
|
-
FloatValueNode,
|
|
18
|
-
StringValueNode,
|
|
19
|
-
BooleanValueNode,
|
|
20
|
-
NullValueNode,
|
|
21
|
-
EnumValueNode,
|
|
22
|
-
ListValueNode,
|
|
23
|
-
ObjectValueNode,
|
|
24
|
-
} from '../language/ast';
|
|
25
|
-
import * as Kind from '../language/kinds';
|
|
26
|
-
import type { GraphQLInputType } from '../type/definition';
|
|
27
|
-
import {
|
|
28
|
-
isScalarType,
|
|
29
|
-
isEnumType,
|
|
30
|
-
isInputObjectType,
|
|
31
|
-
isListType,
|
|
32
|
-
isNonNullType,
|
|
33
|
-
} from '../type/definition';
|
|
34
|
-
import { GraphQLID } from '../type/scalars';
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Produces a GraphQL Value AST given a JavaScript value.
|
|
38
|
-
*
|
|
39
|
-
* A GraphQL type must be provided, which will be used to interpret different
|
|
40
|
-
* JavaScript values.
|
|
41
|
-
*
|
|
42
|
-
* | JSON Value | GraphQL Value |
|
|
43
|
-
* | ------------- | -------------------- |
|
|
44
|
-
* | Object | Input Object |
|
|
45
|
-
* | Array | List |
|
|
46
|
-
* | Boolean | Boolean |
|
|
47
|
-
* | String | String / Enum Value |
|
|
48
|
-
* | Number | Int / Float |
|
|
49
|
-
* | Mixed | Enum Value |
|
|
50
|
-
* | null | NullValue |
|
|
51
|
-
*
|
|
52
|
-
*/
|
|
53
|
-
export function astFromValue(value: mixed, type: GraphQLInputType): ?ValueNode {
|
|
54
|
-
// Ensure flow knows that we treat function params as const.
|
|
55
|
-
const _value = value;
|
|
56
|
-
|
|
57
|
-
if (isNonNullType(type)) {
|
|
58
|
-
const astValue = astFromValue(_value, type.ofType);
|
|
59
|
-
if (astValue && astValue.kind === Kind.NULL) {
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
return astValue;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// only explicit null, not undefined, NaN
|
|
66
|
-
if (_value === null) {
|
|
67
|
-
return ({ kind: Kind.NULL }: NullValueNode);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// undefined, NaN
|
|
71
|
-
if (isInvalid(_value)) {
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Convert JavaScript array to GraphQL list. If the GraphQLType is a list, but
|
|
76
|
-
// the value is not an array, convert the value using the list's item type.
|
|
77
|
-
if (isListType(type)) {
|
|
78
|
-
const itemType = type.ofType;
|
|
79
|
-
if (isCollection(_value)) {
|
|
80
|
-
const valuesNodes = [];
|
|
81
|
-
forEach((_value: any), item => {
|
|
82
|
-
const itemNode = astFromValue(item, itemType);
|
|
83
|
-
if (itemNode) {
|
|
84
|
-
valuesNodes.push(itemNode);
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
return ({ kind: Kind.LIST, values: valuesNodes }: ListValueNode);
|
|
88
|
-
}
|
|
89
|
-
return astFromValue(_value, itemType);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Populate the fields of the input object by creating ASTs from each value
|
|
93
|
-
// in the JavaScript object according to the fields in the input type.
|
|
94
|
-
if (isInputObjectType(type)) {
|
|
95
|
-
if (_value === null || typeof _value !== 'object') {
|
|
96
|
-
return null;
|
|
97
|
-
}
|
|
98
|
-
const fields = type.getFields();
|
|
99
|
-
const fieldNodes = [];
|
|
100
|
-
Object.keys(fields).forEach(fieldName => {
|
|
101
|
-
const fieldType = fields[fieldName].type;
|
|
102
|
-
const fieldValue = astFromValue(_value[fieldName], fieldType);
|
|
103
|
-
if (fieldValue) {
|
|
104
|
-
fieldNodes.push({
|
|
105
|
-
kind: Kind.OBJECT_FIELD,
|
|
106
|
-
name: { kind: Kind.NAME, value: fieldName },
|
|
107
|
-
value: fieldValue,
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
return ({ kind: Kind.OBJECT, fields: fieldNodes }: ObjectValueNode);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (isScalarType(type) || isEnumType(type)) {
|
|
115
|
-
// Since value is an internally represented value, it must be serialized
|
|
116
|
-
// to an externally represented value before converting into an AST.
|
|
117
|
-
const serialized = type.serialize(_value);
|
|
118
|
-
if (isNullish(serialized)) {
|
|
119
|
-
return null;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// Others serialize based on their corresponding JavaScript scalar types.
|
|
123
|
-
if (typeof serialized === 'boolean') {
|
|
124
|
-
return ({ kind: Kind.BOOLEAN, value: serialized }: BooleanValueNode);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// JavaScript numbers can be Int or Float values.
|
|
128
|
-
if (typeof serialized === 'number') {
|
|
129
|
-
const stringNum = String(serialized);
|
|
130
|
-
return /^[0-9]+$/.test(stringNum)
|
|
131
|
-
? ({ kind: Kind.INT, value: stringNum }: IntValueNode)
|
|
132
|
-
: ({ kind: Kind.FLOAT, value: stringNum }: FloatValueNode);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (typeof serialized === 'string') {
|
|
136
|
-
// Enum types use Enum literals.
|
|
137
|
-
if (isEnumType(type)) {
|
|
138
|
-
return ({ kind: Kind.ENUM, value: serialized }: EnumValueNode);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// ID types can use Int literals.
|
|
142
|
-
if (type === GraphQLID && /^[0-9]+$/.test(serialized)) {
|
|
143
|
-
return ({ kind: Kind.INT, value: serialized }: IntValueNode);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// Use JSON stringify, which uses the same string encoding as GraphQL,
|
|
147
|
-
// then remove the quotes.
|
|
148
|
-
return ({
|
|
149
|
-
kind: Kind.STRING,
|
|
150
|
-
value: JSON.stringify(serialized).slice(1, -1),
|
|
151
|
-
}: StringValueNode);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
throw new TypeError('Cannot convert value to AST: ' + String(serialized));
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/* istanbul ignore next */
|
|
158
|
-
throw new Error(`Unknown type: ${(type: empty)}.`);
|
|
159
|
-
}
|