graphql 14.0.2 → 14.2.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 +5 -5
- package/codecov.yml +14 -0
- package/error/GraphQLError.js +2 -2
- package/error/GraphQLError.js.flow +4 -4
- package/error/GraphQLError.mjs +2 -2
- package/error/formatError.js +2 -2
- package/error/formatError.js.flow +1 -1
- package/error/formatError.mjs +2 -2
- package/error/index.js.flow +1 -1
- package/error/index.mjs +2 -2
- package/error/locatedError.js +2 -2
- package/error/locatedError.js.flow +1 -1
- package/error/locatedError.mjs +2 -2
- package/error/printError.js +2 -2
- package/error/printError.js.flow +1 -1
- package/error/printError.mjs +2 -2
- package/error/syntaxError.js +2 -2
- package/error/syntaxError.js.flow +1 -1
- package/error/syntaxError.mjs +2 -2
- package/execution/execute.js +20 -11
- package/execution/execute.js.flow +41 -27
- package/execution/execute.mjs +19 -13
- package/execution/index.js +6 -0
- package/execution/index.js.flow +7 -2
- package/execution/index.mjs +3 -3
- package/execution/values.js +10 -10
- package/execution/values.js.flow +8 -8
- package/execution/values.mjs +9 -9
- package/graphql.js +8 -8
- package/graphql.js.flow +18 -4
- package/graphql.mjs +8 -8
- package/index.js +18 -0
- package/index.js.flow +4 -1
- package/index.mjs +4 -4
- package/jsutils/ObjMap.js.flow +1 -1
- package/jsutils/{MaybePromise.js → PromiseOrValue.js} +0 -0
- package/jsutils/{MaybePromise.js.flow → PromiseOrValue.js.flow} +2 -2
- package/jsutils/{MaybePromise.mjs → PromiseOrValue.mjs} +0 -0
- package/jsutils/dedent.js +2 -2
- package/jsutils/dedent.js.flow +1 -1
- package/jsutils/dedent.mjs +2 -2
- package/jsutils/defineToJSON.js +18 -7
- package/jsutils/defineToJSON.js.flow +15 -6
- package/jsutils/defineToJSON.mjs +15 -7
- package/jsutils/defineToStringTag.js +6 -6
- package/jsutils/defineToStringTag.js.flow +4 -4
- package/jsutils/defineToStringTag.mjs +5 -5
- package/jsutils/inspect.js +109 -23
- package/jsutils/inspect.js.flow +112 -14
- package/jsutils/inspect.mjs +108 -17
- package/jsutils/instanceOf.js +2 -2
- package/jsutils/instanceOf.js.flow +1 -1
- package/jsutils/instanceOf.mjs +2 -2
- package/jsutils/invariant.js +2 -2
- package/jsutils/invariant.js.flow +1 -1
- package/jsutils/invariant.mjs +2 -2
- 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 +2 -2
- package/jsutils/keyMap.js.flow +1 -1
- package/jsutils/keyMap.mjs +2 -2
- package/jsutils/keyValMap.js +2 -2
- package/jsutils/keyValMap.js.flow +1 -1
- package/jsutils/keyValMap.mjs +2 -2
- package/jsutils/mapValue.js +54 -0
- package/jsutils/mapValue.js.flow +27 -0
- package/jsutils/mapValue.mjs +44 -0
- package/jsutils/memoize3.js +2 -2
- package/jsutils/memoize3.js.flow +1 -1
- package/jsutils/memoize3.mjs +2 -2
- package/jsutils/nodejsCustomInspectSymbol.js +18 -0
- package/jsutils/nodejsCustomInspectSymbol.js.flow +15 -0
- package/jsutils/nodejsCustomInspectSymbol.mjs +10 -0
- package/jsutils/orList.js +18 -5
- package/jsutils/orList.js.flow +14 -8
- package/jsutils/orList.mjs +15 -5
- package/jsutils/promiseForObject.js +2 -2
- package/jsutils/promiseForObject.js.flow +1 -1
- 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.flow +1 -1
- package/language/{blockStringValue.mjs → blockString.js} +39 -3
- package/language/{blockStringValue.js.flow → blockString.js.flow} +31 -2
- package/language/{blockStringValue.js → blockString.mjs} +31 -10
- package/language/directiveLocation.js +2 -2
- package/language/directiveLocation.js.flow +1 -1
- package/language/directiveLocation.mjs +2 -2
- package/language/index.js.flow +1 -1
- package/language/index.mjs +2 -2
- package/language/kinds.js +2 -2
- package/language/kinds.js.flow +1 -1
- package/language/kinds.mjs +2 -2
- package/language/lexer.js +60 -46
- package/language/lexer.js.flow +71 -69
- package/language/lexer.mjs +58 -45
- package/language/location.js +2 -2
- package/language/location.js.flow +1 -1
- package/language/location.mjs +2 -2
- package/language/parser.js +84 -83
- package/language/parser.js.flow +85 -94
- package/language/parser.mjs +83 -83
- package/language/predicates.js +2 -2
- package/language/predicates.js.flow +1 -1
- package/language/predicates.mjs +2 -2
- package/language/printer.js +15 -17
- package/language/printer.js.flow +21 -20
- package/language/printer.mjs +14 -17
- package/language/source.js +8 -7
- package/language/source.js.flow +1 -1
- package/language/source.mjs +2 -10
- package/language/visitor.js +7 -6
- package/language/visitor.js.flow +3 -5
- package/language/visitor.mjs +7 -6
- package/package.json +5 -2
- package/polyfills/find.js +31 -0
- package/polyfills/find.js.flow +29 -0
- package/polyfills/find.mjs +23 -0
- package/polyfills/flatMap.js +38 -0
- package/polyfills/flatMap.js.flow +34 -0
- package/polyfills/flatMap.mjs +30 -0
- package/{jsutils → polyfills}/isFinite.js +2 -2
- package/{jsutils → polyfills}/isFinite.js.flow +1 -1
- package/{jsutils → polyfills}/isFinite.mjs +2 -2
- package/{jsutils → polyfills}/isInteger.js +2 -2
- package/{jsutils → polyfills}/isInteger.js.flow +1 -1
- package/{jsutils → polyfills}/isInteger.mjs +2 -2
- package/polyfills/objectEntries.js +26 -0
- package/polyfills/objectEntries.js.flow +19 -0
- package/polyfills/objectEntries.mjs +18 -0
- package/{jsutils → polyfills}/objectValues.js +2 -2
- package/{jsutils → polyfills}/objectValues.js.flow +2 -2
- package/{jsutils → polyfills}/objectValues.mjs +2 -2
- package/subscription/asyncIteratorReject.js.flow +1 -1
- package/subscription/asyncIteratorReject.mjs +2 -2
- package/subscription/index.js.flow +1 -1
- package/subscription/index.mjs +2 -2
- package/subscription/mapAsyncIterator.js.flow +5 -5
- package/subscription/mapAsyncIterator.mjs +2 -2
- package/subscription/subscribe.js +2 -2
- package/subscription/subscribe.js.flow +1 -1
- package/subscription/subscribe.mjs +2 -2
- package/type/definition.js +161 -138
- package/type/definition.js.flow +193 -57
- package/type/definition.mjs +158 -140
- package/type/directives.js +35 -29
- package/type/directives.js.flow +39 -21
- package/type/directives.mjs +34 -31
- package/type/index.js +12 -0
- package/type/index.js.flow +5 -1
- package/type/index.mjs +6 -4
- package/type/introspection.js +11 -7
- package/type/introspection.js.flow +11 -8
- package/type/introspection.mjs +11 -7
- package/type/scalars.js +45 -34
- package/type/scalars.js.flow +41 -27
- package/type/scalars.mjs +45 -27
- package/type/schema.js +134 -88
- package/type/schema.js.flow +77 -11
- package/type/schema.mjs +132 -88
- package/type/validate.js +152 -187
- package/type/validate.js.flow +12 -61
- package/type/validate.mjs +143 -188
- package/utilities/TypeInfo.js +10 -23
- package/utilities/TypeInfo.js.flow +2 -2
- package/utilities/TypeInfo.mjs +3 -25
- package/utilities/assertValidName.js +2 -2
- package/utilities/assertValidName.js.flow +1 -1
- package/utilities/assertValidName.mjs +2 -2
- package/utilities/astFromValue.js +7 -6
- package/utilities/astFromValue.js.flow +7 -6
- package/utilities/astFromValue.mjs +9 -8
- package/utilities/buildASTSchema.js +213 -197
- package/utilities/buildASTSchema.js.flow +163 -173
- package/utilities/buildASTSchema.mjs +203 -198
- package/utilities/buildClientSchema.js +39 -47
- package/utilities/buildClientSchema.js.flow +49 -58
- package/utilities/buildClientSchema.mjs +38 -46
- package/utilities/coerceValue.js +41 -21
- package/utilities/coerceValue.js.flow +44 -49
- package/utilities/coerceValue.mjs +42 -23
- package/utilities/concatAST.js +9 -13
- package/utilities/concatAST.js.flow +3 -9
- package/utilities/concatAST.mjs +6 -13
- package/utilities/extendSchema.js +256 -630
- package/utilities/extendSchema.js.flow +190 -426
- package/utilities/extendSchema.mjs +256 -631
- package/utilities/findBreakingChanges.js +8 -6
- package/utilities/findBreakingChanges.js.flow +4 -3
- package/utilities/findBreakingChanges.mjs +7 -6
- package/utilities/findDeprecatedUsages.js +4 -4
- package/utilities/findDeprecatedUsages.js.flow +3 -3
- package/utilities/findDeprecatedUsages.mjs +4 -4
- package/utilities/getOperationAST.js +2 -2
- package/utilities/getOperationAST.js.flow +1 -1
- package/utilities/getOperationAST.mjs +2 -2
- package/utilities/getOperationRootType.js +6 -6
- package/utilities/getOperationRootType.js.flow +9 -7
- package/utilities/getOperationRootType.mjs +6 -6
- package/utilities/index.js.flow +1 -1
- package/utilities/index.mjs +2 -2
- package/utilities/introspectionFromSchema.js +2 -2
- package/utilities/introspectionFromSchema.js.flow +1 -1
- package/utilities/introspectionFromSchema.mjs +2 -2
- package/utilities/introspectionQuery.js +2 -2
- package/utilities/introspectionQuery.js.flow +1 -1
- package/utilities/introspectionQuery.mjs +2 -2
- package/utilities/isValidJSValue.js +4 -2
- package/utilities/isValidJSValue.js.flow +2 -1
- package/utilities/isValidJSValue.mjs +4 -2
- package/utilities/isValidLiteralValue.js +2 -2
- package/utilities/isValidLiteralValue.js.flow +1 -1
- package/utilities/isValidLiteralValue.mjs +2 -2
- package/utilities/lexicographicSortSchema.js +86 -124
- package/utilities/lexicographicSortSchema.js.flow +68 -96
- package/utilities/lexicographicSortSchema.mjs +86 -124
- package/utilities/schemaPrinter.js +47 -73
- package/utilities/schemaPrinter.js.flow +62 -111
- package/utilities/schemaPrinter.mjs +46 -73
- package/utilities/separateOperations.js +11 -10
- package/utilities/separateOperations.js.flow +1 -1
- package/utilities/separateOperations.mjs +11 -10
- package/utilities/typeComparators.js +2 -2
- package/utilities/typeComparators.js.flow +1 -1
- package/utilities/typeComparators.mjs +2 -2
- package/utilities/typeFromAST.js +9 -4
- package/utilities/typeFromAST.js.flow +5 -2
- package/utilities/typeFromAST.mjs +6 -4
- package/utilities/valueFromAST.js +9 -6
- package/utilities/valueFromAST.js.flow +5 -3
- package/utilities/valueFromAST.mjs +7 -5
- package/utilities/valueFromASTUntyped.js +7 -4
- package/utilities/valueFromASTUntyped.js.flow +5 -2
- package/utilities/valueFromASTUntyped.mjs +6 -4
- package/validation/ValidationContext.js +57 -82
- package/validation/ValidationContext.js.flow +53 -50
- package/validation/ValidationContext.mjs +53 -78
- package/validation/index.js.flow +1 -1
- package/validation/index.mjs +2 -2
- package/validation/rules/ExecutableDefinitions.js +3 -3
- package/validation/rules/ExecutableDefinitions.js.flow +3 -3
- package/validation/rules/ExecutableDefinitions.mjs +3 -3
- package/validation/rules/FieldsOnCorrectType.js +3 -3
- package/validation/rules/FieldsOnCorrectType.js.flow +2 -2
- package/validation/rules/FieldsOnCorrectType.mjs +3 -3
- package/validation/rules/FragmentsOnCompositeTypes.js +4 -4
- package/validation/rules/FragmentsOnCompositeTypes.js.flow +3 -3
- package/validation/rules/FragmentsOnCompositeTypes.mjs +4 -4
- package/validation/rules/KnownArgumentNames.js.flow +1 -1
- package/validation/rules/KnownArgumentNames.mjs +2 -2
- package/validation/rules/KnownDirectives.js +4 -4
- package/validation/rules/KnownDirectives.js.flow +5 -4
- package/validation/rules/KnownDirectives.mjs +4 -4
- package/validation/rules/KnownFragmentNames.js +3 -3
- package/validation/rules/KnownFragmentNames.js.flow +2 -2
- package/validation/rules/KnownFragmentNames.mjs +3 -3
- package/validation/rules/KnownTypeNames.js +60 -22
- package/validation/rules/KnownTypeNames.js.flow +55 -21
- package/validation/rules/KnownTypeNames.mjs +57 -22
- package/validation/rules/LoneAnonymousOperation.js +3 -3
- package/validation/rules/LoneAnonymousOperation.js.flow +2 -2
- package/validation/rules/LoneAnonymousOperation.mjs +3 -3
- package/validation/rules/LoneSchemaDefinition.js +2 -2
- package/validation/rules/LoneSchemaDefinition.js.flow +1 -1
- package/validation/rules/LoneSchemaDefinition.mjs +2 -2
- package/validation/rules/NoFragmentCycles.js +2 -2
- package/validation/rules/NoFragmentCycles.js.flow +3 -3
- package/validation/rules/NoFragmentCycles.mjs +2 -2
- package/validation/rules/NoUndefinedVariables.js +2 -2
- package/validation/rules/NoUndefinedVariables.js.flow +1 -1
- package/validation/rules/NoUndefinedVariables.mjs +2 -2
- package/validation/rules/NoUnusedFragments.js +10 -7
- package/validation/rules/NoUnusedFragments.js.flow +4 -4
- package/validation/rules/NoUnusedFragments.mjs +10 -7
- package/validation/rules/NoUnusedVariables.js +7 -5
- package/validation/rules/NoUnusedVariables.js.flow +4 -3
- package/validation/rules/NoUnusedVariables.mjs +7 -5
- package/validation/rules/OverlappingFieldsCanBeMerged.js +58 -33
- package/validation/rules/OverlappingFieldsCanBeMerged.js.flow +4 -4
- package/validation/rules/OverlappingFieldsCanBeMerged.mjs +50 -34
- package/validation/rules/PossibleFragmentSpreads.js +4 -4
- package/validation/rules/PossibleFragmentSpreads.js.flow +3 -3
- package/validation/rules/PossibleFragmentSpreads.mjs +4 -4
- package/validation/rules/PossibleTypeExtensions.js +158 -0
- package/validation/rules/PossibleTypeExtensions.js.flow +160 -0
- package/validation/rules/PossibleTypeExtensions.mjs +146 -0
- package/validation/rules/ProvidedRequiredArguments.js +3 -3
- package/validation/rules/ProvidedRequiredArguments.js.flow +4 -4
- package/validation/rules/ProvidedRequiredArguments.mjs +5 -5
- package/validation/rules/ScalarLeafs.js +4 -4
- package/validation/rules/ScalarLeafs.js.flow +3 -3
- package/validation/rules/ScalarLeafs.mjs +4 -4
- package/validation/rules/SingleFieldSubscriptions.js +2 -2
- package/validation/rules/SingleFieldSubscriptions.js.flow +1 -1
- package/validation/rules/SingleFieldSubscriptions.mjs +2 -2
- package/validation/rules/UniqueArgumentNames.js +2 -2
- package/validation/rules/UniqueArgumentNames.js.flow +1 -1
- package/validation/rules/UniqueArgumentNames.mjs +2 -2
- package/validation/rules/UniqueDirectiveNames.js +55 -0
- package/validation/rules/UniqueDirectiveNames.js.flow +64 -0
- package/validation/rules/UniqueDirectiveNames.mjs +43 -0
- package/validation/rules/UniqueDirectivesPerLocation.js +2 -2
- package/validation/rules/UniqueDirectivesPerLocation.js.flow +1 -1
- package/validation/rules/UniqueDirectivesPerLocation.mjs +2 -2
- package/validation/rules/UniqueEnumValueNames.js +90 -0
- package/validation/rules/UniqueEnumValueNames.js.flow +85 -0
- package/validation/rules/UniqueEnumValueNames.mjs +77 -0
- package/validation/rules/UniqueFieldDefinitionNames.js +101 -0
- package/validation/rules/UniqueFieldDefinitionNames.js.flow +99 -0
- package/validation/rules/UniqueFieldDefinitionNames.mjs +88 -0
- package/validation/rules/UniqueFragmentNames.js +2 -2
- package/validation/rules/UniqueFragmentNames.js.flow +1 -1
- package/validation/rules/UniqueFragmentNames.mjs +2 -2
- package/validation/rules/UniqueInputFieldNames.js +2 -4
- package/validation/rules/UniqueInputFieldNames.js.flow +1 -2
- package/validation/rules/UniqueInputFieldNames.mjs +2 -4
- package/validation/rules/UniqueOperationNames.js +2 -2
- package/validation/rules/UniqueOperationNames.js.flow +1 -1
- package/validation/rules/UniqueOperationNames.mjs +2 -2
- package/validation/rules/UniqueOperationTypes.js +85 -0
- package/validation/rules/UniqueOperationTypes.js.flow +76 -0
- package/validation/rules/UniqueOperationTypes.mjs +73 -0
- package/validation/rules/UniqueTypeNames.js +62 -0
- package/validation/rules/UniqueTypeNames.js.flow +67 -0
- package/validation/rules/UniqueTypeNames.mjs +50 -0
- package/validation/rules/UniqueVariableNames.js +2 -2
- package/validation/rules/UniqueVariableNames.js.flow +1 -1
- package/validation/rules/UniqueVariableNames.mjs +2 -2
- package/validation/rules/ValuesOfCorrectType.js +30 -14
- package/validation/rules/ValuesOfCorrectType.js.flow +5 -6
- package/validation/rules/ValuesOfCorrectType.mjs +29 -14
- package/validation/rules/VariablesAreInputTypes.js +3 -3
- package/validation/rules/VariablesAreInputTypes.js.flow +2 -2
- package/validation/rules/VariablesAreInputTypes.mjs +3 -3
- package/validation/rules/VariablesInAllowedPosition.js +5 -5
- package/validation/rules/VariablesInAllowedPosition.js.flow +1 -1
- package/validation/rules/VariablesInAllowedPosition.mjs +5 -5
- package/validation/specifiedRules.js +15 -3
- package/validation/specifiedRules.js.flow +14 -1
- package/validation/specifiedRules.mjs +9 -3
- package/validation/validate.js +2 -2
- package/validation/validate.js.flow +1 -1
- package/validation/validate.mjs +2 -2
- package/jsutils/find.js +0 -22
- package/jsutils/find.js.flow +0 -19
- package/jsutils/find.mjs +0 -15
package/type/definition.mjs
CHANGED
|
@@ -5,19 +5,22 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
5
5
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Copyright (c)
|
|
8
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
9
9
|
*
|
|
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
|
+
*
|
|
14
14
|
*/
|
|
15
|
+
import objectEntries from '../polyfills/objectEntries';
|
|
15
16
|
import defineToJSON from '../jsutils/defineToJSON';
|
|
16
17
|
import defineToStringTag from '../jsutils/defineToStringTag';
|
|
17
18
|
import instanceOf from '../jsutils/instanceOf';
|
|
18
19
|
import inspect from '../jsutils/inspect';
|
|
19
20
|
import invariant from '../jsutils/invariant';
|
|
20
21
|
import keyMap from '../jsutils/keyMap';
|
|
22
|
+
import keyValMap from '../jsutils/keyValMap';
|
|
23
|
+
import mapValue from '../jsutils/mapValue';
|
|
21
24
|
import { Kind } from '../language/kinds';
|
|
22
25
|
import { valueFromASTUntyped } from '../utilities/valueFromASTUntyped';
|
|
23
26
|
export function isType(type) {
|
|
@@ -180,8 +183,10 @@ export function GraphQLList(ofType) {
|
|
|
180
183
|
|
|
181
184
|
GraphQLList.prototype.toString = function toString() {
|
|
182
185
|
return '[' + String(this.ofType) + ']';
|
|
183
|
-
};
|
|
186
|
+
}; // Conditionally apply `[Symbol.toStringTag]` if `Symbol`s are supported
|
|
184
187
|
|
|
188
|
+
|
|
189
|
+
defineToStringTag(GraphQLList);
|
|
185
190
|
defineToJSON(GraphQLList);
|
|
186
191
|
/**
|
|
187
192
|
* Non-Null Type Wrapper
|
|
@@ -215,8 +220,10 @@ export function GraphQLNonNull(ofType) {
|
|
|
215
220
|
|
|
216
221
|
GraphQLNonNull.prototype.toString = function toString() {
|
|
217
222
|
return String(this.ofType) + '!';
|
|
218
|
-
};
|
|
223
|
+
}; // Conditionally apply `[Symbol.toStringTag]` if `Symbol`s are supported
|
|
224
|
+
|
|
219
225
|
|
|
226
|
+
defineToStringTag(GraphQLNonNull);
|
|
220
227
|
defineToJSON(GraphQLNonNull);
|
|
221
228
|
/**
|
|
222
229
|
* These types wrap and modify other types
|
|
@@ -279,8 +286,13 @@ export function getNamedType(type) {
|
|
|
279
286
|
*/
|
|
280
287
|
|
|
281
288
|
function resolveThunk(thunk) {
|
|
289
|
+
// $FlowFixMe(>=0.90.0)
|
|
282
290
|
return typeof thunk === 'function' ? thunk() : thunk;
|
|
283
291
|
}
|
|
292
|
+
|
|
293
|
+
function undefineIfEmpty(arr) {
|
|
294
|
+
return arr && arr.length > 0 ? arr : undefined;
|
|
295
|
+
}
|
|
284
296
|
/**
|
|
285
297
|
* Scalar Type Definition
|
|
286
298
|
*
|
|
@@ -311,20 +323,6 @@ export var GraphQLScalarType =
|
|
|
311
323
|
/*#__PURE__*/
|
|
312
324
|
function () {
|
|
313
325
|
function GraphQLScalarType(config) {
|
|
314
|
-
_defineProperty(this, "name", void 0);
|
|
315
|
-
|
|
316
|
-
_defineProperty(this, "description", void 0);
|
|
317
|
-
|
|
318
|
-
_defineProperty(this, "serialize", void 0);
|
|
319
|
-
|
|
320
|
-
_defineProperty(this, "parseValue", void 0);
|
|
321
|
-
|
|
322
|
-
_defineProperty(this, "parseLiteral", void 0);
|
|
323
|
-
|
|
324
|
-
_defineProperty(this, "astNode", void 0);
|
|
325
|
-
|
|
326
|
-
_defineProperty(this, "extensionASTNodes", void 0);
|
|
327
|
-
|
|
328
326
|
this.name = config.name;
|
|
329
327
|
this.description = config.description;
|
|
330
328
|
this.serialize = config.serialize;
|
|
@@ -335,7 +333,7 @@ function () {
|
|
|
335
333
|
|
|
336
334
|
this.parseLiteral = config.parseLiteral || valueFromASTUntyped;
|
|
337
335
|
this.astNode = config.astNode;
|
|
338
|
-
this.extensionASTNodes = config.extensionASTNodes;
|
|
336
|
+
this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);
|
|
339
337
|
!(typeof config.name === 'string') ? invariant(0, 'Must provide name.') : void 0;
|
|
340
338
|
!(typeof config.serialize === 'function') ? invariant(0, "".concat(this.name, " must provide \"serialize\" function. If this custom Scalar ") + 'is also used as an input type, ensure "parseValue" and "parseLiteral" ' + 'functions are also provided.') : void 0;
|
|
341
339
|
|
|
@@ -346,6 +344,18 @@ function () {
|
|
|
346
344
|
|
|
347
345
|
var _proto = GraphQLScalarType.prototype;
|
|
348
346
|
|
|
347
|
+
_proto.toConfig = function toConfig() {
|
|
348
|
+
return {
|
|
349
|
+
name: this.name,
|
|
350
|
+
description: this.description,
|
|
351
|
+
serialize: this.serialize,
|
|
352
|
+
parseValue: this.parseValue,
|
|
353
|
+
parseLiteral: this.parseLiteral,
|
|
354
|
+
astNode: this.astNode,
|
|
355
|
+
extensionASTNodes: this.extensionASTNodes || []
|
|
356
|
+
};
|
|
357
|
+
};
|
|
358
|
+
|
|
349
359
|
_proto.toString = function toString() {
|
|
350
360
|
return this.name;
|
|
351
361
|
};
|
|
@@ -397,24 +407,10 @@ export var GraphQLObjectType =
|
|
|
397
407
|
/*#__PURE__*/
|
|
398
408
|
function () {
|
|
399
409
|
function GraphQLObjectType(config) {
|
|
400
|
-
_defineProperty(this, "name", void 0);
|
|
401
|
-
|
|
402
|
-
_defineProperty(this, "description", void 0);
|
|
403
|
-
|
|
404
|
-
_defineProperty(this, "astNode", void 0);
|
|
405
|
-
|
|
406
|
-
_defineProperty(this, "extensionASTNodes", void 0);
|
|
407
|
-
|
|
408
|
-
_defineProperty(this, "isTypeOf", void 0);
|
|
409
|
-
|
|
410
|
-
_defineProperty(this, "_fields", void 0);
|
|
411
|
-
|
|
412
|
-
_defineProperty(this, "_interfaces", void 0);
|
|
413
|
-
|
|
414
410
|
this.name = config.name;
|
|
415
411
|
this.description = config.description;
|
|
416
412
|
this.astNode = config.astNode;
|
|
417
|
-
this.extensionASTNodes = config.extensionASTNodes;
|
|
413
|
+
this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);
|
|
418
414
|
this.isTypeOf = config.isTypeOf;
|
|
419
415
|
this._fields = defineFieldMap.bind(undefined, config);
|
|
420
416
|
this._interfaces = defineInterfaces.bind(undefined, config);
|
|
@@ -440,6 +436,18 @@ function () {
|
|
|
440
436
|
return this._interfaces;
|
|
441
437
|
};
|
|
442
438
|
|
|
439
|
+
_proto2.toConfig = function toConfig() {
|
|
440
|
+
return {
|
|
441
|
+
name: this.name,
|
|
442
|
+
description: this.description,
|
|
443
|
+
isTypeOf: this.isTypeOf,
|
|
444
|
+
interfaces: this.getInterfaces(),
|
|
445
|
+
fields: fieldsToFieldsConfig(this.getFields()),
|
|
446
|
+
astNode: this.astNode,
|
|
447
|
+
extensionASTNodes: this.extensionASTNodes || []
|
|
448
|
+
};
|
|
449
|
+
};
|
|
450
|
+
|
|
443
451
|
_proto2.toString = function toString() {
|
|
444
452
|
return this.name;
|
|
445
453
|
};
|
|
@@ -459,54 +467,61 @@ function defineInterfaces(config) {
|
|
|
459
467
|
function defineFieldMap(config) {
|
|
460
468
|
var fieldMap = resolveThunk(config.fields) || {};
|
|
461
469
|
!isPlainObj(fieldMap) ? invariant(0, "".concat(config.name, " fields must be an object with field names as keys or a ") + 'function which returns such an object.') : void 0;
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
var _arr = Object.keys(fieldMap);
|
|
465
|
-
|
|
466
|
-
var _loop = function _loop() {
|
|
467
|
-
var fieldName = _arr[_i];
|
|
468
|
-
var fieldConfig = fieldMap[fieldName];
|
|
470
|
+
return mapValue(fieldMap, function (fieldConfig, fieldName) {
|
|
469
471
|
!isPlainObj(fieldConfig) ? invariant(0, "".concat(config.name, ".").concat(fieldName, " field config must be an object")) : void 0;
|
|
470
472
|
!!fieldConfig.hasOwnProperty('isDeprecated') ? invariant(0, "".concat(config.name, ".").concat(fieldName, " should provide \"deprecationReason\" ") + 'instead of "isDeprecated".') : void 0;
|
|
471
|
-
|
|
472
|
-
var
|
|
473
|
+
!(fieldConfig.resolve == null || typeof fieldConfig.resolve === 'function') ? invariant(0, "".concat(config.name, ".").concat(fieldName, " field resolver must be a function if ") + "provided, but got: ".concat(inspect(fieldConfig.resolve), ".")) : void 0;
|
|
474
|
+
var argsConfig = fieldConfig.args || {};
|
|
475
|
+
!isPlainObj(argsConfig) ? invariant(0, "".concat(config.name, ".").concat(fieldName, " args must be an object with argument ") + 'names as keys.') : void 0;
|
|
476
|
+
var args = objectEntries(argsConfig).map(function (_ref) {
|
|
477
|
+
var argName = _ref[0],
|
|
478
|
+
arg = _ref[1];
|
|
479
|
+
return {
|
|
480
|
+
name: argName,
|
|
481
|
+
description: arg.description === undefined ? null : arg.description,
|
|
482
|
+
type: arg.type,
|
|
483
|
+
defaultValue: arg.defaultValue,
|
|
484
|
+
astNode: arg.astNode
|
|
485
|
+
};
|
|
486
|
+
});
|
|
487
|
+
return _objectSpread({}, fieldConfig, {
|
|
473
488
|
isDeprecated: Boolean(fieldConfig.deprecationReason),
|
|
474
|
-
name: fieldName
|
|
489
|
+
name: fieldName,
|
|
490
|
+
args: args
|
|
475
491
|
});
|
|
476
|
-
|
|
477
|
-
!(field.resolve == null || typeof field.resolve === 'function') ? invariant(0, "".concat(config.name, ".").concat(fieldName, " field resolver must be a function if ") + "provided, but got: ".concat(inspect(field.resolve), ".")) : void 0;
|
|
478
|
-
var argsConfig = fieldConfig.args;
|
|
479
|
-
|
|
480
|
-
if (!argsConfig) {
|
|
481
|
-
field.args = [];
|
|
482
|
-
} else {
|
|
483
|
-
!isPlainObj(argsConfig) ? invariant(0, "".concat(config.name, ".").concat(fieldName, " args must be an object with argument ") + 'names as keys.') : void 0;
|
|
484
|
-
field.args = Object.keys(argsConfig).map(function (argName) {
|
|
485
|
-
var arg = argsConfig[argName];
|
|
486
|
-
return {
|
|
487
|
-
name: argName,
|
|
488
|
-
description: arg.description === undefined ? null : arg.description,
|
|
489
|
-
type: arg.type,
|
|
490
|
-
defaultValue: arg.defaultValue,
|
|
491
|
-
astNode: arg.astNode
|
|
492
|
-
};
|
|
493
|
-
});
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
resultFieldMap[fieldName] = field;
|
|
497
|
-
};
|
|
498
|
-
|
|
499
|
-
for (var _i = 0; _i < _arr.length; _i++) {
|
|
500
|
-
_loop();
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
return resultFieldMap;
|
|
492
|
+
});
|
|
504
493
|
}
|
|
505
494
|
|
|
506
495
|
function isPlainObj(obj) {
|
|
507
496
|
return obj && _typeof(obj) === 'object' && !Array.isArray(obj);
|
|
508
497
|
}
|
|
509
498
|
|
|
499
|
+
function fieldsToFieldsConfig(fields) {
|
|
500
|
+
return mapValue(fields, function (field) {
|
|
501
|
+
return {
|
|
502
|
+
type: field.type,
|
|
503
|
+
args: argsToArgsConfig(field.args),
|
|
504
|
+
resolve: field.resolve,
|
|
505
|
+
subscribe: field.subscribe,
|
|
506
|
+
deprecationReason: field.deprecationReason,
|
|
507
|
+
description: field.description,
|
|
508
|
+
astNode: field.astNode
|
|
509
|
+
};
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
export function argsToArgsConfig(args) {
|
|
514
|
+
return keyValMap(args, function (arg) {
|
|
515
|
+
return arg.name;
|
|
516
|
+
}, function (arg) {
|
|
517
|
+
return {
|
|
518
|
+
type: arg.type,
|
|
519
|
+
defaultValue: arg.defaultValue,
|
|
520
|
+
description: arg.description,
|
|
521
|
+
astNode: arg.astNode
|
|
522
|
+
};
|
|
523
|
+
});
|
|
524
|
+
}
|
|
510
525
|
export function isRequiredArgument(arg) {
|
|
511
526
|
return isNonNullType(arg.type) && arg.defaultValue === undefined;
|
|
512
527
|
}
|
|
@@ -533,22 +548,10 @@ export var GraphQLInterfaceType =
|
|
|
533
548
|
/*#__PURE__*/
|
|
534
549
|
function () {
|
|
535
550
|
function GraphQLInterfaceType(config) {
|
|
536
|
-
_defineProperty(this, "name", void 0);
|
|
537
|
-
|
|
538
|
-
_defineProperty(this, "description", void 0);
|
|
539
|
-
|
|
540
|
-
_defineProperty(this, "astNode", void 0);
|
|
541
|
-
|
|
542
|
-
_defineProperty(this, "extensionASTNodes", void 0);
|
|
543
|
-
|
|
544
|
-
_defineProperty(this, "resolveType", void 0);
|
|
545
|
-
|
|
546
|
-
_defineProperty(this, "_fields", void 0);
|
|
547
|
-
|
|
548
551
|
this.name = config.name;
|
|
549
552
|
this.description = config.description;
|
|
550
553
|
this.astNode = config.astNode;
|
|
551
|
-
this.extensionASTNodes = config.extensionASTNodes;
|
|
554
|
+
this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);
|
|
552
555
|
this.resolveType = config.resolveType;
|
|
553
556
|
this._fields = defineFieldMap.bind(undefined, config);
|
|
554
557
|
!(typeof config.name === 'string') ? invariant(0, 'Must provide name.') : void 0;
|
|
@@ -565,6 +568,17 @@ function () {
|
|
|
565
568
|
return this._fields;
|
|
566
569
|
};
|
|
567
570
|
|
|
571
|
+
_proto3.toConfig = function toConfig() {
|
|
572
|
+
return {
|
|
573
|
+
name: this.name,
|
|
574
|
+
description: this.description,
|
|
575
|
+
resolveType: this.resolveType,
|
|
576
|
+
fields: fieldsToFieldsConfig(this.getFields()),
|
|
577
|
+
astNode: this.astNode,
|
|
578
|
+
extensionASTNodes: this.extensionASTNodes || []
|
|
579
|
+
};
|
|
580
|
+
};
|
|
581
|
+
|
|
568
582
|
_proto3.toString = function toString() {
|
|
569
583
|
return this.name;
|
|
570
584
|
};
|
|
@@ -602,22 +616,10 @@ export var GraphQLUnionType =
|
|
|
602
616
|
/*#__PURE__*/
|
|
603
617
|
function () {
|
|
604
618
|
function GraphQLUnionType(config) {
|
|
605
|
-
_defineProperty(this, "name", void 0);
|
|
606
|
-
|
|
607
|
-
_defineProperty(this, "description", void 0);
|
|
608
|
-
|
|
609
|
-
_defineProperty(this, "astNode", void 0);
|
|
610
|
-
|
|
611
|
-
_defineProperty(this, "extensionASTNodes", void 0);
|
|
612
|
-
|
|
613
|
-
_defineProperty(this, "resolveType", void 0);
|
|
614
|
-
|
|
615
|
-
_defineProperty(this, "_types", void 0);
|
|
616
|
-
|
|
617
619
|
this.name = config.name;
|
|
618
620
|
this.description = config.description;
|
|
619
621
|
this.astNode = config.astNode;
|
|
620
|
-
this.extensionASTNodes = config.extensionASTNodes;
|
|
622
|
+
this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);
|
|
621
623
|
this.resolveType = config.resolveType;
|
|
622
624
|
this._types = defineTypes.bind(undefined, config);
|
|
623
625
|
!(typeof config.name === 'string') ? invariant(0, 'Must provide name.') : void 0;
|
|
@@ -634,6 +636,17 @@ function () {
|
|
|
634
636
|
return this._types;
|
|
635
637
|
};
|
|
636
638
|
|
|
639
|
+
_proto4.toConfig = function toConfig() {
|
|
640
|
+
return {
|
|
641
|
+
name: this.name,
|
|
642
|
+
description: this.description,
|
|
643
|
+
resolveType: this.resolveType,
|
|
644
|
+
types: this.getTypes(),
|
|
645
|
+
astNode: this.astNode,
|
|
646
|
+
extensionASTNodes: this.extensionASTNodes || []
|
|
647
|
+
};
|
|
648
|
+
};
|
|
649
|
+
|
|
637
650
|
_proto4.toString = function toString() {
|
|
638
651
|
return this.name;
|
|
639
652
|
};
|
|
@@ -679,24 +692,10 @@ function () {
|
|
|
679
692
|
function GraphQLEnumType(config
|
|
680
693
|
/* <T> */
|
|
681
694
|
) {
|
|
682
|
-
_defineProperty(this, "name", void 0);
|
|
683
|
-
|
|
684
|
-
_defineProperty(this, "description", void 0);
|
|
685
|
-
|
|
686
|
-
_defineProperty(this, "astNode", void 0);
|
|
687
|
-
|
|
688
|
-
_defineProperty(this, "extensionASTNodes", void 0);
|
|
689
|
-
|
|
690
|
-
_defineProperty(this, "_values", void 0);
|
|
691
|
-
|
|
692
|
-
_defineProperty(this, "_valueLookup", void 0);
|
|
693
|
-
|
|
694
|
-
_defineProperty(this, "_nameLookup", void 0);
|
|
695
|
-
|
|
696
695
|
this.name = config.name;
|
|
697
696
|
this.description = config.description;
|
|
698
697
|
this.astNode = config.astNode;
|
|
699
|
-
this.extensionASTNodes = config.extensionASTNodes;
|
|
698
|
+
this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);
|
|
700
699
|
this._values = defineEnumValues(this, config.values);
|
|
701
700
|
this._valueLookup = new Map(this._values.map(function (enumValue) {
|
|
702
701
|
return [enumValue.value, enumValue];
|
|
@@ -752,6 +751,26 @@ function () {
|
|
|
752
751
|
}
|
|
753
752
|
};
|
|
754
753
|
|
|
754
|
+
_proto5.toConfig = function toConfig() {
|
|
755
|
+
var values = keyValMap(this.getValues(), function (value) {
|
|
756
|
+
return value.name;
|
|
757
|
+
}, function (value) {
|
|
758
|
+
return {
|
|
759
|
+
description: value.description,
|
|
760
|
+
value: value.value,
|
|
761
|
+
deprecationReason: value.deprecationReason,
|
|
762
|
+
astNode: value.astNode
|
|
763
|
+
};
|
|
764
|
+
});
|
|
765
|
+
return {
|
|
766
|
+
name: this.name,
|
|
767
|
+
description: this.description,
|
|
768
|
+
values: values,
|
|
769
|
+
astNode: this.astNode,
|
|
770
|
+
extensionASTNodes: this.extensionASTNodes || []
|
|
771
|
+
};
|
|
772
|
+
};
|
|
773
|
+
|
|
755
774
|
_proto5.toString = function toString() {
|
|
756
775
|
return this.name;
|
|
757
776
|
};
|
|
@@ -766,8 +785,9 @@ function defineEnumValues(type, valueMap
|
|
|
766
785
|
/* <T> */
|
|
767
786
|
) {
|
|
768
787
|
!isPlainObj(valueMap) ? invariant(0, "".concat(type.name, " values must be an object with value names as keys.")) : void 0;
|
|
769
|
-
return
|
|
770
|
-
var
|
|
788
|
+
return objectEntries(valueMap).map(function (_ref2) {
|
|
789
|
+
var valueName = _ref2[0],
|
|
790
|
+
value = _ref2[1];
|
|
771
791
|
!isPlainObj(value) ? invariant(0, "".concat(type.name, ".").concat(valueName, " must refer to an object with a \"value\" key ") + "representing an internal value but got: ".concat(inspect(value), ".")) : void 0;
|
|
772
792
|
!!value.hasOwnProperty('isDeprecated') ? invariant(0, "".concat(type.name, ".").concat(valueName, " should provide \"deprecationReason\" instead ") + 'of "isDeprecated".') : void 0;
|
|
773
793
|
return {
|
|
@@ -805,20 +825,10 @@ export var GraphQLInputObjectType =
|
|
|
805
825
|
/*#__PURE__*/
|
|
806
826
|
function () {
|
|
807
827
|
function GraphQLInputObjectType(config) {
|
|
808
|
-
_defineProperty(this, "name", void 0);
|
|
809
|
-
|
|
810
|
-
_defineProperty(this, "description", void 0);
|
|
811
|
-
|
|
812
|
-
_defineProperty(this, "astNode", void 0);
|
|
813
|
-
|
|
814
|
-
_defineProperty(this, "extensionASTNodes", void 0);
|
|
815
|
-
|
|
816
|
-
_defineProperty(this, "_fields", void 0);
|
|
817
|
-
|
|
818
828
|
this.name = config.name;
|
|
819
829
|
this.description = config.description;
|
|
820
830
|
this.astNode = config.astNode;
|
|
821
|
-
this.extensionASTNodes = config.extensionASTNodes;
|
|
831
|
+
this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);
|
|
822
832
|
this._fields = defineInputFieldMap.bind(undefined, config);
|
|
823
833
|
!(typeof config.name === 'string') ? invariant(0, 'Must provide name.') : void 0;
|
|
824
834
|
}
|
|
@@ -833,6 +843,24 @@ function () {
|
|
|
833
843
|
return this._fields;
|
|
834
844
|
};
|
|
835
845
|
|
|
846
|
+
_proto6.toConfig = function toConfig() {
|
|
847
|
+
var fields = mapValue(this.getFields(), function (field) {
|
|
848
|
+
return {
|
|
849
|
+
description: field.description,
|
|
850
|
+
type: field.type,
|
|
851
|
+
defaultValue: field.defaultValue,
|
|
852
|
+
astNode: field.astNode
|
|
853
|
+
};
|
|
854
|
+
});
|
|
855
|
+
return {
|
|
856
|
+
name: this.name,
|
|
857
|
+
description: this.description,
|
|
858
|
+
fields: fields,
|
|
859
|
+
astNode: this.astNode,
|
|
860
|
+
extensionASTNodes: this.extensionASTNodes || []
|
|
861
|
+
};
|
|
862
|
+
};
|
|
863
|
+
|
|
836
864
|
_proto6.toString = function toString() {
|
|
837
865
|
return this.name;
|
|
838
866
|
};
|
|
@@ -846,22 +874,12 @@ defineToJSON(GraphQLInputObjectType);
|
|
|
846
874
|
function defineInputFieldMap(config) {
|
|
847
875
|
var fieldMap = resolveThunk(config.fields) || {};
|
|
848
876
|
!isPlainObj(fieldMap) ? invariant(0, "".concat(config.name, " fields must be an object with field names as keys or a ") + 'function which returns such an object.') : void 0;
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
|
|
854
|
-
var fieldName = _arr2[_i2];
|
|
855
|
-
|
|
856
|
-
var field = _objectSpread({}, fieldMap[fieldName], {
|
|
877
|
+
return mapValue(fieldMap, function (fieldConfig, fieldName) {
|
|
878
|
+
!!fieldConfig.hasOwnProperty('resolve') ? invariant(0, "".concat(config.name, ".").concat(fieldName, " field has a resolve property, but ") + 'Input Types cannot define resolvers.') : void 0;
|
|
879
|
+
return _objectSpread({}, fieldConfig, {
|
|
857
880
|
name: fieldName
|
|
858
881
|
});
|
|
859
|
-
|
|
860
|
-
!!field.hasOwnProperty('resolve') ? invariant(0, "".concat(config.name, ".").concat(fieldName, " field has a resolve property, but ") + 'Input Types cannot define resolvers.') : void 0;
|
|
861
|
-
resultFieldMap[fieldName] = field;
|
|
862
|
-
}
|
|
863
|
-
|
|
864
|
-
return resultFieldMap;
|
|
882
|
+
});
|
|
865
883
|
}
|
|
866
884
|
|
|
867
885
|
export function isRequiredInputField(field) {
|
package/type/directives.js
CHANGED
|
@@ -4,9 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.isDirective = isDirective;
|
|
7
|
+
exports.assertDirective = assertDirective;
|
|
7
8
|
exports.isSpecifiedDirective = isSpecifiedDirective;
|
|
8
9
|
exports.specifiedDirectives = exports.GraphQLDeprecatedDirective = exports.DEFAULT_DEPRECATION_REASON = exports.GraphQLSkipDirective = exports.GraphQLIncludeDirective = exports.GraphQLDirective = void 0;
|
|
9
10
|
|
|
11
|
+
var _objectEntries = _interopRequireDefault(require("../polyfills/objectEntries"));
|
|
12
|
+
|
|
10
13
|
var _definition = require("./definition");
|
|
11
14
|
|
|
12
15
|
var _scalars = require("./scalars");
|
|
@@ -19,16 +22,23 @@ var _instanceOf = _interopRequireDefault(require("../jsutils/instanceOf"));
|
|
|
19
22
|
|
|
20
23
|
var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
|
|
21
24
|
|
|
25
|
+
var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
|
|
26
|
+
|
|
22
27
|
var _directiveLocation = require("../language/directiveLocation");
|
|
23
28
|
|
|
24
29
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
30
|
|
|
26
|
-
function
|
|
31
|
+
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); }
|
|
27
32
|
|
|
28
33
|
// eslint-disable-next-line no-redeclare
|
|
29
34
|
function isDirective(directive) {
|
|
30
35
|
return (0, _instanceOf.default)(directive, GraphQLDirective);
|
|
31
36
|
}
|
|
37
|
+
|
|
38
|
+
function assertDirective(directive) {
|
|
39
|
+
!isDirective(directive) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(directive), " to be a GraphQL directive.")) : void 0;
|
|
40
|
+
return directive;
|
|
41
|
+
}
|
|
32
42
|
/**
|
|
33
43
|
* Directives are used by the GraphQL runtime as a way of modifying execution
|
|
34
44
|
* behavior. Type system creators will usually not create these directly.
|
|
@@ -39,39 +49,25 @@ var GraphQLDirective =
|
|
|
39
49
|
/*#__PURE__*/
|
|
40
50
|
function () {
|
|
41
51
|
function GraphQLDirective(config) {
|
|
42
|
-
_defineProperty(this, "name", void 0);
|
|
43
|
-
|
|
44
|
-
_defineProperty(this, "description", void 0);
|
|
45
|
-
|
|
46
|
-
_defineProperty(this, "locations", void 0);
|
|
47
|
-
|
|
48
|
-
_defineProperty(this, "args", void 0);
|
|
49
|
-
|
|
50
|
-
_defineProperty(this, "astNode", void 0);
|
|
51
|
-
|
|
52
52
|
this.name = config.name;
|
|
53
53
|
this.description = config.description;
|
|
54
54
|
this.locations = config.locations;
|
|
55
55
|
this.astNode = config.astNode;
|
|
56
56
|
!config.name ? (0, _invariant.default)(0, 'Directive must be named.') : void 0;
|
|
57
|
-
!Array.isArray(config.locations) ? (0, _invariant.default)(0,
|
|
58
|
-
var args = config.args;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
astNode: arg.astNode
|
|
72
|
-
};
|
|
73
|
-
});
|
|
74
|
-
}
|
|
57
|
+
!Array.isArray(config.locations) ? (0, _invariant.default)(0, "@".concat(config.name, " locations must be an Array.")) : void 0;
|
|
58
|
+
var args = config.args || {};
|
|
59
|
+
!(_typeof(args) === 'object' && !Array.isArray(args)) ? (0, _invariant.default)(0, "@".concat(config.name, " args must be an object with argument names as keys.")) : void 0;
|
|
60
|
+
this.args = (0, _objectEntries.default)(args).map(function (_ref) {
|
|
61
|
+
var argName = _ref[0],
|
|
62
|
+
arg = _ref[1];
|
|
63
|
+
return {
|
|
64
|
+
name: argName,
|
|
65
|
+
description: arg.description === undefined ? null : arg.description,
|
|
66
|
+
type: arg.type,
|
|
67
|
+
defaultValue: arg.defaultValue,
|
|
68
|
+
astNode: arg.astNode
|
|
69
|
+
};
|
|
70
|
+
});
|
|
75
71
|
}
|
|
76
72
|
|
|
77
73
|
var _proto = GraphQLDirective.prototype;
|
|
@@ -80,6 +76,16 @@ function () {
|
|
|
80
76
|
return '@' + this.name;
|
|
81
77
|
};
|
|
82
78
|
|
|
79
|
+
_proto.toConfig = function toConfig() {
|
|
80
|
+
return {
|
|
81
|
+
name: this.name,
|
|
82
|
+
description: this.description,
|
|
83
|
+
locations: this.locations,
|
|
84
|
+
args: (0, _definition.argsToArgsConfig)(this.args),
|
|
85
|
+
astNode: this.astNode
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
|
|
83
89
|
return GraphQLDirective;
|
|
84
90
|
}(); // Conditionally apply `[Symbol.toStringTag]` if `Symbol`s are supported
|
|
85
91
|
|
package/type/directives.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.
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* @flow strict
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
import objectEntries from '../polyfills/objectEntries';
|
|
11
|
+
import { argsToArgsConfig } from './definition';
|
|
10
12
|
import type {
|
|
11
13
|
GraphQLFieldConfigArgumentMap,
|
|
12
14
|
GraphQLArgument,
|
|
@@ -17,6 +19,7 @@ import defineToStringTag from '../jsutils/defineToStringTag';
|
|
|
17
19
|
import defineToJSON from '../jsutils/defineToJSON';
|
|
18
20
|
import instanceOf from '../jsutils/instanceOf';
|
|
19
21
|
import invariant from '../jsutils/invariant';
|
|
22
|
+
import inspect from '../jsutils/inspect';
|
|
20
23
|
import type { DirectiveDefinitionNode } from '../language/ast';
|
|
21
24
|
import {
|
|
22
25
|
DirectiveLocation,
|
|
@@ -34,6 +37,14 @@ export function isDirective(directive) {
|
|
|
34
37
|
return instanceOf(directive, GraphQLDirective);
|
|
35
38
|
}
|
|
36
39
|
|
|
40
|
+
export function assertDirective(directive: mixed): GraphQLDirective {
|
|
41
|
+
invariant(
|
|
42
|
+
isDirective(directive),
|
|
43
|
+
`Expected ${inspect(directive)} to be a GraphQL directive.`,
|
|
44
|
+
);
|
|
45
|
+
return directive;
|
|
46
|
+
}
|
|
47
|
+
|
|
37
48
|
/**
|
|
38
49
|
* Directives are used by the GraphQL runtime as a way of modifying execution
|
|
39
50
|
* behavior. Type system creators will usually not create these directly.
|
|
@@ -53,33 +64,40 @@ export class GraphQLDirective {
|
|
|
53
64
|
invariant(config.name, 'Directive must be named.');
|
|
54
65
|
invariant(
|
|
55
66
|
Array.isArray(config.locations),
|
|
56
|
-
|
|
67
|
+
`@${config.name} locations must be an Array.`,
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
const args = config.args || {};
|
|
71
|
+
invariant(
|
|
72
|
+
typeof args === 'object' && !Array.isArray(args),
|
|
73
|
+
`@${config.name} args must be an object with argument names as keys.`,
|
|
57
74
|
);
|
|
58
75
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
);
|
|
67
|
-
this.args = Object.keys(args).map(argName => {
|
|
68
|
-
const arg = args[argName];
|
|
69
|
-
return {
|
|
70
|
-
name: argName,
|
|
71
|
-
description: arg.description === undefined ? null : arg.description,
|
|
72
|
-
type: arg.type,
|
|
73
|
-
defaultValue: arg.defaultValue,
|
|
74
|
-
astNode: arg.astNode,
|
|
75
|
-
};
|
|
76
|
-
});
|
|
77
|
-
}
|
|
76
|
+
this.args = objectEntries(args).map(([argName, arg]) => ({
|
|
77
|
+
name: argName,
|
|
78
|
+
description: arg.description === undefined ? null : arg.description,
|
|
79
|
+
type: arg.type,
|
|
80
|
+
defaultValue: arg.defaultValue,
|
|
81
|
+
astNode: arg.astNode,
|
|
82
|
+
}));
|
|
78
83
|
}
|
|
79
84
|
|
|
80
85
|
toString(): string {
|
|
81
86
|
return '@' + this.name;
|
|
82
87
|
}
|
|
88
|
+
|
|
89
|
+
toConfig(): {|
|
|
90
|
+
...GraphQLDirectiveConfig,
|
|
91
|
+
args: GraphQLFieldConfigArgumentMap,
|
|
92
|
+
|} {
|
|
93
|
+
return {
|
|
94
|
+
name: this.name,
|
|
95
|
+
description: this.description,
|
|
96
|
+
locations: this.locations,
|
|
97
|
+
args: argsToArgsConfig(this.args),
|
|
98
|
+
astNode: this.astNode,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
83
101
|
}
|
|
84
102
|
|
|
85
103
|
// Conditionally apply `[Symbol.toStringTag]` if `Symbol`s are supported
|