graphql 14.1.1 → 14.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/error/GraphQLError.js +12 -10
- package/error/GraphQLError.js.flow +11 -6
- package/error/GraphQLError.mjs +20 -3
- package/error/formatError.js +2 -2
- package/error/formatError.js.flow +3 -3
- package/error/formatError.mjs +2 -2
- package/error/index.js +1 -1
- package/error/index.js.flow +5 -2
- package/error/index.mjs +2 -2
- package/error/locatedError.js +2 -2
- package/error/locatedError.js.flow +2 -2
- package/error/locatedError.mjs +2 -2
- package/error/printError.js +2 -2
- package/error/printError.js.flow +4 -5
- package/error/printError.mjs +2 -2
- package/error/syntaxError.js +2 -2
- package/error/syntaxError.js.flow +2 -2
- package/error/syntaxError.mjs +2 -2
- package/execution/execute.js +52 -37
- package/execution/execute.js.flow +66 -51
- package/execution/execute.mjs +50 -38
- package/execution/index.js +7 -1
- package/execution/index.js.flow +9 -4
- package/execution/index.mjs +3 -3
- package/execution/values.js +11 -11
- package/execution/values.js.flow +23 -19
- package/execution/values.mjs +11 -11
- package/graphql.js +13 -9
- package/graphql.js.flow +28 -10
- package/graphql.mjs +10 -9
- package/index.js +83 -53
- package/index.js.flow +60 -47
- package/index.mjs +26 -23
- package/jsutils/ObjMap.js +1 -1
- package/jsutils/ObjMap.js.flow +1 -1
- package/jsutils/ObjMap.mjs +1 -0
- package/jsutils/PromiseOrValue.js +1 -0
- package/jsutils/{MaybePromise.js.flow → PromiseOrValue.js.flow} +2 -2
- package/jsutils/PromiseOrValue.mjs +1 -0
- package/jsutils/dedent.js +2 -2
- package/jsutils/dedent.js.flow +1 -1
- package/jsutils/dedent.mjs +2 -2
- package/jsutils/defineToJSON.js +2 -2
- package/jsutils/defineToJSON.js.flow +1 -1
- package/jsutils/defineToJSON.mjs +2 -2
- package/jsutils/defineToStringTag.js +2 -2
- package/jsutils/defineToStringTag.js.flow +1 -1
- package/jsutils/defineToStringTag.mjs +2 -2
- package/jsutils/inspect.js +94 -19
- package/jsutils/inspect.js.flow +98 -20
- package/jsutils/inspect.mjs +94 -20
- package/jsutils/instanceOf.js +2 -2
- package/jsutils/instanceOf.js.flow +1 -1
- package/jsutils/instanceOf.mjs +2 -2
- package/jsutils/invariant.js +5 -3
- package/jsutils/invariant.js.flow +3 -2
- package/jsutils/invariant.mjs +5 -3
- package/jsutils/isInvalid.js +2 -2
- package/jsutils/isInvalid.js.flow +1 -1
- package/jsutils/isInvalid.mjs +2 -2
- package/jsutils/isNullish.js +2 -2
- package/jsutils/isNullish.js.flow +1 -1
- package/jsutils/isNullish.mjs +2 -2
- package/jsutils/isPromise.js +2 -2
- package/jsutils/isPromise.js.flow +1 -1
- package/jsutils/isPromise.mjs +2 -2
- package/jsutils/keyMap.js +4 -3
- package/jsutils/keyMap.js.flow +6 -6
- package/jsutils/keyMap.mjs +4 -3
- package/jsutils/keyValMap.js +4 -3
- package/jsutils/keyValMap.js.flow +6 -6
- package/jsutils/keyValMap.mjs +4 -3
- package/jsutils/mapValue.js +2 -2
- package/jsutils/mapValue.js.flow +2 -2
- package/jsutils/mapValue.mjs +2 -2
- package/jsutils/memoize3.js +3 -3
- package/jsutils/memoize3.js.flow +2 -2
- package/jsutils/memoize3.mjs +3 -3
- package/jsutils/nodejsCustomInspectSymbol.js +2 -2
- package/jsutils/nodejsCustomInspectSymbol.js.flow +1 -1
- package/jsutils/nodejsCustomInspectSymbol.mjs +2 -2
- package/jsutils/orList.js +2 -2
- package/jsutils/orList.js.flow +1 -1
- package/jsutils/orList.mjs +2 -2
- package/jsutils/promiseForObject.js +2 -2
- package/jsutils/promiseForObject.js.flow +2 -2
- package/jsutils/promiseForObject.mjs +2 -2
- package/jsutils/promiseReduce.js +2 -2
- package/jsutils/promiseReduce.js.flow +5 -5
- package/jsutils/promiseReduce.mjs +2 -2
- package/jsutils/quotedOrList.js +2 -2
- package/jsutils/quotedOrList.js.flow +1 -1
- package/jsutils/quotedOrList.mjs +2 -2
- package/jsutils/suggestionList.js +2 -2
- package/jsutils/suggestionList.js.flow +1 -1
- package/jsutils/suggestionList.mjs +2 -2
- package/language/ast.js +1 -1
- package/language/ast.js.flow +3 -3
- package/language/ast.mjs +1 -0
- package/language/blockString.js +114 -0
- package/language/blockString.js.flow +102 -0
- package/language/blockString.mjs +104 -0
- package/language/directiveLocation.js +2 -2
- package/language/directiveLocation.js.flow +1 -1
- package/language/directiveLocation.mjs +2 -2
- package/language/index.js +9 -9
- package/language/index.js.flow +10 -5
- package/language/index.mjs +3 -3
- package/language/kinds.js +2 -2
- package/language/kinds.js.flow +1 -1
- package/language/kinds.mjs +2 -2
- package/language/lexer.js +52 -44
- package/language/lexer.js.flow +65 -54
- package/language/lexer.mjs +49 -43
- package/language/location.js +2 -2
- package/language/location.js.flow +2 -2
- package/language/location.mjs +2 -2
- package/language/parser.js +75 -67
- package/language/parser.js.flow +138 -127
- package/language/parser.mjs +76 -68
- package/language/predicates.js +2 -2
- package/language/predicates.js.flow +2 -2
- package/language/predicates.mjs +2 -2
- package/language/printer.js +6 -14
- package/language/printer.js.flow +8 -17
- package/language/printer.mjs +5 -14
- package/language/source.js +2 -2
- package/language/source.js.flow +1 -1
- package/language/source.mjs +2 -2
- package/language/visitor.js +4 -6
- package/language/visitor.js.flow +3 -3
- package/language/visitor.mjs +4 -6
- package/package.json +1 -1
- package/polyfills/find.js +2 -2
- package/polyfills/find.js.flow +1 -1
- package/polyfills/find.mjs +2 -2
- package/polyfills/flatMap.js +38 -0
- package/polyfills/flatMap.js.flow +34 -0
- package/polyfills/flatMap.mjs +30 -0
- package/polyfills/isFinite.js +2 -2
- package/polyfills/isFinite.js.flow +1 -1
- package/polyfills/isFinite.mjs +2 -2
- package/polyfills/isInteger.js +2 -2
- package/polyfills/isInteger.js.flow +1 -1
- package/polyfills/isInteger.mjs +2 -2
- package/polyfills/objectEntries.js +2 -2
- package/polyfills/objectEntries.js.flow +2 -2
- package/polyfills/objectEntries.mjs +2 -2
- package/polyfills/objectValues.js +2 -2
- package/polyfills/objectValues.js.flow +2 -2
- package/polyfills/objectValues.mjs +2 -2
- package/subscription/asyncIteratorReject.js +1 -1
- package/subscription/asyncIteratorReject.js.flow +1 -1
- package/subscription/asyncIteratorReject.mjs +2 -2
- package/subscription/index.js +1 -1
- package/subscription/index.js.flow +1 -1
- package/subscription/index.mjs +2 -2
- package/subscription/mapAsyncIterator.js +1 -1
- package/subscription/mapAsyncIterator.js.flow +5 -5
- package/subscription/mapAsyncIterator.mjs +2 -2
- package/subscription/subscribe.js +2 -2
- package/subscription/subscribe.js.flow +6 -6
- package/subscription/subscribe.mjs +2 -2
- package/type/definition.js +138 -22
- package/type/definition.js.flow +184 -36
- package/type/definition.mjs +136 -23
- package/type/directives.js +14 -3
- package/type/directives.js.flow +24 -11
- package/type/directives.mjs +16 -5
- package/type/index.js +7 -7
- package/type/index.js.flow +8 -4
- package/type/index.mjs +10 -6
- package/type/introspection.js +14 -9
- package/type/introspection.js.flow +12 -18
- package/type/introspection.mjs +14 -9
- package/type/scalars.js +5 -4
- package/type/scalars.js.flow +4 -10
- package/type/scalars.mjs +7 -6
- package/type/schema.js +55 -3
- package/type/schema.js.flow +73 -17
- package/type/schema.mjs +56 -4
- package/type/validate.js +19 -47
- package/type/validate.js.flow +17 -29
- package/type/validate.mjs +18 -47
- package/utilities/TypeInfo.js +93 -73
- package/utilities/TypeInfo.js.flow +30 -23
- package/utilities/TypeInfo.mjs +93 -73
- package/utilities/assertValidName.js +2 -2
- package/utilities/assertValidName.js.flow +2 -2
- package/utilities/assertValidName.mjs +2 -2
- package/utilities/astFromValue.js +5 -4
- package/utilities/astFromValue.js.flow +8 -7
- package/utilities/astFromValue.mjs +7 -6
- package/utilities/buildASTSchema.js +63 -62
- package/utilities/buildASTSchema.js.flow +92 -108
- package/utilities/buildASTSchema.mjs +61 -62
- package/utilities/buildClientSchema.js +38 -45
- package/utilities/buildClientSchema.js.flow +66 -79
- package/utilities/buildClientSchema.mjs +37 -44
- package/utilities/coerceValue.js +6 -7
- package/utilities/coerceValue.js.flow +5 -4
- package/utilities/coerceValue.mjs +7 -8
- package/utilities/concatAST.js +9 -13
- package/utilities/concatAST.js.flow +4 -10
- package/utilities/concatAST.mjs +6 -13
- package/utilities/extendSchema.js +219 -511
- package/utilities/extendSchema.js.flow +195 -304
- package/utilities/extendSchema.mjs +218 -512
- package/utilities/findBreakingChanges.js +54 -95
- package/utilities/findBreakingChanges.js.flow +49 -47
- package/utilities/findBreakingChanges.mjs +80 -95
- package/utilities/findDeprecatedUsages.js +4 -4
- package/utilities/findDeprecatedUsages.js.flow +5 -5
- package/utilities/findDeprecatedUsages.mjs +4 -4
- package/utilities/getOperationAST.js +2 -2
- package/utilities/getOperationAST.js.flow +5 -2
- package/utilities/getOperationAST.mjs +2 -2
- package/utilities/getOperationRootType.js +24 -24
- package/utilities/getOperationRootType.js.flow +40 -35
- package/utilities/getOperationRootType.mjs +24 -24
- package/utilities/index.js +9 -1
- package/utilities/index.js.flow +13 -6
- package/utilities/index.mjs +13 -8
- package/utilities/introspectionFromSchema.js +6 -4
- package/utilities/introspectionFromSchema.js.flow +8 -7
- package/utilities/introspectionFromSchema.mjs +6 -5
- package/utilities/introspectionQuery.js +2 -2
- package/utilities/introspectionQuery.js.flow +2 -2
- package/utilities/introspectionQuery.mjs +2 -2
- package/utilities/isValidJSValue.js +4 -2
- package/utilities/isValidJSValue.js.flow +3 -2
- package/utilities/isValidJSValue.mjs +4 -2
- package/utilities/isValidLiteralValue.js +2 -2
- package/utilities/isValidLiteralValue.js.flow +4 -4
- package/utilities/isValidLiteralValue.mjs +2 -2
- package/utilities/lexicographicSortSchema.js +84 -123
- package/utilities/lexicographicSortSchema.js.flow +68 -96
- package/utilities/lexicographicSortSchema.mjs +84 -123
- package/utilities/schemaPrinter.js +47 -73
- package/utilities/schemaPrinter.js.flow +69 -120
- package/utilities/schemaPrinter.mjs +45 -72
- package/utilities/separateOperations.js +8 -12
- package/utilities/separateOperations.js.flow +6 -3
- package/utilities/separateOperations.mjs +8 -12
- package/utilities/stripIgnoredCharacters.js +140 -0
- package/utilities/stripIgnoredCharacters.js.flow +129 -0
- package/utilities/stripIgnoredCharacters.mjs +127 -0
- package/utilities/typeComparators.js +2 -2
- package/utilities/typeComparators.js.flow +4 -3
- package/utilities/typeComparators.mjs +2 -2
- package/utilities/typeFromAST.js +9 -4
- package/utilities/typeFromAST.js.flow +15 -9
- package/utilities/typeFromAST.mjs +6 -4
- package/utilities/valueFromAST.js +7 -4
- package/utilities/valueFromAST.js.flow +7 -5
- package/utilities/valueFromAST.mjs +6 -4
- package/utilities/valueFromASTUntyped.js +11 -6
- package/utilities/valueFromASTUntyped.js.flow +9 -5
- package/utilities/valueFromASTUntyped.mjs +10 -6
- package/validation/ValidationContext.js +1 -1
- package/validation/ValidationContext.js.flow +19 -20
- package/validation/ValidationContext.mjs +2 -2
- package/validation/index.js +1 -1
- package/validation/index.js.flow +2 -1
- package/validation/index.mjs +3 -2
- package/validation/rules/ExecutableDefinitions.js +3 -3
- package/validation/rules/ExecutableDefinitions.js.flow +4 -4
- package/validation/rules/ExecutableDefinitions.mjs +3 -3
- package/validation/rules/FieldsOnCorrectType.js +3 -3
- package/validation/rules/FieldsOnCorrectType.js.flow +7 -7
- package/validation/rules/FieldsOnCorrectType.mjs +3 -3
- package/validation/rules/FragmentsOnCompositeTypes.js +4 -4
- package/validation/rules/FragmentsOnCompositeTypes.js.flow +5 -5
- package/validation/rules/FragmentsOnCompositeTypes.mjs +4 -4
- package/validation/rules/KnownArgumentNames.js +1 -1
- package/validation/rules/KnownArgumentNames.js.flow +5 -5
- package/validation/rules/KnownArgumentNames.mjs +2 -2
- package/validation/rules/KnownDirectives.js +8 -6
- package/validation/rules/KnownDirectives.js.flow +11 -9
- package/validation/rules/KnownDirectives.mjs +8 -6
- package/validation/rules/KnownFragmentNames.js +3 -3
- package/validation/rules/KnownFragmentNames.js.flow +4 -4
- package/validation/rules/KnownFragmentNames.mjs +3 -3
- package/validation/rules/KnownTypeNames.js +2 -2
- package/validation/rules/KnownTypeNames.js.flow +6 -6
- package/validation/rules/KnownTypeNames.mjs +2 -2
- package/validation/rules/LoneAnonymousOperation.js +3 -3
- package/validation/rules/LoneAnonymousOperation.js.flow +4 -4
- package/validation/rules/LoneAnonymousOperation.mjs +3 -3
- package/validation/rules/LoneSchemaDefinition.js +2 -2
- package/validation/rules/LoneSchemaDefinition.js.flow +3 -3
- package/validation/rules/LoneSchemaDefinition.mjs +2 -2
- package/validation/rules/NoFragmentCycles.js +2 -2
- package/validation/rules/NoFragmentCycles.js.flow +4 -4
- package/validation/rules/NoFragmentCycles.mjs +2 -2
- package/validation/rules/NoUndefinedVariables.js +2 -2
- package/validation/rules/NoUndefinedVariables.js.flow +3 -3
- package/validation/rules/NoUndefinedVariables.mjs +2 -2
- package/validation/rules/NoUnusedFragments.js +7 -7
- package/validation/rules/NoUnusedFragments.js.flow +4 -4
- package/validation/rules/NoUnusedFragments.mjs +7 -7
- package/validation/rules/NoUnusedVariables.js +5 -5
- package/validation/rules/NoUnusedVariables.js.flow +6 -5
- package/validation/rules/NoUnusedVariables.mjs +5 -5
- package/validation/rules/OverlappingFieldsCanBeMerged.js +26 -23
- package/validation/rules/OverlappingFieldsCanBeMerged.js.flow +17 -17
- package/validation/rules/OverlappingFieldsCanBeMerged.mjs +26 -23
- package/validation/rules/PossibleFragmentSpreads.js +4 -4
- package/validation/rules/PossibleFragmentSpreads.js.flow +5 -5
- package/validation/rules/PossibleFragmentSpreads.mjs +4 -4
- package/validation/rules/PossibleTypeExtensions.js +3 -3
- package/validation/rules/PossibleTypeExtensions.js.flow +5 -5
- package/validation/rules/PossibleTypeExtensions.mjs +4 -4
- package/validation/rules/ProvidedRequiredArguments.js +6 -8
- package/validation/rules/ProvidedRequiredArguments.js.flow +8 -8
- package/validation/rules/ProvidedRequiredArguments.mjs +7 -9
- package/validation/rules/ScalarLeafs.js +4 -4
- package/validation/rules/ScalarLeafs.js.flow +6 -6
- package/validation/rules/ScalarLeafs.mjs +4 -4
- package/validation/rules/SingleFieldSubscriptions.js +2 -2
- package/validation/rules/SingleFieldSubscriptions.js.flow +4 -4
- package/validation/rules/SingleFieldSubscriptions.mjs +2 -2
- package/validation/rules/UniqueArgumentNames.js +2 -2
- package/validation/rules/UniqueArgumentNames.js.flow +3 -3
- package/validation/rules/UniqueArgumentNames.mjs +2 -2
- package/validation/rules/UniqueDirectiveNames.js +2 -2
- package/validation/rules/UniqueDirectiveNames.js.flow +3 -3
- package/validation/rules/UniqueDirectiveNames.mjs +2 -2
- package/validation/rules/UniqueDirectivesPerLocation.js +3 -2
- package/validation/rules/UniqueDirectivesPerLocation.js.flow +4 -4
- package/validation/rules/UniqueDirectivesPerLocation.mjs +3 -2
- package/validation/rules/UniqueEnumValueNames.js +4 -8
- package/validation/rules/UniqueEnumValueNames.js.flow +6 -8
- package/validation/rules/UniqueEnumValueNames.mjs +4 -8
- package/validation/rules/UniqueFieldDefinitionNames.js +4 -8
- package/validation/rules/UniqueFieldDefinitionNames.js.flow +6 -8
- package/validation/rules/UniqueFieldDefinitionNames.mjs +4 -8
- package/validation/rules/UniqueFragmentNames.js +2 -2
- package/validation/rules/UniqueFragmentNames.js.flow +3 -3
- package/validation/rules/UniqueFragmentNames.mjs +2 -2
- package/validation/rules/UniqueInputFieldNames.js +2 -4
- package/validation/rules/UniqueInputFieldNames.js.flow +3 -4
- package/validation/rules/UniqueInputFieldNames.mjs +2 -4
- package/validation/rules/UniqueOperationNames.js +2 -2
- package/validation/rules/UniqueOperationNames.js.flow +3 -3
- package/validation/rules/UniqueOperationNames.mjs +2 -2
- package/validation/rules/UniqueOperationTypes.js +2 -2
- package/validation/rules/UniqueOperationTypes.js.flow +3 -3
- package/validation/rules/UniqueOperationTypes.mjs +2 -2
- package/validation/rules/UniqueTypeNames.js +2 -2
- package/validation/rules/UniqueTypeNames.js.flow +4 -4
- package/validation/rules/UniqueTypeNames.mjs +2 -2
- package/validation/rules/UniqueVariableNames.js +2 -2
- package/validation/rules/UniqueVariableNames.js.flow +4 -4
- package/validation/rules/UniqueVariableNames.mjs +2 -2
- package/validation/rules/ValuesOfCorrectType.js +2 -2
- package/validation/rules/ValuesOfCorrectType.js.flow +5 -5
- package/validation/rules/ValuesOfCorrectType.mjs +2 -2
- package/validation/rules/VariablesAreInputTypes.js +3 -3
- package/validation/rules/VariablesAreInputTypes.js.flow +5 -5
- package/validation/rules/VariablesAreInputTypes.mjs +3 -3
- package/validation/rules/VariablesInAllowedPosition.js +3 -3
- package/validation/rules/VariablesInAllowedPosition.js.flow +7 -8
- package/validation/rules/VariablesInAllowedPosition.mjs +3 -3
- package/validation/specifiedRules.js +2 -2
- package/validation/specifiedRules.js.flow +13 -6
- package/validation/specifiedRules.mjs +7 -7
- package/validation/validate.js +2 -2
- package/validation/validate.js.flow +10 -6
- package/validation/validate.mjs +2 -2
- package/jsutils/MaybePromise.js +0 -1
- package/jsutils/MaybePromise.mjs +0 -0
- package/language/blockStringValue.js +0 -73
- package/language/blockStringValue.js.flow +0 -64
- package/language/blockStringValue.mjs +0 -66
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
3
|
*
|
|
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.
|
|
@@ -8,10 +8,11 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import objectValues from '../polyfills/objectValues';
|
|
11
|
-
import
|
|
11
|
+
import inspect from '../jsutils/inspect';
|
|
12
12
|
import { astFromValue } from '../utilities/astFromValue';
|
|
13
13
|
import { print } from '../language/printer';
|
|
14
14
|
import {
|
|
15
|
+
type GraphQLField,
|
|
15
16
|
GraphQLObjectType,
|
|
16
17
|
GraphQLEnumType,
|
|
17
18
|
GraphQLList,
|
|
@@ -29,7 +30,6 @@ import {
|
|
|
29
30
|
} from './definition';
|
|
30
31
|
import { GraphQLString, GraphQLBoolean } from './scalars';
|
|
31
32
|
import { DirectiveLocation } from '../language/directiveLocation';
|
|
32
|
-
import type { GraphQLField } from './definition';
|
|
33
33
|
|
|
34
34
|
export const __Schema = new GraphQLObjectType({
|
|
35
35
|
name: '__Schema',
|
|
@@ -218,7 +218,10 @@ export const __Type = new GraphQLObjectType({
|
|
|
218
218
|
} else if (isNonNullType(type)) {
|
|
219
219
|
return TypeKind.NON_NULL;
|
|
220
220
|
}
|
|
221
|
-
|
|
221
|
+
|
|
222
|
+
// Not reachable. All possible types have been considered.
|
|
223
|
+
/* istanbul ignore next */
|
|
224
|
+
throw new Error(`Unexpected type: "${inspect((type: empty))}".`);
|
|
222
225
|
},
|
|
223
226
|
},
|
|
224
227
|
name: {
|
|
@@ -348,10 +351,10 @@ export const __InputValue = new GraphQLObjectType({
|
|
|
348
351
|
description:
|
|
349
352
|
'A GraphQL-formatted string representing the default value for this ' +
|
|
350
353
|
'input value.',
|
|
351
|
-
resolve
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
354
|
+
resolve(inputVal) {
|
|
355
|
+
const valueAST = astFromValue(inputVal.defaultValue, inputVal.type);
|
|
356
|
+
return valueAST ? print(valueAST) : null;
|
|
357
|
+
},
|
|
355
358
|
},
|
|
356
359
|
}),
|
|
357
360
|
});
|
|
@@ -484,15 +487,6 @@ export const introspectionTypes: $ReadOnlyArray<*> = [
|
|
|
484
487
|
export function isIntrospectionType(type: mixed): boolean %checks {
|
|
485
488
|
return (
|
|
486
489
|
isNamedType(type) &&
|
|
487
|
-
|
|
488
|
-
// a simple expression.
|
|
489
|
-
(type.name === __Schema.name ||
|
|
490
|
-
type.name === __Directive.name ||
|
|
491
|
-
type.name === __DirectiveLocation.name ||
|
|
492
|
-
type.name === __Type.name ||
|
|
493
|
-
type.name === __Field.name ||
|
|
494
|
-
type.name === __InputValue.name ||
|
|
495
|
-
type.name === __EnumValue.name ||
|
|
496
|
-
type.name === __TypeKind.name)
|
|
490
|
+
introspectionTypes.some(({ name }) => type.name === name)
|
|
497
491
|
);
|
|
498
492
|
}
|
package/type/introspection.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
3
|
*
|
|
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.
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
9
|
import objectValues from '../polyfills/objectValues';
|
|
10
|
-
import
|
|
10
|
+
import inspect from '../jsutils/inspect';
|
|
11
11
|
import { astFromValue } from '../utilities/astFromValue';
|
|
12
12
|
import { print } from '../language/printer';
|
|
13
13
|
import { GraphQLObjectType, GraphQLEnumType, GraphQLList, GraphQLNonNull, isScalarType, isObjectType, isInterfaceType, isUnionType, isEnumType, isInputObjectType, isListType, isNonNullType, isAbstractType, isNamedType } from './definition';
|
|
@@ -194,9 +194,12 @@ export var __Type = new GraphQLObjectType({
|
|
|
194
194
|
return TypeKind.LIST;
|
|
195
195
|
} else if (isNonNullType(type)) {
|
|
196
196
|
return TypeKind.NON_NULL;
|
|
197
|
-
}
|
|
197
|
+
} // Not reachable. All possible types have been considered.
|
|
198
|
+
|
|
199
|
+
/* istanbul ignore next */
|
|
200
|
+
|
|
198
201
|
|
|
199
|
-
throw new Error(
|
|
202
|
+
throw new Error("Unexpected type: \"".concat(inspect(type), "\"."));
|
|
200
203
|
}
|
|
201
204
|
},
|
|
202
205
|
name: {
|
|
@@ -367,7 +370,8 @@ export var __InputValue = new GraphQLObjectType({
|
|
|
367
370
|
type: GraphQLString,
|
|
368
371
|
description: 'A GraphQL-formatted string representing the default value for this ' + 'input value.',
|
|
369
372
|
resolve: function resolve(inputVal) {
|
|
370
|
-
|
|
373
|
+
var valueAST = astFromValue(inputVal.defaultValue, inputVal.type);
|
|
374
|
+
return valueAST ? print(valueAST) : null;
|
|
371
375
|
}
|
|
372
376
|
}
|
|
373
377
|
};
|
|
@@ -494,7 +498,8 @@ export var TypeNameMetaFieldDef = {
|
|
|
494
498
|
};
|
|
495
499
|
export var introspectionTypes = [__Schema, __Directive, __DirectiveLocation, __Type, __Field, __InputValue, __EnumValue, __TypeKind];
|
|
496
500
|
export function isIntrospectionType(type) {
|
|
497
|
-
return isNamedType(type) &&
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
}
|
|
501
|
+
return isNamedType(type) && introspectionTypes.some(function (_ref8) {
|
|
502
|
+
var name = _ref8.name;
|
|
503
|
+
return type.name === name;
|
|
504
|
+
});
|
|
505
|
+
}
|
package/type/scalars.js
CHANGED
|
@@ -249,7 +249,8 @@ var specifiedScalarTypes = [GraphQLString, GraphQLInt, GraphQLFloat, GraphQLBool
|
|
|
249
249
|
exports.specifiedScalarTypes = specifiedScalarTypes;
|
|
250
250
|
|
|
251
251
|
function isSpecifiedScalarType(type) {
|
|
252
|
-
return (0, _definition.
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
}
|
|
252
|
+
return (0, _definition.isScalarType)(type) && specifiedScalarTypes.some(function (_ref) {
|
|
253
|
+
var name = _ref.name;
|
|
254
|
+
return type.name === name;
|
|
255
|
+
});
|
|
256
|
+
}
|
package/type/scalars.js.flow
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
3
|
*
|
|
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.
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import isFinite from '../polyfills/isFinite';
|
|
11
11
|
import isInteger from '../polyfills/isInteger';
|
|
12
12
|
import inspect from '../jsutils/inspect';
|
|
13
|
-
import { GraphQLScalarType,
|
|
13
|
+
import { GraphQLScalarType, isScalarType } from './definition';
|
|
14
14
|
import { Kind } from '../language/kinds';
|
|
15
15
|
|
|
16
16
|
// As per the GraphQL Spec, Integers are only treated as valid when a valid
|
|
@@ -255,13 +255,7 @@ export const specifiedScalarTypes: $ReadOnlyArray<*> = [
|
|
|
255
255
|
|
|
256
256
|
export function isSpecifiedScalarType(type: mixed): boolean %checks {
|
|
257
257
|
return (
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
// a simple expression.
|
|
261
|
-
(type.name === GraphQLString.name ||
|
|
262
|
-
type.name === GraphQLInt.name ||
|
|
263
|
-
type.name === GraphQLFloat.name ||
|
|
264
|
-
type.name === GraphQLBoolean.name ||
|
|
265
|
-
type.name === GraphQLID.name)
|
|
258
|
+
isScalarType(type) &&
|
|
259
|
+
specifiedScalarTypes.some(({ name }) => type.name === name)
|
|
266
260
|
);
|
|
267
261
|
}
|
package/type/scalars.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Copyright (c)
|
|
4
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
5
5
|
*
|
|
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.
|
|
@@ -11,7 +11,7 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
|
|
|
11
11
|
import isFinite from '../polyfills/isFinite';
|
|
12
12
|
import isInteger from '../polyfills/isInteger';
|
|
13
13
|
import inspect from '../jsutils/inspect';
|
|
14
|
-
import { GraphQLScalarType,
|
|
14
|
+
import { GraphQLScalarType, isScalarType } from './definition';
|
|
15
15
|
import { Kind } from '../language/kinds'; // As per the GraphQL Spec, Integers are only treated as valid when a valid
|
|
16
16
|
// 32-bit signed integer, providing the broadest support across platforms.
|
|
17
17
|
//
|
|
@@ -234,7 +234,8 @@ export var GraphQLID = new GraphQLScalarType({
|
|
|
234
234
|
});
|
|
235
235
|
export var specifiedScalarTypes = [GraphQLString, GraphQLInt, GraphQLFloat, GraphQLBoolean, GraphQLID];
|
|
236
236
|
export function isSpecifiedScalarType(type) {
|
|
237
|
-
return
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
}
|
|
237
|
+
return isScalarType(type) && specifiedScalarTypes.some(function (_ref) {
|
|
238
|
+
var name = _ref.name;
|
|
239
|
+
return type.name === name;
|
|
240
|
+
});
|
|
241
|
+
}
|
package/type/schema.js
CHANGED
|
@@ -52,6 +52,43 @@ function assertSchema(schema) {
|
|
|
52
52
|
* mutation: MyAppMutationRootType,
|
|
53
53
|
* })
|
|
54
54
|
*
|
|
55
|
+
* Note: When the schema is constructed, by default only the types that are
|
|
56
|
+
* reachable by traversing the root types are included, other types must be
|
|
57
|
+
* explicitly referenced.
|
|
58
|
+
*
|
|
59
|
+
* Example:
|
|
60
|
+
*
|
|
61
|
+
* const characterInterface = new GraphQLInterfaceType({
|
|
62
|
+
* name: 'Character',
|
|
63
|
+
* ...
|
|
64
|
+
* });
|
|
65
|
+
*
|
|
66
|
+
* const humanType = new GraphQLObjectType({
|
|
67
|
+
* name: 'Human',
|
|
68
|
+
* interfaces: [characterInterface],
|
|
69
|
+
* ...
|
|
70
|
+
* });
|
|
71
|
+
*
|
|
72
|
+
* const droidType = new GraphQLObjectType({
|
|
73
|
+
* name: 'Droid',
|
|
74
|
+
* interfaces: [characterInterface],
|
|
75
|
+
* ...
|
|
76
|
+
* });
|
|
77
|
+
*
|
|
78
|
+
* const schema = new GraphQLSchema({
|
|
79
|
+
* query: new GraphQLObjectType({
|
|
80
|
+
* name: 'Query',
|
|
81
|
+
* fields: {
|
|
82
|
+
* hero: { type: characterInterface, ... },
|
|
83
|
+
* }
|
|
84
|
+
* }),
|
|
85
|
+
* ...
|
|
86
|
+
* // Since this schema references only the `Character` interface it's
|
|
87
|
+
* // necessary to explicitly list the types that implement it if
|
|
88
|
+
* // you want them to be included in the final schema.
|
|
89
|
+
* types: [humanType, droidType],
|
|
90
|
+
* })
|
|
91
|
+
*
|
|
55
92
|
* Note: If an array of `directives` are provided to GraphQLSchema, that will be
|
|
56
93
|
* the exact list of directives represented and allowed. If `directives` is not
|
|
57
94
|
* provided then a default set of the specified directives (e.g. @include and
|
|
@@ -210,7 +247,8 @@ function () {
|
|
|
210
247
|
if (!possibleTypeMap[abstractType.name]) {
|
|
211
248
|
var possibleTypes = this.getPossibleTypes(abstractType);
|
|
212
249
|
possibleTypeMap[abstractType.name] = possibleTypes.reduce(function (map, type) {
|
|
213
|
-
|
|
250
|
+
map[type.name] = true;
|
|
251
|
+
return map;
|
|
214
252
|
}, Object.create(null));
|
|
215
253
|
}
|
|
216
254
|
|
|
@@ -227,6 +265,20 @@ function () {
|
|
|
227
265
|
});
|
|
228
266
|
};
|
|
229
267
|
|
|
268
|
+
_proto.toConfig = function toConfig() {
|
|
269
|
+
return {
|
|
270
|
+
types: (0, _objectValues.default)(this.getTypeMap()),
|
|
271
|
+
directives: this.getDirectives().slice(),
|
|
272
|
+
query: this.getQueryType(),
|
|
273
|
+
mutation: this.getMutationType(),
|
|
274
|
+
subscription: this.getSubscriptionType(),
|
|
275
|
+
astNode: this.astNode,
|
|
276
|
+
extensionASTNodes: this.extensionASTNodes || [],
|
|
277
|
+
assumeValid: this.__validationErrors !== undefined,
|
|
278
|
+
allowedLegacyNames: this.__allowedLegacyNames
|
|
279
|
+
};
|
|
280
|
+
};
|
|
281
|
+
|
|
230
282
|
return GraphQLSchema;
|
|
231
283
|
}(); // Conditionally apply `[Symbol.toStringTag]` if `Symbol`s are supported
|
|
232
284
|
|
|
@@ -244,7 +296,7 @@ function typeMapReducer(map, type) {
|
|
|
244
296
|
}
|
|
245
297
|
|
|
246
298
|
if (map[type.name]) {
|
|
247
|
-
!(map[type.name] === type) ? (0, _invariant.default)(0, 'Schema must contain
|
|
299
|
+
!(map[type.name] === type) ? (0, _invariant.default)(0, 'Schema must contain uniquely named types but contains multiple ' + "types named \"".concat(type.name, "\".")) : void 0;
|
|
248
300
|
return map;
|
|
249
301
|
}
|
|
250
302
|
|
|
@@ -331,4 +383,4 @@ function typeMapDirectiveReducer(map, directive) {
|
|
|
331
383
|
return directive.args.reduce(function (_map, arg) {
|
|
332
384
|
return typeMapReducer(_map, arg.type);
|
|
333
385
|
}, map);
|
|
334
|
-
}
|
|
386
|
+
}
|
package/type/schema.js.flow
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
3
|
*
|
|
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.
|
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
import find from '../polyfills/find';
|
|
11
11
|
import objectValues from '../polyfills/objectValues';
|
|
12
12
|
import {
|
|
13
|
+
type GraphQLType,
|
|
14
|
+
type GraphQLNamedType,
|
|
15
|
+
type GraphQLAbstractType,
|
|
16
|
+
type GraphQLObjectType,
|
|
13
17
|
isAbstractType,
|
|
14
18
|
isObjectType,
|
|
15
19
|
isInterfaceType,
|
|
@@ -17,28 +21,22 @@ import {
|
|
|
17
21
|
isInputObjectType,
|
|
18
22
|
isWrappingType,
|
|
19
23
|
} from './definition';
|
|
20
|
-
import
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
GraphQLAbstractType,
|
|
24
|
-
GraphQLObjectType,
|
|
25
|
-
} from './definition';
|
|
26
|
-
import type {
|
|
27
|
-
SchemaDefinitionNode,
|
|
28
|
-
SchemaExtensionNode,
|
|
24
|
+
import {
|
|
25
|
+
type SchemaDefinitionNode,
|
|
26
|
+
type SchemaExtensionNode,
|
|
29
27
|
} from '../language/ast';
|
|
30
28
|
import {
|
|
31
29
|
GraphQLDirective,
|
|
32
30
|
isDirective,
|
|
33
31
|
specifiedDirectives,
|
|
34
32
|
} from './directives';
|
|
35
|
-
import type
|
|
33
|
+
import { type GraphQLError } from '../error/GraphQLError';
|
|
36
34
|
import inspect from '../jsutils/inspect';
|
|
37
35
|
import { __Schema } from './introspection';
|
|
38
36
|
import defineToStringTag from '../jsutils/defineToStringTag';
|
|
39
37
|
import instanceOf from '../jsutils/instanceOf';
|
|
40
38
|
import invariant from '../jsutils/invariant';
|
|
41
|
-
import type
|
|
39
|
+
import { type ObjMap } from '../jsutils/ObjMap';
|
|
42
40
|
|
|
43
41
|
/**
|
|
44
42
|
* Test if the given value is a GraphQL schema.
|
|
@@ -72,6 +70,43 @@ export function assertSchema(schema: mixed): GraphQLSchema {
|
|
|
72
70
|
* mutation: MyAppMutationRootType,
|
|
73
71
|
* })
|
|
74
72
|
*
|
|
73
|
+
* Note: When the schema is constructed, by default only the types that are
|
|
74
|
+
* reachable by traversing the root types are included, other types must be
|
|
75
|
+
* explicitly referenced.
|
|
76
|
+
*
|
|
77
|
+
* Example:
|
|
78
|
+
*
|
|
79
|
+
* const characterInterface = new GraphQLInterfaceType({
|
|
80
|
+
* name: 'Character',
|
|
81
|
+
* ...
|
|
82
|
+
* });
|
|
83
|
+
*
|
|
84
|
+
* const humanType = new GraphQLObjectType({
|
|
85
|
+
* name: 'Human',
|
|
86
|
+
* interfaces: [characterInterface],
|
|
87
|
+
* ...
|
|
88
|
+
* });
|
|
89
|
+
*
|
|
90
|
+
* const droidType = new GraphQLObjectType({
|
|
91
|
+
* name: 'Droid',
|
|
92
|
+
* interfaces: [characterInterface],
|
|
93
|
+
* ...
|
|
94
|
+
* });
|
|
95
|
+
*
|
|
96
|
+
* const schema = new GraphQLSchema({
|
|
97
|
+
* query: new GraphQLObjectType({
|
|
98
|
+
* name: 'Query',
|
|
99
|
+
* fields: {
|
|
100
|
+
* hero: { type: characterInterface, ... },
|
|
101
|
+
* }
|
|
102
|
+
* }),
|
|
103
|
+
* ...
|
|
104
|
+
* // Since this schema references only the `Character` interface it's
|
|
105
|
+
* // necessary to explicitly list the types that implement it if
|
|
106
|
+
* // you want them to be included in the final schema.
|
|
107
|
+
* types: [humanType, droidType],
|
|
108
|
+
* })
|
|
109
|
+
*
|
|
75
110
|
* Note: If an array of `directives` are provided to GraphQLSchema, that will be
|
|
76
111
|
* the exact list of directives represented and allowed. If `directives` is not
|
|
77
112
|
* provided then a default set of the specified directives (e.g. @include and
|
|
@@ -222,10 +257,10 @@ export class GraphQLSchema {
|
|
|
222
257
|
|
|
223
258
|
if (!possibleTypeMap[abstractType.name]) {
|
|
224
259
|
const possibleTypes = this.getPossibleTypes(abstractType);
|
|
225
|
-
possibleTypeMap[abstractType.name] = possibleTypes.reduce(
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
);
|
|
260
|
+
possibleTypeMap[abstractType.name] = possibleTypes.reduce((map, type) => {
|
|
261
|
+
map[type.name] = true;
|
|
262
|
+
return map;
|
|
263
|
+
}, Object.create(null));
|
|
229
264
|
}
|
|
230
265
|
|
|
231
266
|
return Boolean(possibleTypeMap[abstractType.name][possibleType.name]);
|
|
@@ -238,6 +273,27 @@ export class GraphQLSchema {
|
|
|
238
273
|
getDirective(name: string): ?GraphQLDirective {
|
|
239
274
|
return find(this.getDirectives(), directive => directive.name === name);
|
|
240
275
|
}
|
|
276
|
+
|
|
277
|
+
toConfig(): {|
|
|
278
|
+
...GraphQLSchemaConfig,
|
|
279
|
+
types: Array<GraphQLNamedType>,
|
|
280
|
+
directives: Array<GraphQLDirective>,
|
|
281
|
+
extensionASTNodes: $ReadOnlyArray<SchemaExtensionNode>,
|
|
282
|
+
assumeValid: boolean,
|
|
283
|
+
allowedLegacyNames: $ReadOnlyArray<string>,
|
|
284
|
+
|} {
|
|
285
|
+
return {
|
|
286
|
+
types: objectValues(this.getTypeMap()),
|
|
287
|
+
directives: this.getDirectives().slice(),
|
|
288
|
+
query: this.getQueryType(),
|
|
289
|
+
mutation: this.getMutationType(),
|
|
290
|
+
subscription: this.getSubscriptionType(),
|
|
291
|
+
astNode: this.astNode,
|
|
292
|
+
extensionASTNodes: this.extensionASTNodes || [],
|
|
293
|
+
assumeValid: this.__validationErrors !== undefined,
|
|
294
|
+
allowedLegacyNames: this.__allowedLegacyNames,
|
|
295
|
+
};
|
|
296
|
+
}
|
|
241
297
|
}
|
|
242
298
|
|
|
243
299
|
// Conditionally apply `[Symbol.toStringTag]` if `Symbol`s are supported
|
|
@@ -286,7 +342,7 @@ function typeMapReducer(map: TypeMap, type: ?GraphQLType): TypeMap {
|
|
|
286
342
|
if (map[type.name]) {
|
|
287
343
|
invariant(
|
|
288
344
|
map[type.name] === type,
|
|
289
|
-
'Schema must contain
|
|
345
|
+
'Schema must contain uniquely named types but contains multiple ' +
|
|
290
346
|
`types named "${type.name}".`,
|
|
291
347
|
);
|
|
292
348
|
return map;
|
package/type/schema.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Copyright (c)
|
|
4
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
5
5
|
*
|
|
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.
|
|
@@ -39,6 +39,43 @@ export function assertSchema(schema) {
|
|
|
39
39
|
* mutation: MyAppMutationRootType,
|
|
40
40
|
* })
|
|
41
41
|
*
|
|
42
|
+
* Note: When the schema is constructed, by default only the types that are
|
|
43
|
+
* reachable by traversing the root types are included, other types must be
|
|
44
|
+
* explicitly referenced.
|
|
45
|
+
*
|
|
46
|
+
* Example:
|
|
47
|
+
*
|
|
48
|
+
* const characterInterface = new GraphQLInterfaceType({
|
|
49
|
+
* name: 'Character',
|
|
50
|
+
* ...
|
|
51
|
+
* });
|
|
52
|
+
*
|
|
53
|
+
* const humanType = new GraphQLObjectType({
|
|
54
|
+
* name: 'Human',
|
|
55
|
+
* interfaces: [characterInterface],
|
|
56
|
+
* ...
|
|
57
|
+
* });
|
|
58
|
+
*
|
|
59
|
+
* const droidType = new GraphQLObjectType({
|
|
60
|
+
* name: 'Droid',
|
|
61
|
+
* interfaces: [characterInterface],
|
|
62
|
+
* ...
|
|
63
|
+
* });
|
|
64
|
+
*
|
|
65
|
+
* const schema = new GraphQLSchema({
|
|
66
|
+
* query: new GraphQLObjectType({
|
|
67
|
+
* name: 'Query',
|
|
68
|
+
* fields: {
|
|
69
|
+
* hero: { type: characterInterface, ... },
|
|
70
|
+
* }
|
|
71
|
+
* }),
|
|
72
|
+
* ...
|
|
73
|
+
* // Since this schema references only the `Character` interface it's
|
|
74
|
+
* // necessary to explicitly list the types that implement it if
|
|
75
|
+
* // you want them to be included in the final schema.
|
|
76
|
+
* types: [humanType, droidType],
|
|
77
|
+
* })
|
|
78
|
+
*
|
|
42
79
|
* Note: If an array of `directives` are provided to GraphQLSchema, that will be
|
|
43
80
|
* the exact list of directives represented and allowed. If `directives` is not
|
|
44
81
|
* provided then a default set of the specified directives (e.g. @include and
|
|
@@ -196,7 +233,8 @@ function () {
|
|
|
196
233
|
if (!possibleTypeMap[abstractType.name]) {
|
|
197
234
|
var possibleTypes = this.getPossibleTypes(abstractType);
|
|
198
235
|
possibleTypeMap[abstractType.name] = possibleTypes.reduce(function (map, type) {
|
|
199
|
-
|
|
236
|
+
map[type.name] = true;
|
|
237
|
+
return map;
|
|
200
238
|
}, Object.create(null));
|
|
201
239
|
}
|
|
202
240
|
|
|
@@ -213,6 +251,20 @@ function () {
|
|
|
213
251
|
});
|
|
214
252
|
};
|
|
215
253
|
|
|
254
|
+
_proto.toConfig = function toConfig() {
|
|
255
|
+
return {
|
|
256
|
+
types: objectValues(this.getTypeMap()),
|
|
257
|
+
directives: this.getDirectives().slice(),
|
|
258
|
+
query: this.getQueryType(),
|
|
259
|
+
mutation: this.getMutationType(),
|
|
260
|
+
subscription: this.getSubscriptionType(),
|
|
261
|
+
astNode: this.astNode,
|
|
262
|
+
extensionASTNodes: this.extensionASTNodes || [],
|
|
263
|
+
assumeValid: this.__validationErrors !== undefined,
|
|
264
|
+
allowedLegacyNames: this.__allowedLegacyNames
|
|
265
|
+
};
|
|
266
|
+
};
|
|
267
|
+
|
|
216
268
|
return GraphQLSchema;
|
|
217
269
|
}(); // Conditionally apply `[Symbol.toStringTag]` if `Symbol`s are supported
|
|
218
270
|
|
|
@@ -228,7 +280,7 @@ function typeMapReducer(map, type) {
|
|
|
228
280
|
}
|
|
229
281
|
|
|
230
282
|
if (map[type.name]) {
|
|
231
|
-
!(map[type.name] === type) ? invariant(0, 'Schema must contain
|
|
283
|
+
!(map[type.name] === type) ? invariant(0, 'Schema must contain uniquely named types but contains multiple ' + "types named \"".concat(type.name, "\".")) : void 0;
|
|
232
284
|
return map;
|
|
233
285
|
}
|
|
234
286
|
|
|
@@ -315,4 +367,4 @@ function typeMapDirectiveReducer(map, directive) {
|
|
|
315
367
|
return directive.args.reduce(function (_map, arg) {
|
|
316
368
|
return typeMapReducer(_map, arg.type);
|
|
317
369
|
}, map);
|
|
318
|
-
}
|
|
370
|
+
}
|
package/type/validate.js
CHANGED
|
@@ -8,6 +8,8 @@ exports.assertValidSchema = assertValidSchema;
|
|
|
8
8
|
|
|
9
9
|
var _find = _interopRequireDefault(require("../polyfills/find"));
|
|
10
10
|
|
|
11
|
+
var _flatMap = _interopRequireDefault(require("../polyfills/flatMap"));
|
|
12
|
+
|
|
11
13
|
var _objectValues = _interopRequireDefault(require("../polyfills/objectValues"));
|
|
12
14
|
|
|
13
15
|
var _objectEntries = _interopRequireDefault(require("../polyfills/objectEntries"));
|
|
@@ -31,7 +33,7 @@ var _typeComparators = require("../utilities/typeComparators");
|
|
|
31
33
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
32
34
|
|
|
33
35
|
/**
|
|
34
|
-
* Copyright (c)
|
|
36
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
35
37
|
*
|
|
36
38
|
* This source code is licensed under the MIT license found in the
|
|
37
39
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -92,7 +94,7 @@ function () {
|
|
|
92
94
|
var _proto = SchemaValidationContext.prototype;
|
|
93
95
|
|
|
94
96
|
_proto.reportError = function reportError(message, nodes) {
|
|
95
|
-
var _nodes =
|
|
97
|
+
var _nodes = Array.isArray(nodes) ? nodes.filter(Boolean) : nodes;
|
|
96
98
|
|
|
97
99
|
this.addError(new _GraphQLError.GraphQLError(message, _nodes));
|
|
98
100
|
};
|
|
@@ -674,39 +676,9 @@ function getAllNodes(object) {
|
|
|
674
676
|
}
|
|
675
677
|
|
|
676
678
|
function getAllSubNodes(object, getter) {
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
var _iteratorError14 = undefined;
|
|
681
|
-
|
|
682
|
-
try {
|
|
683
|
-
for (var _iterator14 = getAllNodes(object)[Symbol.iterator](), _step14; !(_iteratorNormalCompletion14 = (_step14 = _iterator14.next()).done); _iteratorNormalCompletion14 = true) {
|
|
684
|
-
var astNode = _step14.value;
|
|
685
|
-
|
|
686
|
-
if (astNode) {
|
|
687
|
-
var subNodes = getter(astNode);
|
|
688
|
-
|
|
689
|
-
if (subNodes) {
|
|
690
|
-
result = result.concat(subNodes);
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
} catch (err) {
|
|
695
|
-
_didIteratorError14 = true;
|
|
696
|
-
_iteratorError14 = err;
|
|
697
|
-
} finally {
|
|
698
|
-
try {
|
|
699
|
-
if (!_iteratorNormalCompletion14 && _iterator14.return != null) {
|
|
700
|
-
_iterator14.return();
|
|
701
|
-
}
|
|
702
|
-
} finally {
|
|
703
|
-
if (_didIteratorError14) {
|
|
704
|
-
throw _iteratorError14;
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
return result;
|
|
679
|
+
return (0, _flatMap.default)(getAllNodes(object), function (item) {
|
|
680
|
+
return getter(item) || [];
|
|
681
|
+
});
|
|
710
682
|
}
|
|
711
683
|
|
|
712
684
|
function getImplementsInterfaceNode(type, iface) {
|
|
@@ -743,29 +715,29 @@ function getAllFieldArgNodes(type, fieldName, argName) {
|
|
|
743
715
|
var fieldNode = getFieldNode(type, fieldName);
|
|
744
716
|
|
|
745
717
|
if (fieldNode && fieldNode.arguments) {
|
|
746
|
-
var
|
|
747
|
-
var
|
|
748
|
-
var
|
|
718
|
+
var _iteratorNormalCompletion14 = true;
|
|
719
|
+
var _didIteratorError14 = false;
|
|
720
|
+
var _iteratorError14 = undefined;
|
|
749
721
|
|
|
750
722
|
try {
|
|
751
|
-
for (var
|
|
752
|
-
var node =
|
|
723
|
+
for (var _iterator14 = fieldNode.arguments[Symbol.iterator](), _step14; !(_iteratorNormalCompletion14 = (_step14 = _iterator14.next()).done); _iteratorNormalCompletion14 = true) {
|
|
724
|
+
var node = _step14.value;
|
|
753
725
|
|
|
754
726
|
if (node.name.value === argName) {
|
|
755
727
|
argNodes.push(node);
|
|
756
728
|
}
|
|
757
729
|
}
|
|
758
730
|
} catch (err) {
|
|
759
|
-
|
|
760
|
-
|
|
731
|
+
_didIteratorError14 = true;
|
|
732
|
+
_iteratorError14 = err;
|
|
761
733
|
} finally {
|
|
762
734
|
try {
|
|
763
|
-
if (!
|
|
764
|
-
|
|
735
|
+
if (!_iteratorNormalCompletion14 && _iterator14.return != null) {
|
|
736
|
+
_iterator14.return();
|
|
765
737
|
}
|
|
766
738
|
} finally {
|
|
767
|
-
if (
|
|
768
|
-
throw
|
|
739
|
+
if (_didIteratorError14) {
|
|
740
|
+
throw _iteratorError14;
|
|
769
741
|
}
|
|
770
742
|
}
|
|
771
743
|
}
|
|
@@ -798,4 +770,4 @@ function getUnionMemberTypeNodes(union, typeName) {
|
|
|
798
770
|
}).filter(function (typeNode) {
|
|
799
771
|
return typeNode.name.value === typeName;
|
|
800
772
|
});
|
|
801
|
-
}
|
|
773
|
+
}
|