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
|
@@ -6,7 +6,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
6
6
|
* This source code is licensed under the MIT license found in the
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
9
|
+
* strict
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import { isObjectType, isInterfaceType, isUnionType, isEnumType, isInputObjectType, isNonNullType, isNamedType, isInputType, isOutputType } from './definition';
|
|
@@ -18,6 +18,7 @@ import { isSchema } from './schema';
|
|
|
18
18
|
|
|
19
19
|
import find from '../jsutils/find';
|
|
20
20
|
import invariant from '../jsutils/invariant';
|
|
21
|
+
import objectValues from '../jsutils/objectValues';
|
|
21
22
|
import { GraphQLError } from '../error/GraphQLError';
|
|
22
23
|
|
|
23
24
|
import { isValidNameError } from '../utilities/assertValidName';
|
|
@@ -155,26 +156,31 @@ function validateDirectives(context) {
|
|
|
155
156
|
}
|
|
156
157
|
|
|
157
158
|
function validateName(context, node) {
|
|
159
|
+
// If a schema explicitly allows some legacy name which is no longer valid,
|
|
160
|
+
// allow it to be assumed valid.
|
|
161
|
+
if (context.schema.__allowedLegacyNames && context.schema.__allowedLegacyNames.indexOf(node.name) !== -1) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
158
164
|
// Ensure names are valid, however introspection types opt out.
|
|
159
165
|
var error = isValidNameError(node.name, node.astNode || undefined);
|
|
160
|
-
if (error
|
|
166
|
+
if (error) {
|
|
161
167
|
context.addError(error);
|
|
162
168
|
}
|
|
163
169
|
}
|
|
164
170
|
|
|
165
171
|
function validateTypes(context) {
|
|
166
172
|
var typeMap = context.schema.getTypeMap();
|
|
167
|
-
|
|
168
|
-
var type = typeMap[typeName];
|
|
169
|
-
|
|
173
|
+
objectValues(typeMap).forEach(function (type) {
|
|
170
174
|
// Ensure all provided types are in fact GraphQL type.
|
|
171
175
|
if (!isNamedType(type)) {
|
|
172
176
|
context.reportError('Expected GraphQL named type but got: ' + String(type) + '.', type && type.astNode);
|
|
173
177
|
return;
|
|
174
178
|
}
|
|
175
179
|
|
|
176
|
-
// Ensure
|
|
177
|
-
|
|
180
|
+
// Ensure it is named correctly (excluding introspection types).
|
|
181
|
+
if (!isIntrospectionType(type)) {
|
|
182
|
+
validateName(context, type);
|
|
183
|
+
}
|
|
178
184
|
|
|
179
185
|
if (isObjectType(type)) {
|
|
180
186
|
// Ensure fields are valid
|
|
@@ -199,30 +205,27 @@ function validateTypes(context) {
|
|
|
199
205
|
}
|
|
200
206
|
|
|
201
207
|
function validateFields(context, type) {
|
|
202
|
-
var
|
|
203
|
-
var fieldNames = Object.keys(fieldMap);
|
|
208
|
+
var fields = objectValues(type.getFields());
|
|
204
209
|
|
|
205
210
|
// Objects and Interfaces both must define one or more fields.
|
|
206
|
-
if (
|
|
211
|
+
if (fields.length === 0) {
|
|
207
212
|
context.reportError('Type ' + type.name + ' must define one or more fields.', getAllObjectOrInterfaceNodes(type));
|
|
208
213
|
}
|
|
209
214
|
|
|
210
|
-
|
|
211
|
-
var field = fieldMap[fieldName];
|
|
212
|
-
|
|
215
|
+
fields.forEach(function (field) {
|
|
213
216
|
// Ensure they are named correctly.
|
|
214
217
|
validateName(context, field);
|
|
215
218
|
|
|
216
219
|
// Ensure they were defined at most once.
|
|
217
|
-
var fieldNodes = getAllFieldNodes(type,
|
|
220
|
+
var fieldNodes = getAllFieldNodes(type, field.name);
|
|
218
221
|
if (fieldNodes.length > 1) {
|
|
219
|
-
context.reportError('Field ' + type.name + '.' +
|
|
222
|
+
context.reportError('Field ' + type.name + '.' + field.name + ' can only be defined once.', fieldNodes);
|
|
220
223
|
return; // continue loop
|
|
221
224
|
}
|
|
222
225
|
|
|
223
226
|
// Ensure the type is an output type
|
|
224
227
|
if (!isOutputType(field.type)) {
|
|
225
|
-
context.reportError('The type of ' + type.name + '.' +
|
|
228
|
+
context.reportError('The type of ' + type.name + '.' + field.name + ' must be Output Type ' + ('but got: ' + String(field.type) + '.'), getFieldTypeNode(type, field.name));
|
|
226
229
|
}
|
|
227
230
|
|
|
228
231
|
// Ensure the arguments are valid
|
|
@@ -235,13 +238,13 @@ function validateFields(context, type) {
|
|
|
235
238
|
|
|
236
239
|
// Ensure they are unique per field.
|
|
237
240
|
if (argNames[argName]) {
|
|
238
|
-
context.reportError('Field argument ' + type.name + '.' +
|
|
241
|
+
context.reportError('Field argument ' + type.name + '.' + field.name + '(' + argName + ':) can only ' + 'be defined once.', getAllFieldArgNodes(type, field.name, argName));
|
|
239
242
|
}
|
|
240
243
|
argNames[argName] = true;
|
|
241
244
|
|
|
242
245
|
// Ensure the type is an input type
|
|
243
246
|
if (!isInputType(arg.type)) {
|
|
244
|
-
context.reportError('The type of ' + type.name + '.' +
|
|
247
|
+
context.reportError('The type of ' + type.name + '.' + field.name + '(' + argName + ':) must be Input ' + ('Type but got: ' + String(arg.type) + '.'), getFieldArgTypeNode(type, field.name, argName));
|
|
245
248
|
}
|
|
246
249
|
});
|
|
247
250
|
});
|
|
@@ -250,6 +253,11 @@ function validateFields(context, type) {
|
|
|
250
253
|
function validateObjectInterfaces(context, object) {
|
|
251
254
|
var implementedTypeNames = Object.create(null);
|
|
252
255
|
object.getInterfaces().forEach(function (iface) {
|
|
256
|
+
if (!isInterfaceType(iface)) {
|
|
257
|
+
context.reportError('Type ' + String(object) + ' must only implement Interface types, ' + ('it cannot implement ' + String(iface) + '.'), getImplementsInterfaceNode(object, iface));
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
|
|
253
261
|
if (implementedTypeNames[iface.name]) {
|
|
254
262
|
context.reportError('Type ' + object.name + ' can only implement ' + iface.name + ' once.', getAllImplementsInterfaceNodes(object, iface));
|
|
255
263
|
return; // continue loop
|
|
@@ -260,11 +268,6 @@ function validateObjectInterfaces(context, object) {
|
|
|
260
268
|
}
|
|
261
269
|
|
|
262
270
|
function validateObjectImplementsInterface(context, object, iface) {
|
|
263
|
-
if (!isInterfaceType(iface)) {
|
|
264
|
-
context.reportError('Type ' + String(object) + ' must only implement Interface types, ' + ('it cannot implement ' + String(iface) + '.'), getImplementsInterfaceNode(object, iface));
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
271
|
var objectFieldMap = object.getFields();
|
|
269
272
|
var ifaceFieldMap = iface.getFields();
|
|
270
273
|
|
|
@@ -368,17 +371,14 @@ function validateEnumValues(context, enumType) {
|
|
|
368
371
|
}
|
|
369
372
|
|
|
370
373
|
function validateInputFields(context, inputObj) {
|
|
371
|
-
var
|
|
372
|
-
var fieldNames = Object.keys(fieldMap);
|
|
374
|
+
var fields = objectValues(inputObj.getFields());
|
|
373
375
|
|
|
374
|
-
if (
|
|
376
|
+
if (fields.length === 0) {
|
|
375
377
|
context.reportError('Input Object type ' + inputObj.name + ' must define one or more fields.', inputObj.astNode);
|
|
376
378
|
}
|
|
377
379
|
|
|
378
380
|
// Ensure the arguments are valid
|
|
379
|
-
|
|
380
|
-
var field = fieldMap[fieldName];
|
|
381
|
-
|
|
381
|
+
fields.forEach(function (field) {
|
|
382
382
|
// Ensure they are named correctly.
|
|
383
383
|
validateName(context, field);
|
|
384
384
|
|
|
@@ -386,7 +386,7 @@ function validateInputFields(context, inputObj) {
|
|
|
386
386
|
|
|
387
387
|
// Ensure the type is an input type
|
|
388
388
|
if (!isInputType(field.type)) {
|
|
389
|
-
context.reportError('The type of ' + inputObj.name + '.' +
|
|
389
|
+
context.reportError('The type of ' + inputObj.name + '.' + field.name + ' must be Input Type ' + ('but got: ' + String(field.type) + '.'), field.astNode && field.astNode.type);
|
|
390
390
|
}
|
|
391
391
|
});
|
|
392
392
|
}
|
package/utilities/TypeInfo.js
CHANGED
|
@@ -7,8 +7,6 @@ exports.TypeInfo = undefined;
|
|
|
7
7
|
|
|
8
8
|
var _kinds = require('../language/kinds');
|
|
9
9
|
|
|
10
|
-
var Kind = _interopRequireWildcard(_kinds);
|
|
11
|
-
|
|
12
10
|
var _definition = require('../type/definition');
|
|
13
11
|
|
|
14
12
|
var _introspection = require('../type/introspection');
|
|
@@ -21,15 +19,13 @@ var _find2 = _interopRequireDefault(_find);
|
|
|
21
19
|
|
|
22
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
21
|
|
|
24
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
|
25
|
-
|
|
26
22
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /**
|
|
27
23
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
28
24
|
*
|
|
29
25
|
* This source code is licensed under the MIT license found in the
|
|
30
26
|
* LICENSE file in the root directory of this source tree.
|
|
31
27
|
*
|
|
32
|
-
*
|
|
28
|
+
* strict
|
|
33
29
|
*/
|
|
34
30
|
|
|
35
31
|
/**
|
|
@@ -120,11 +116,11 @@ var TypeInfo = exports.TypeInfo = function () {
|
|
|
120
116
|
// checked before continuing since TypeInfo is used as part of validation
|
|
121
117
|
// which occurs before guarantees of schema and document validity.
|
|
122
118
|
switch (node.kind) {
|
|
123
|
-
case Kind.SELECTION_SET:
|
|
119
|
+
case _kinds.Kind.SELECTION_SET:
|
|
124
120
|
var namedType = (0, _definition.getNamedType)(this.getType());
|
|
125
121
|
this._parentTypeStack.push((0, _definition.isCompositeType)(namedType) ? namedType : undefined);
|
|
126
122
|
break;
|
|
127
|
-
case Kind.FIELD:
|
|
123
|
+
case _kinds.Kind.FIELD:
|
|
128
124
|
var parentType = this.getParentType();
|
|
129
125
|
var fieldDef = void 0;
|
|
130
126
|
var fieldType = void 0;
|
|
@@ -137,10 +133,10 @@ var TypeInfo = exports.TypeInfo = function () {
|
|
|
137
133
|
this._fieldDefStack.push(fieldDef);
|
|
138
134
|
this._typeStack.push((0, _definition.isOutputType)(fieldType) ? fieldType : undefined);
|
|
139
135
|
break;
|
|
140
|
-
case Kind.DIRECTIVE:
|
|
136
|
+
case _kinds.Kind.DIRECTIVE:
|
|
141
137
|
this._directive = schema.getDirective(node.name.value);
|
|
142
138
|
break;
|
|
143
|
-
case Kind.OPERATION_DEFINITION:
|
|
139
|
+
case _kinds.Kind.OPERATION_DEFINITION:
|
|
144
140
|
var type = void 0;
|
|
145
141
|
if (node.operation === 'query') {
|
|
146
142
|
type = schema.getQueryType();
|
|
@@ -151,17 +147,17 @@ var TypeInfo = exports.TypeInfo = function () {
|
|
|
151
147
|
}
|
|
152
148
|
this._typeStack.push((0, _definition.isObjectType)(type) ? type : undefined);
|
|
153
149
|
break;
|
|
154
|
-
case Kind.INLINE_FRAGMENT:
|
|
155
|
-
case Kind.FRAGMENT_DEFINITION:
|
|
150
|
+
case _kinds.Kind.INLINE_FRAGMENT:
|
|
151
|
+
case _kinds.Kind.FRAGMENT_DEFINITION:
|
|
156
152
|
var typeConditionAST = node.typeCondition;
|
|
157
153
|
var outputType = typeConditionAST ? (0, _typeFromAST.typeFromAST)(schema, typeConditionAST) : (0, _definition.getNamedType)(this.getType());
|
|
158
154
|
this._typeStack.push((0, _definition.isOutputType)(outputType) ? outputType : undefined);
|
|
159
155
|
break;
|
|
160
|
-
case Kind.VARIABLE_DEFINITION:
|
|
156
|
+
case _kinds.Kind.VARIABLE_DEFINITION:
|
|
161
157
|
var inputType = (0, _typeFromAST.typeFromAST)(schema, node.type);
|
|
162
158
|
this._inputTypeStack.push((0, _definition.isInputType)(inputType) ? inputType : undefined);
|
|
163
159
|
break;
|
|
164
|
-
case Kind.ARGUMENT:
|
|
160
|
+
case _kinds.Kind.ARGUMENT:
|
|
165
161
|
var argDef = void 0;
|
|
166
162
|
var argType = void 0;
|
|
167
163
|
var fieldOrDirective = this.getDirective() || this.getFieldDef();
|
|
@@ -176,12 +172,12 @@ var TypeInfo = exports.TypeInfo = function () {
|
|
|
176
172
|
this._argument = argDef;
|
|
177
173
|
this._inputTypeStack.push((0, _definition.isInputType)(argType) ? argType : undefined);
|
|
178
174
|
break;
|
|
179
|
-
case Kind.LIST:
|
|
175
|
+
case _kinds.Kind.LIST:
|
|
180
176
|
var listType = (0, _definition.getNullableType)(this.getInputType());
|
|
181
177
|
var itemType = (0, _definition.isListType)(listType) ? listType.ofType : listType;
|
|
182
178
|
this._inputTypeStack.push((0, _definition.isInputType)(itemType) ? itemType : undefined);
|
|
183
179
|
break;
|
|
184
|
-
case Kind.OBJECT_FIELD:
|
|
180
|
+
case _kinds.Kind.OBJECT_FIELD:
|
|
185
181
|
var objectType = (0, _definition.getNamedType)(this.getInputType());
|
|
186
182
|
var inputFieldType = void 0;
|
|
187
183
|
if ((0, _definition.isInputObjectType)(objectType)) {
|
|
@@ -192,7 +188,7 @@ var TypeInfo = exports.TypeInfo = function () {
|
|
|
192
188
|
}
|
|
193
189
|
this._inputTypeStack.push((0, _definition.isInputType)(inputFieldType) ? inputFieldType : undefined);
|
|
194
190
|
break;
|
|
195
|
-
case Kind.ENUM:
|
|
191
|
+
case _kinds.Kind.ENUM:
|
|
196
192
|
var enumType = (0, _definition.getNamedType)(this.getInputType());
|
|
197
193
|
var enumValue = void 0;
|
|
198
194
|
if ((0, _definition.isEnumType)(enumType)) {
|
|
@@ -205,33 +201,33 @@ var TypeInfo = exports.TypeInfo = function () {
|
|
|
205
201
|
|
|
206
202
|
TypeInfo.prototype.leave = function leave(node) {
|
|
207
203
|
switch (node.kind) {
|
|
208
|
-
case Kind.SELECTION_SET:
|
|
204
|
+
case _kinds.Kind.SELECTION_SET:
|
|
209
205
|
this._parentTypeStack.pop();
|
|
210
206
|
break;
|
|
211
|
-
case Kind.FIELD:
|
|
207
|
+
case _kinds.Kind.FIELD:
|
|
212
208
|
this._fieldDefStack.pop();
|
|
213
209
|
this._typeStack.pop();
|
|
214
210
|
break;
|
|
215
|
-
case Kind.DIRECTIVE:
|
|
211
|
+
case _kinds.Kind.DIRECTIVE:
|
|
216
212
|
this._directive = null;
|
|
217
213
|
break;
|
|
218
|
-
case Kind.OPERATION_DEFINITION:
|
|
219
|
-
case Kind.INLINE_FRAGMENT:
|
|
220
|
-
case Kind.FRAGMENT_DEFINITION:
|
|
214
|
+
case _kinds.Kind.OPERATION_DEFINITION:
|
|
215
|
+
case _kinds.Kind.INLINE_FRAGMENT:
|
|
216
|
+
case _kinds.Kind.FRAGMENT_DEFINITION:
|
|
221
217
|
this._typeStack.pop();
|
|
222
218
|
break;
|
|
223
|
-
case Kind.VARIABLE_DEFINITION:
|
|
219
|
+
case _kinds.Kind.VARIABLE_DEFINITION:
|
|
224
220
|
this._inputTypeStack.pop();
|
|
225
221
|
break;
|
|
226
|
-
case Kind.ARGUMENT:
|
|
222
|
+
case _kinds.Kind.ARGUMENT:
|
|
227
223
|
this._argument = null;
|
|
228
224
|
this._inputTypeStack.pop();
|
|
229
225
|
break;
|
|
230
|
-
case Kind.LIST:
|
|
231
|
-
case Kind.OBJECT_FIELD:
|
|
226
|
+
case _kinds.Kind.LIST:
|
|
227
|
+
case _kinds.Kind.OBJECT_FIELD:
|
|
232
228
|
this._inputTypeStack.pop();
|
|
233
229
|
break;
|
|
234
|
-
case Kind.ENUM:
|
|
230
|
+
case _kinds.Kind.ENUM:
|
|
235
231
|
this._enumValue = null;
|
|
236
232
|
break;
|
|
237
233
|
}
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @flow
|
|
7
|
+
* @flow strict
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import
|
|
10
|
+
import { Kind } from '../language/kinds';
|
|
11
11
|
import {
|
|
12
12
|
isObjectType,
|
|
13
13
|
isInterfaceType,
|
|
@@ -6,10 +6,10 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
6
6
|
* This source code is licensed under the MIT license found in the
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
9
|
+
* strict
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import
|
|
12
|
+
import { Kind } from '../language/kinds';
|
|
13
13
|
import { isObjectType, isInterfaceType, isEnumType, isInputObjectType, isListType, isCompositeType, isInputType, isOutputType, getNullableType, getNamedType } from '../type/definition';
|
|
14
14
|
|
|
15
15
|
import { SchemaMetaFieldDef, TypeMetaFieldDef, TypeNameMetaFieldDef } from '../type/introspection';
|
|
@@ -20,7 +20,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
20
20
|
* This source code is licensed under the MIT license found in the
|
|
21
21
|
* LICENSE file in the root directory of this source tree.
|
|
22
22
|
*
|
|
23
|
-
*
|
|
23
|
+
* strict
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
26
|
var NAME_RX = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
@@ -41,11 +41,7 @@ function assertValidName(name) {
|
|
|
41
41
|
*/
|
|
42
42
|
function isValidNameError(name, node) {
|
|
43
43
|
!(typeof name === 'string') ? (0, _invariant2.default)(0, 'Expected string') : void 0;
|
|
44
|
-
if (name.length > 1 && name[0] === '_' && name[1] === '_'
|
|
45
|
-
// Note: this special case is not part of the spec and exists only to
|
|
46
|
-
// support legacy server configurations. Do not rely on this special case
|
|
47
|
-
// as it may be removed at any time.
|
|
48
|
-
name !== '__configs__') {
|
|
44
|
+
if (name.length > 1 && name[0] === '_' && name[1] === '_') {
|
|
49
45
|
return new _GraphQLError.GraphQLError('Name "' + name + '" must not begin with "__", which is reserved by ' + 'GraphQL introspection.', node);
|
|
50
46
|
}
|
|
51
47
|
if (!NAME_RX.test(name)) {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @flow
|
|
7
|
+
* @flow strict
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { GraphQLError } from '../error/GraphQLError';
|
|
@@ -32,15 +32,7 @@ export function isValidNameError(
|
|
|
32
32
|
node?: ASTNode | void,
|
|
33
33
|
): GraphQLError | void {
|
|
34
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
|
-
) {
|
|
35
|
+
if (name.length > 1 && name[0] === '_' && name[1] === '_') {
|
|
44
36
|
return new GraphQLError(
|
|
45
37
|
`Name "${name}" must not begin with "__", which is reserved by ` +
|
|
46
38
|
'GraphQL introspection.',
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* strict
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { GraphQLError } from '../error/GraphQLError';
|
|
@@ -29,11 +29,7 @@ export function assertValidName(name) {
|
|
|
29
29
|
*/
|
|
30
30
|
export function isValidNameError(name, node) {
|
|
31
31
|
!(typeof name === 'string') ? invariant(0, 'Expected string') : void 0;
|
|
32
|
-
if (name.length > 1 && name[0] === '_' && name[1] === '_'
|
|
33
|
-
// Note: this special case is not part of the spec and exists only to
|
|
34
|
-
// support legacy server configurations. Do not rely on this special case
|
|
35
|
-
// as it may be removed at any time.
|
|
36
|
-
name !== '__configs__') {
|
|
32
|
+
if (name.length > 1 && name[0] === '_' && name[1] === '_') {
|
|
37
33
|
return new GraphQLError('Name "' + name + '" must not begin with "__", which is reserved by ' + 'GraphQL introspection.', node);
|
|
38
34
|
}
|
|
39
35
|
if (!NAME_RX.test(name)) {
|
|
@@ -10,7 +10,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
|
10
10
|
* This source code is licensed under the MIT license found in the
|
|
11
11
|
* LICENSE file in the root directory of this source tree.
|
|
12
12
|
*
|
|
13
|
-
*
|
|
13
|
+
* strict
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
exports.astFromValue = astFromValue;
|
|
@@ -25,16 +25,16 @@ var _isInvalid = require('../jsutils/isInvalid');
|
|
|
25
25
|
|
|
26
26
|
var _isInvalid2 = _interopRequireDefault(_isInvalid);
|
|
27
27
|
|
|
28
|
-
var
|
|
28
|
+
var _objectValues = require('../jsutils/objectValues');
|
|
29
|
+
|
|
30
|
+
var _objectValues2 = _interopRequireDefault(_objectValues);
|
|
29
31
|
|
|
30
|
-
var
|
|
32
|
+
var _kinds = require('../language/kinds');
|
|
31
33
|
|
|
32
34
|
var _definition = require('../type/definition');
|
|
33
35
|
|
|
34
36
|
var _scalars = require('../type/scalars');
|
|
35
37
|
|
|
36
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
|
37
|
-
|
|
38
38
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
39
39
|
|
|
40
40
|
/**
|
|
@@ -55,24 +55,21 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
55
55
|
*
|
|
56
56
|
*/
|
|
57
57
|
function astFromValue(value, type) {
|
|
58
|
-
// Ensure flow knows that we treat function params as const.
|
|
59
|
-
var _value = value;
|
|
60
|
-
|
|
61
58
|
if ((0, _definition.isNonNullType)(type)) {
|
|
62
|
-
var astValue = astFromValue(
|
|
63
|
-
if (astValue && astValue.kind === Kind.NULL) {
|
|
59
|
+
var astValue = astFromValue(value, type.ofType);
|
|
60
|
+
if (astValue && astValue.kind === _kinds.Kind.NULL) {
|
|
64
61
|
return null;
|
|
65
62
|
}
|
|
66
63
|
return astValue;
|
|
67
64
|
}
|
|
68
65
|
|
|
69
66
|
// only explicit null, not undefined, NaN
|
|
70
|
-
if (
|
|
71
|
-
return { kind: Kind.NULL };
|
|
67
|
+
if (value === null) {
|
|
68
|
+
return { kind: _kinds.Kind.NULL };
|
|
72
69
|
}
|
|
73
70
|
|
|
74
71
|
// undefined, NaN
|
|
75
|
-
if ((0, _isInvalid2.default)(
|
|
72
|
+
if ((0, _isInvalid2.default)(value)) {
|
|
76
73
|
return null;
|
|
77
74
|
}
|
|
78
75
|
|
|
@@ -80,77 +77,73 @@ function astFromValue(value, type) {
|
|
|
80
77
|
// the value is not an array, convert the value using the list's item type.
|
|
81
78
|
if ((0, _definition.isListType)(type)) {
|
|
82
79
|
var itemType = type.ofType;
|
|
83
|
-
if ((0, _iterall.isCollection)(
|
|
80
|
+
if ((0, _iterall.isCollection)(value)) {
|
|
84
81
|
var valuesNodes = [];
|
|
85
|
-
(0, _iterall.forEach)(
|
|
82
|
+
(0, _iterall.forEach)(value, function (item) {
|
|
86
83
|
var itemNode = astFromValue(item, itemType);
|
|
87
84
|
if (itemNode) {
|
|
88
85
|
valuesNodes.push(itemNode);
|
|
89
86
|
}
|
|
90
87
|
});
|
|
91
|
-
return { kind: Kind.LIST, values: valuesNodes };
|
|
88
|
+
return { kind: _kinds.Kind.LIST, values: valuesNodes };
|
|
92
89
|
}
|
|
93
|
-
return astFromValue(
|
|
90
|
+
return astFromValue(value, itemType);
|
|
94
91
|
}
|
|
95
92
|
|
|
96
93
|
// Populate the fields of the input object by creating ASTs from each value
|
|
97
94
|
// in the JavaScript object according to the fields in the input type.
|
|
98
95
|
if ((0, _definition.isInputObjectType)(type)) {
|
|
99
|
-
if (
|
|
96
|
+
if (value === null || (typeof value === 'undefined' ? 'undefined' : _typeof(value)) !== 'object') {
|
|
100
97
|
return null;
|
|
101
98
|
}
|
|
102
|
-
var fields = type.getFields();
|
|
99
|
+
var fields = (0, _objectValues2.default)(type.getFields());
|
|
103
100
|
var fieldNodes = [];
|
|
104
|
-
|
|
105
|
-
var
|
|
106
|
-
var fieldValue = astFromValue(_value[fieldName], fieldType);
|
|
101
|
+
fields.forEach(function (field) {
|
|
102
|
+
var fieldValue = astFromValue(value[field.name], field.type);
|
|
107
103
|
if (fieldValue) {
|
|
108
104
|
fieldNodes.push({
|
|
109
|
-
kind: Kind.OBJECT_FIELD,
|
|
110
|
-
name: { kind: Kind.NAME, value:
|
|
105
|
+
kind: _kinds.Kind.OBJECT_FIELD,
|
|
106
|
+
name: { kind: _kinds.Kind.NAME, value: field.name },
|
|
111
107
|
value: fieldValue
|
|
112
108
|
});
|
|
113
109
|
}
|
|
114
110
|
});
|
|
115
|
-
return { kind: Kind.OBJECT, fields: fieldNodes };
|
|
111
|
+
return { kind: _kinds.Kind.OBJECT, fields: fieldNodes };
|
|
116
112
|
}
|
|
117
113
|
|
|
118
114
|
if ((0, _definition.isScalarType)(type) || (0, _definition.isEnumType)(type)) {
|
|
119
115
|
// Since value is an internally represented value, it must be serialized
|
|
120
116
|
// to an externally represented value before converting into an AST.
|
|
121
|
-
var serialized = type.serialize(
|
|
117
|
+
var serialized = type.serialize(value);
|
|
122
118
|
if ((0, _isNullish2.default)(serialized)) {
|
|
123
119
|
return null;
|
|
124
120
|
}
|
|
125
121
|
|
|
126
122
|
// Others serialize based on their corresponding JavaScript scalar types.
|
|
127
123
|
if (typeof serialized === 'boolean') {
|
|
128
|
-
return { kind: Kind.BOOLEAN, value: serialized };
|
|
124
|
+
return { kind: _kinds.Kind.BOOLEAN, value: serialized };
|
|
129
125
|
}
|
|
130
126
|
|
|
131
127
|
// JavaScript numbers can be Int or Float values.
|
|
132
128
|
if (typeof serialized === 'number') {
|
|
133
129
|
var stringNum = String(serialized);
|
|
134
|
-
return
|
|
135
|
-
);
|
|
130
|
+
return integerStringRegExp.test(stringNum) ? { kind: _kinds.Kind.INT, value: stringNum } : { kind: _kinds.Kind.FLOAT, value: stringNum };
|
|
136
131
|
}
|
|
137
132
|
|
|
138
133
|
if (typeof serialized === 'string') {
|
|
139
134
|
// Enum types use Enum literals.
|
|
140
135
|
if ((0, _definition.isEnumType)(type)) {
|
|
141
|
-
return { kind: Kind.ENUM, value: serialized };
|
|
136
|
+
return { kind: _kinds.Kind.ENUM, value: serialized };
|
|
142
137
|
}
|
|
143
138
|
|
|
144
139
|
// ID types can use Int literals.
|
|
145
|
-
if (type === _scalars.GraphQLID &&
|
|
146
|
-
return { kind: Kind.INT, value: serialized };
|
|
140
|
+
if (type === _scalars.GraphQLID && integerStringRegExp.test(serialized)) {
|
|
141
|
+
return { kind: _kinds.Kind.INT, value: serialized };
|
|
147
142
|
}
|
|
148
143
|
|
|
149
|
-
// Use JSON stringify, which uses the same string encoding as GraphQL,
|
|
150
|
-
// then remove the quotes.
|
|
151
144
|
return {
|
|
152
|
-
kind: Kind.STRING,
|
|
153
|
-
value:
|
|
145
|
+
kind: _kinds.Kind.STRING,
|
|
146
|
+
value: serialized
|
|
154
147
|
};
|
|
155
148
|
}
|
|
156
149
|
|
|
@@ -159,4 +152,11 @@ function astFromValue(value, type) {
|
|
|
159
152
|
|
|
160
153
|
/* istanbul ignore next */
|
|
161
154
|
throw new Error('Unknown type: ' + type + '.');
|
|
162
|
-
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* IntValue:
|
|
159
|
+
* - NegativeSign? 0
|
|
160
|
+
* - NegativeSign? NonZeroDigit ( Digit+ )?
|
|
161
|
+
*/
|
|
162
|
+
var integerStringRegExp = /^-?(0|[1-9][0-9]*)$/;
|