graphql 16.14.0 → 16.14.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/error/GraphQLError.d.ts +151 -15
- package/error/GraphQLError.js +143 -12
- package/error/GraphQLError.mjs +143 -12
- package/error/index.d.ts +6 -0
- package/error/index.mjs +6 -0
- package/error/locatedError.d.ts +20 -0
- package/error/locatedError.js +21 -0
- package/error/locatedError.mjs +20 -0
- package/error/syntaxError.d.ts +15 -0
- package/error/syntaxError.js +16 -0
- package/error/syntaxError.mjs +15 -0
- package/execution/collectFields.js +6 -0
- package/execution/collectFields.mjs +6 -0
- package/execution/execute.d.ts +211 -12
- package/execution/execute.js +214 -23
- package/execution/execute.mjs +213 -23
- package/execution/index.d.ts +6 -0
- package/execution/index.mjs +6 -0
- package/execution/mapAsyncIterator.d.ts +2 -0
- package/execution/mapAsyncIterator.js +2 -0
- package/execution/mapAsyncIterator.mjs +2 -0
- package/execution/subscribe.d.ts +195 -5
- package/execution/subscribe.js +154 -11
- package/execution/subscribe.mjs +153 -11
- package/execution/values.d.ts +167 -10
- package/execution/values.js +149 -5
- package/execution/values.mjs +148 -5
- package/graphql.d.ts +163 -41
- package/graphql.js +126 -4
- package/graphql.mjs +131 -41
- package/index.d.ts +11 -17
- package/index.mjs +13 -19
- package/jsutils/Maybe.d.ts +5 -1
- package/jsutils/ObjMap.d.ts +4 -0
- package/jsutils/Path.d.ts +30 -0
- package/jsutils/Path.js +29 -0
- package/jsutils/Path.mjs +29 -0
- package/jsutils/PromiseOrValue.d.ts +1 -0
- package/jsutils/devAssert.d.ts +1 -0
- package/jsutils/devAssert.js +1 -0
- package/jsutils/devAssert.mjs +1 -0
- package/jsutils/didYouMean.d.ts +4 -1
- package/jsutils/didYouMean.js +4 -1
- package/jsutils/didYouMean.mjs +4 -1
- package/jsutils/groupBy.d.ts +2 -0
- package/jsutils/groupBy.js +2 -0
- package/jsutils/groupBy.mjs +2 -0
- package/jsutils/identityFunc.d.ts +2 -0
- package/jsutils/identityFunc.js +2 -0
- package/jsutils/identityFunc.mjs +2 -0
- package/jsutils/inspect.d.ts +2 -0
- package/jsutils/inspect.js +2 -0
- package/jsutils/inspect.mjs +2 -0
- package/jsutils/instanceOf.d.ts +2 -0
- package/jsutils/instanceOf.js +2 -0
- package/jsutils/instanceOf.mjs +2 -0
- package/jsutils/invariant.d.ts +1 -0
- package/jsutils/invariant.js +1 -0
- package/jsutils/invariant.mjs +1 -0
- package/jsutils/isAsyncIterable.d.ts +2 -0
- package/jsutils/isAsyncIterable.js +2 -0
- package/jsutils/isAsyncIterable.mjs +2 -0
- package/jsutils/isIterableObject.d.ts +6 -5
- package/jsutils/isIterableObject.js +6 -5
- package/jsutils/isIterableObject.mjs +6 -5
- package/jsutils/isObjectLike.d.ts +2 -0
- package/jsutils/isObjectLike.js +2 -0
- package/jsutils/isObjectLike.mjs +2 -0
- package/jsutils/isPromise.d.ts +2 -0
- package/jsutils/isPromise.js +2 -0
- package/jsutils/isPromise.mjs +2 -0
- package/jsutils/keyMap.d.ts +7 -14
- package/jsutils/keyMap.js +7 -14
- package/jsutils/keyMap.mjs +7 -14
- package/jsutils/keyValMap.d.ts +9 -6
- package/jsutils/keyValMap.js +9 -6
- package/jsutils/keyValMap.mjs +9 -6
- package/jsutils/mapValue.d.ts +2 -0
- package/jsutils/mapValue.js +2 -0
- package/jsutils/mapValue.mjs +2 -0
- package/jsutils/memoize3.d.ts +2 -0
- package/jsutils/memoize3.js +2 -0
- package/jsutils/memoize3.mjs +2 -0
- package/jsutils/naturalCompare.d.ts +2 -0
- package/jsutils/naturalCompare.js +2 -0
- package/jsutils/naturalCompare.mjs +2 -0
- package/jsutils/printPathArray.d.ts +2 -0
- package/jsutils/printPathArray.js +2 -0
- package/jsutils/printPathArray.mjs +2 -0
- package/jsutils/promiseForObject.d.ts +2 -0
- package/jsutils/promiseForObject.js +2 -0
- package/jsutils/promiseForObject.mjs +2 -0
- package/jsutils/promiseReduce.d.ts +2 -0
- package/jsutils/promiseReduce.js +2 -0
- package/jsutils/promiseReduce.mjs +2 -0
- package/jsutils/suggestionList.d.ts +2 -0
- package/jsutils/suggestionList.js +4 -0
- package/jsutils/suggestionList.mjs +4 -0
- package/jsutils/toError.d.ts +2 -0
- package/jsutils/toError.js +2 -0
- package/jsutils/toError.mjs +2 -0
- package/jsutils/toObjMap.d.ts +1 -0
- package/jsutils/toObjMap.js +1 -0
- package/jsutils/toObjMap.mjs +1 -0
- package/language/ast.d.ts +412 -54
- package/language/ast.js +95 -38
- package/language/ast.mjs +95 -38
- package/language/blockString.d.ts +1 -3
- package/language/blockString.js +1 -3
- package/language/blockString.mjs +1 -3
- package/language/directiveLocation.d.ts +28 -8
- package/language/directiveLocation.js +9 -6
- package/language/directiveLocation.mjs +9 -6
- package/language/index.d.ts +6 -0
- package/language/index.mjs +6 -0
- package/language/kinds.d.ts +57 -18
- package/language/kinds.js +9 -6
- package/language/kinds.mjs +9 -6
- package/language/lexer.d.ts +47 -14
- package/language/lexer.js +71 -13
- package/language/lexer.mjs +70 -13
- package/language/location.d.ts +16 -3
- package/language/location.js +14 -3
- package/language/location.mjs +14 -3
- package/language/parser.d.ts +236 -13
- package/language/parser.js +224 -0
- package/language/parser.mjs +224 -3
- package/language/predicates.d.ts +169 -0
- package/language/predicates.js +170 -0
- package/language/predicates.mjs +180 -0
- package/language/printLocation.d.ts +28 -0
- package/language/printLocation.js +29 -0
- package/language/printLocation.mjs +28 -0
- package/language/printString.d.ts +2 -0
- package/language/printString.js +5 -1
- package/language/printString.mjs +5 -1
- package/language/printer.d.ts +12 -0
- package/language/printer.js +19 -0
- package/language/printer.mjs +18 -0
- package/language/schemaCoordinateLexer.d.ts +8 -6
- package/language/schemaCoordinateLexer.js +10 -6
- package/language/schemaCoordinateLexer.mjs +10 -6
- package/language/source.d.ts +28 -0
- package/language/source.js +32 -0
- package/language/source.mjs +31 -0
- package/language/tokenKind.d.ts +30 -3
- package/language/tokenKind.js +8 -3
- package/language/tokenKind.mjs +8 -3
- package/language/visitor.d.ts +200 -72
- package/language/visitor.js +122 -50
- package/language/visitor.mjs +122 -54
- package/package.json +1 -1
- package/subscription/index.d.ts +9 -3
- package/subscription/index.mjs +9 -3
- package/type/assertName.d.ts +18 -1
- package/type/assertName.js +19 -1
- package/type/assertName.mjs +18 -1
- package/type/definition.d.ts +2540 -79
- package/type/definition.js +2214 -61
- package/type/definition.mjs +2241 -60
- package/type/directives.d.ts +193 -18
- package/type/directives.js +196 -19
- package/type/directives.mjs +196 -19
- package/type/index.d.ts +6 -0
- package/type/index.mjs +6 -0
- package/type/introspection.d.ts +36 -0
- package/type/introspection.js +33 -0
- package/type/introspection.mjs +41 -0
- package/type/scalars.d.ts +29 -2
- package/type/scalars.js +37 -2
- package/type/scalars.mjs +36 -2
- package/type/schema.d.ts +490 -28
- package/type/schema.js +484 -26
- package/type/schema.mjs +484 -26
- package/type/validate.d.ts +31 -0
- package/type/validate.js +32 -0
- package/type/validate.mjs +31 -0
- package/utilities/TypeInfo.d.ts +441 -1
- package/utilities/TypeInfo.js +444 -1
- package/utilities/TypeInfo.mjs +443 -1
- package/utilities/assertValidName.d.ts +27 -2
- package/utilities/assertValidName.js +28 -2
- package/utilities/assertValidName.mjs +27 -2
- package/utilities/astFromValue.d.ts +33 -3
- package/utilities/astFromValue.js +36 -3
- package/utilities/astFromValue.mjs +35 -3
- package/utilities/buildASTSchema.d.ts +65 -6
- package/utilities/buildASTSchema.js +65 -6
- package/utilities/buildASTSchema.mjs +65 -6
- package/utilities/buildClientSchema.d.ts +15 -0
- package/utilities/buildClientSchema.js +16 -0
- package/utilities/buildClientSchema.mjs +15 -0
- package/utilities/coerceInputValue.d.ts +46 -0
- package/utilities/coerceInputValue.js +47 -0
- package/utilities/coerceInputValue.mjs +46 -0
- package/utilities/concatAST.d.ts +12 -0
- package/utilities/concatAST.js +13 -0
- package/utilities/concatAST.mjs +12 -0
- package/utilities/extendSchema.d.ts +56 -3
- package/utilities/extendSchema.js +63 -3
- package/utilities/extendSchema.mjs +62 -3
- package/utilities/findBreakingChanges.d.ts +95 -0
- package/utilities/findBreakingChanges.js +68 -0
- package/utilities/findBreakingChanges.mjs +70 -0
- package/utilities/getIntrospectionQuery.d.ts +132 -0
- package/utilities/getIntrospectionQuery.js +41 -0
- package/utilities/getIntrospectionQuery.mjs +41 -0
- package/utilities/getOperationAST.d.ts +15 -0
- package/utilities/getOperationAST.js +16 -0
- package/utilities/getOperationAST.mjs +15 -0
- package/utilities/getOperationRootType.d.ts +18 -1
- package/utilities/getOperationRootType.js +19 -1
- package/utilities/getOperationRootType.mjs +18 -1
- package/utilities/index.d.ts +7 -0
- package/utilities/index.mjs +7 -0
- package/utilities/introspectionFromSchema.d.ts +54 -0
- package/utilities/introspectionFromSchema.js +55 -0
- package/utilities/introspectionFromSchema.mjs +54 -0
- package/utilities/lexicographicSortSchema.d.ts +35 -0
- package/utilities/lexicographicSortSchema.js +36 -0
- package/utilities/lexicographicSortSchema.mjs +35 -0
- package/utilities/printSchema.d.ts +63 -0
- package/utilities/printSchema.js +66 -0
- package/utilities/printSchema.mjs +67 -0
- package/utilities/resolveSchemaCoordinate.d.ts +62 -0
- package/utilities/resolveSchemaCoordinate.js +64 -0
- package/utilities/resolveSchemaCoordinate.mjs +63 -0
- package/utilities/separateOperations.d.ts +30 -0
- package/utilities/separateOperations.js +31 -0
- package/utilities/separateOperations.mjs +30 -0
- package/utilities/stripIgnoredCharacters.d.ts +13 -6
- package/utilities/stripIgnoredCharacters.js +16 -6
- package/utilities/stripIgnoredCharacters.mjs +15 -6
- package/utilities/typeComparators.d.ts +84 -0
- package/utilities/typeComparators.js +85 -0
- package/utilities/typeComparators.mjs +84 -0
- package/utilities/typeFromAST.d.ts +86 -0
- package/utilities/typeFromAST.js +3 -0
- package/utilities/typeFromAST.mjs +3 -0
- package/utilities/typedQueryDocumentNode.d.ts +4 -0
- package/utilities/valueFromAST.d.ts +38 -0
- package/utilities/valueFromAST.js +39 -0
- package/utilities/valueFromAST.mjs +38 -0
- package/utilities/valueFromASTUntyped.d.ts +15 -2
- package/utilities/valueFromASTUntyped.js +16 -2
- package/utilities/valueFromASTUntyped.mjs +15 -2
- package/validation/ValidationContext.d.ts +399 -0
- package/validation/ValidationContext.js +400 -0
- package/validation/ValidationContext.mjs +401 -0
- package/validation/index.d.ts +6 -0
- package/validation/index.mjs +6 -0
- package/validation/rules/ExecutableDefinitionsRule.d.ts +28 -0
- package/validation/rules/ExecutableDefinitionsRule.js +29 -0
- package/validation/rules/ExecutableDefinitionsRule.mjs +28 -0
- package/validation/rules/FieldsOnCorrectTypeRule.d.ts +28 -0
- package/validation/rules/FieldsOnCorrectTypeRule.js +33 -0
- package/validation/rules/FieldsOnCorrectTypeRule.mjs +32 -0
- package/validation/rules/FragmentsOnCompositeTypesRule.d.ts +28 -0
- package/validation/rules/FragmentsOnCompositeTypesRule.js +29 -0
- package/validation/rules/FragmentsOnCompositeTypesRule.mjs +28 -0
- package/validation/rules/KnownArgumentNamesRule.d.ts +29 -3
- package/validation/rules/KnownArgumentNamesRule.js +30 -3
- package/validation/rules/KnownArgumentNamesRule.mjs +29 -3
- package/validation/rules/KnownDirectivesRule.d.ts +28 -0
- package/validation/rules/KnownDirectivesRule.js +29 -0
- package/validation/rules/KnownDirectivesRule.mjs +28 -0
- package/validation/rules/KnownFragmentNamesRule.d.ts +28 -0
- package/validation/rules/KnownFragmentNamesRule.js +29 -0
- package/validation/rules/KnownFragmentNamesRule.mjs +28 -0
- package/validation/rules/KnownTypeNamesRule.d.ts +28 -0
- package/validation/rules/KnownTypeNamesRule.js +29 -0
- package/validation/rules/KnownTypeNamesRule.mjs +28 -0
- package/validation/rules/LoneAnonymousOperationRule.d.ts +28 -0
- package/validation/rules/LoneAnonymousOperationRule.js +29 -0
- package/validation/rules/LoneAnonymousOperationRule.mjs +28 -0
- package/validation/rules/LoneSchemaDefinitionRule.d.ts +21 -0
- package/validation/rules/LoneSchemaDefinitionRule.js +22 -0
- package/validation/rules/LoneSchemaDefinitionRule.mjs +21 -0
- package/validation/rules/MaxIntrospectionDepthRule.d.ts +31 -0
- package/validation/rules/MaxIntrospectionDepthRule.js +33 -0
- package/validation/rules/MaxIntrospectionDepthRule.mjs +34 -0
- package/validation/rules/NoFragmentCyclesRule.d.ts +28 -0
- package/validation/rules/NoFragmentCyclesRule.js +29 -0
- package/validation/rules/NoFragmentCyclesRule.mjs +28 -0
- package/validation/rules/NoUndefinedVariablesRule.d.ts +28 -0
- package/validation/rules/NoUndefinedVariablesRule.js +29 -0
- package/validation/rules/NoUndefinedVariablesRule.mjs +28 -0
- package/validation/rules/NoUnusedFragmentsRule.d.ts +28 -0
- package/validation/rules/NoUnusedFragmentsRule.js +29 -0
- package/validation/rules/NoUnusedFragmentsRule.mjs +28 -0
- package/validation/rules/NoUnusedVariablesRule.d.ts +29 -0
- package/validation/rules/NoUnusedVariablesRule.js +30 -0
- package/validation/rules/NoUnusedVariablesRule.mjs +29 -0
- package/validation/rules/OverlappingFieldsCanBeMergedRule.d.ts +33 -0
- package/validation/rules/OverlappingFieldsCanBeMergedRule.js +45 -6
- package/validation/rules/OverlappingFieldsCanBeMergedRule.mjs +45 -6
- package/validation/rules/PossibleFragmentSpreadsRule.d.ts +36 -0
- package/validation/rules/PossibleFragmentSpreadsRule.js +37 -0
- package/validation/rules/PossibleFragmentSpreadsRule.mjs +36 -0
- package/validation/rules/PossibleTypeExtensionsRule.d.ts +21 -0
- package/validation/rules/PossibleTypeExtensionsRule.js +22 -0
- package/validation/rules/PossibleTypeExtensionsRule.mjs +21 -0
- package/validation/rules/ProvidedRequiredArgumentsRule.d.ts +29 -3
- package/validation/rules/ProvidedRequiredArgumentsRule.js +30 -3
- package/validation/rules/ProvidedRequiredArgumentsRule.mjs +29 -3
- package/validation/rules/ScalarLeafsRule.d.ts +28 -0
- package/validation/rules/ScalarLeafsRule.js +29 -0
- package/validation/rules/ScalarLeafsRule.mjs +28 -0
- package/validation/rules/SingleFieldSubscriptionsRule.d.ts +33 -0
- package/validation/rules/SingleFieldSubscriptionsRule.js +34 -0
- package/validation/rules/SingleFieldSubscriptionsRule.mjs +33 -0
- package/validation/rules/UniqueArgumentDefinitionNamesRule.d.ts +21 -0
- package/validation/rules/UniqueArgumentDefinitionNamesRule.js +22 -0
- package/validation/rules/UniqueArgumentDefinitionNamesRule.mjs +21 -0
- package/validation/rules/UniqueArgumentNamesRule.d.ts +28 -0
- package/validation/rules/UniqueArgumentNamesRule.js +29 -0
- package/validation/rules/UniqueArgumentNamesRule.mjs +28 -0
- package/validation/rules/UniqueDirectiveNamesRule.d.ts +21 -0
- package/validation/rules/UniqueDirectiveNamesRule.js +22 -0
- package/validation/rules/UniqueDirectiveNamesRule.mjs +21 -0
- package/validation/rules/UniqueDirectivesPerLocationRule.d.ts +28 -0
- package/validation/rules/UniqueDirectivesPerLocationRule.js +29 -0
- package/validation/rules/UniqueDirectivesPerLocationRule.mjs +28 -0
- package/validation/rules/UniqueEnumValueNamesRule.d.ts +21 -0
- package/validation/rules/UniqueEnumValueNamesRule.js +22 -0
- package/validation/rules/UniqueEnumValueNamesRule.mjs +21 -0
- package/validation/rules/UniqueFieldDefinitionNamesRule.d.ts +21 -0
- package/validation/rules/UniqueFieldDefinitionNamesRule.js +22 -0
- package/validation/rules/UniqueFieldDefinitionNamesRule.mjs +21 -0
- package/validation/rules/UniqueFragmentNamesRule.d.ts +28 -0
- package/validation/rules/UniqueFragmentNamesRule.js +29 -0
- package/validation/rules/UniqueFragmentNamesRule.mjs +28 -0
- package/validation/rules/UniqueInputFieldNamesRule.d.ts +32 -0
- package/validation/rules/UniqueInputFieldNamesRule.js +33 -0
- package/validation/rules/UniqueInputFieldNamesRule.mjs +32 -0
- package/validation/rules/UniqueOperationNamesRule.d.ts +28 -0
- package/validation/rules/UniqueOperationNamesRule.js +29 -0
- package/validation/rules/UniqueOperationNamesRule.mjs +28 -0
- package/validation/rules/UniqueOperationTypesRule.d.ts +21 -0
- package/validation/rules/UniqueOperationTypesRule.js +22 -0
- package/validation/rules/UniqueOperationTypesRule.mjs +21 -0
- package/validation/rules/UniqueTypeNamesRule.d.ts +21 -0
- package/validation/rules/UniqueTypeNamesRule.js +22 -0
- package/validation/rules/UniqueTypeNamesRule.mjs +21 -0
- package/validation/rules/UniqueVariableNamesRule.d.ts +28 -0
- package/validation/rules/UniqueVariableNamesRule.js +29 -0
- package/validation/rules/UniqueVariableNamesRule.mjs +28 -0
- package/validation/rules/ValuesOfCorrectTypeRule.d.ts +28 -0
- package/validation/rules/ValuesOfCorrectTypeRule.js +31 -0
- package/validation/rules/ValuesOfCorrectTypeRule.mjs +30 -0
- package/validation/rules/VariablesAreInputTypesRule.d.ts +32 -0
- package/validation/rules/VariablesAreInputTypesRule.js +33 -0
- package/validation/rules/VariablesAreInputTypesRule.mjs +32 -0
- package/validation/rules/VariablesInAllowedPositionRule.d.ts +28 -0
- package/validation/rules/VariablesInAllowedPositionRule.js +35 -1
- package/validation/rules/VariablesInAllowedPositionRule.mjs +34 -1
- package/validation/rules/custom/NoDeprecatedCustomRule.d.ts +41 -0
- package/validation/rules/custom/NoDeprecatedCustomRule.js +42 -0
- package/validation/rules/custom/NoDeprecatedCustomRule.mjs +41 -0
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.d.ts +28 -0
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.js +29 -0
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.mjs +28 -0
- package/validation/specifiedRules.d.ts +2 -3
- package/validation/specifiedRules.js +2 -3
- package/validation/specifiedRules.mjs +2 -3
- package/validation/validate.d.ts +70 -9
- package/validation/validate.js +63 -7
- package/validation/validate.mjs +63 -7
- package/version.d.ts +3 -6
- package/version.js +6 -8
- package/version.mjs +5 -8
package/type/directives.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** @category Directives */
|
|
1
2
|
import type { Maybe } from '../jsutils/Maybe';
|
|
2
3
|
import type {
|
|
3
4
|
DirectiveDefinitionNode,
|
|
@@ -10,14 +11,46 @@ import type {
|
|
|
10
11
|
} from './definition';
|
|
11
12
|
/**
|
|
12
13
|
* Test if the given value is a GraphQL directive.
|
|
14
|
+
* @param directive - Value to inspect.
|
|
15
|
+
* @returns True when the value is a GraphQLDirective.
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { DirectiveLocation } from 'graphql/language';
|
|
19
|
+
* import { GraphQLDirective, GraphQLString, isDirective } from 'graphql/type';
|
|
20
|
+
*
|
|
21
|
+
* const upper = new GraphQLDirective({
|
|
22
|
+
* name: 'upper',
|
|
23
|
+
* locations: [DirectiveLocation.FIELD_DEFINITION],
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* isDirective(upper); // => true
|
|
27
|
+
* isDirective(GraphQLString); // => false
|
|
28
|
+
* ```
|
|
13
29
|
*/
|
|
14
30
|
export declare function isDirective(
|
|
15
31
|
directive: unknown,
|
|
16
32
|
): directive is GraphQLDirective;
|
|
33
|
+
/**
|
|
34
|
+
* Returns the value as a GraphQLDirective, or throws if it is not a directive.
|
|
35
|
+
* @param directive - Value to inspect.
|
|
36
|
+
* @returns The value typed as a GraphQLDirective.
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* import { DirectiveLocation } from 'graphql/language';
|
|
40
|
+
* import { assertDirective, GraphQLDirective, GraphQLString } from 'graphql/type';
|
|
41
|
+
*
|
|
42
|
+
* const upper = new GraphQLDirective({
|
|
43
|
+
* name: 'upper',
|
|
44
|
+
* locations: [DirectiveLocation.FIELD_DEFINITION],
|
|
45
|
+
* });
|
|
46
|
+
*
|
|
47
|
+
* assertDirective(upper); // => upper
|
|
48
|
+
* assertDirective(GraphQLString); // throws an error
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
17
51
|
export declare function assertDirective(directive: unknown): GraphQLDirective;
|
|
18
52
|
/**
|
|
19
53
|
* Custom extensions
|
|
20
|
-
*
|
|
21
54
|
* @remarks
|
|
22
55
|
* Use a unique identifier name for your extension, for example the name of
|
|
23
56
|
* your library or project. Do not use a shortened identifier as this increases
|
|
@@ -32,30 +65,160 @@ export interface GraphQLDirectiveExtensions {
|
|
|
32
65
|
* behavior. Type system creators will usually not create these directly.
|
|
33
66
|
*/
|
|
34
67
|
export declare class GraphQLDirective {
|
|
68
|
+
/** The GraphQL name for this schema element. */
|
|
35
69
|
name: string;
|
|
70
|
+
/** Human-readable description for this schema element, if provided. */
|
|
36
71
|
description: Maybe<string>;
|
|
72
|
+
/** Locations where this directive may be applied. */
|
|
37
73
|
locations: ReadonlyArray<DirectiveLocation>;
|
|
74
|
+
/** Arguments accepted by this field or directive. */
|
|
38
75
|
args: ReadonlyArray<GraphQLArgument>;
|
|
76
|
+
/** Whether this directive may appear more than once at the same location. */
|
|
39
77
|
isRepeatable: boolean;
|
|
78
|
+
/** Reason this element is deprecated, if one was provided. */
|
|
40
79
|
deprecationReason: Maybe<string>;
|
|
80
|
+
/** Extension fields to include in the formatted result. */
|
|
41
81
|
extensions: Readonly<GraphQLDirectiveExtensions>;
|
|
82
|
+
/** AST node from which this schema element was built, if available. */
|
|
42
83
|
astNode: Maybe<DirectiveDefinitionNode>;
|
|
84
|
+
/** AST extension nodes applied to this schema element. */
|
|
43
85
|
extensionASTNodes: ReadonlyArray<DirectiveExtensionNode>;
|
|
86
|
+
/**
|
|
87
|
+
* Creates a GraphQLDirective instance.
|
|
88
|
+
* @param config - Configuration describing this object.
|
|
89
|
+
* @example
|
|
90
|
+
* ```ts
|
|
91
|
+
* import { DirectiveLocation, parse } from 'graphql/language';
|
|
92
|
+
* import {
|
|
93
|
+
* GraphQLBoolean,
|
|
94
|
+
* GraphQLDirective,
|
|
95
|
+
* GraphQLInt,
|
|
96
|
+
* GraphQLNonNull,
|
|
97
|
+
* } from 'graphql/type';
|
|
98
|
+
*
|
|
99
|
+
* const document = parse(`
|
|
100
|
+
* directive @cacheControl(maxAge: Int) repeatable on FIELD_DEFINITION
|
|
101
|
+
* extend directive @cacheControl(maxAge: Int) on FIELD_DEFINITION
|
|
102
|
+
* `);
|
|
103
|
+
* const definition = document.definitions[0];
|
|
104
|
+
*
|
|
105
|
+
* const cacheControl = new GraphQLDirective({
|
|
106
|
+
* name: 'cacheControl',
|
|
107
|
+
* description: 'Controls HTTP cache hints for a field.',
|
|
108
|
+
* locations: [DirectiveLocation.FIELD_DEFINITION],
|
|
109
|
+
* args: {
|
|
110
|
+
* inheritMaxAge: {
|
|
111
|
+
* description: 'Inherit the parent cache hint.',
|
|
112
|
+
* type: new GraphQLNonNull(GraphQLBoolean),
|
|
113
|
+
* defaultValue: false,
|
|
114
|
+
* deprecationReason: 'Use maxAge instead.',
|
|
115
|
+
* extensions: { scope: 'cache' },
|
|
116
|
+
* },
|
|
117
|
+
* maxAge: {
|
|
118
|
+
* type: GraphQLInt,
|
|
119
|
+
* astNode: definition.arguments[0],
|
|
120
|
+
* },
|
|
121
|
+
* },
|
|
122
|
+
* isRepeatable: true,
|
|
123
|
+
* deprecationReason: 'Use @cache instead.',
|
|
124
|
+
* extensions: { scope: 'cache' },
|
|
125
|
+
* astNode: definition,
|
|
126
|
+
* extensionASTNodes: [ document.definitions[1] ],
|
|
127
|
+
* });
|
|
128
|
+
*
|
|
129
|
+
* cacheControl.name; // => 'cacheControl'
|
|
130
|
+
* cacheControl.description; // => 'Controls HTTP cache hints for a field.'
|
|
131
|
+
* cacheControl.args[0].name; // => 'inheritMaxAge'
|
|
132
|
+
* cacheControl.args[0].defaultValue; // => false
|
|
133
|
+
* cacheControl.isRepeatable; // => true
|
|
134
|
+
* cacheControl.extensions; // => { scope: 'cache' }
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
44
137
|
constructor(config: Readonly<GraphQLDirectiveConfig>);
|
|
138
|
+
/**
|
|
139
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
140
|
+
* @returns The built-in string tag for this object.
|
|
141
|
+
*/
|
|
45
142
|
get [Symbol.toStringTag](): string;
|
|
143
|
+
/**
|
|
144
|
+
* Returns a normalized configuration object for this object.
|
|
145
|
+
* @returns A configuration object that can be used to recreate this object.
|
|
146
|
+
* @example
|
|
147
|
+
* ```ts
|
|
148
|
+
* import { DirectiveLocation } from 'graphql/language';
|
|
149
|
+
* import { GraphQLDirective, GraphQLString } from 'graphql/type';
|
|
150
|
+
*
|
|
151
|
+
* const tag = new GraphQLDirective({
|
|
152
|
+
* name: 'tag',
|
|
153
|
+
* locations: [DirectiveLocation.FIELD_DEFINITION],
|
|
154
|
+
* args: {
|
|
155
|
+
* name: { type: GraphQLString },
|
|
156
|
+
* },
|
|
157
|
+
* });
|
|
158
|
+
*
|
|
159
|
+
* const config = tag.toConfig();
|
|
160
|
+
* const tagCopy = new GraphQLDirective(config);
|
|
161
|
+
*
|
|
162
|
+
* config.args.name.type; // => GraphQLString
|
|
163
|
+
* tagCopy.args[0].name; // => 'name'
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
46
166
|
toConfig(): GraphQLDirectiveNormalizedConfig;
|
|
167
|
+
/**
|
|
168
|
+
* Returns the schema coordinate identifying this directive.
|
|
169
|
+
* @returns The directive schema coordinate.
|
|
170
|
+
* @example
|
|
171
|
+
* ```ts
|
|
172
|
+
* import { DirectiveLocation } from 'graphql/language';
|
|
173
|
+
* import { GraphQLDirective } from 'graphql/type';
|
|
174
|
+
*
|
|
175
|
+
* const tag = new GraphQLDirective({
|
|
176
|
+
* name: 'tag',
|
|
177
|
+
* locations: [DirectiveLocation.FIELD_DEFINITION],
|
|
178
|
+
* });
|
|
179
|
+
*
|
|
180
|
+
* tag.toString(); // => '@tag'
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
47
183
|
toString(): string;
|
|
184
|
+
/**
|
|
185
|
+
* Returns the JSON representation used when this object is serialized.
|
|
186
|
+
* @returns The JSON-serializable representation.
|
|
187
|
+
* @example
|
|
188
|
+
* ```ts
|
|
189
|
+
* import { DirectiveLocation } from 'graphql/language';
|
|
190
|
+
* import { GraphQLDirective } from 'graphql/type';
|
|
191
|
+
*
|
|
192
|
+
* const tag = new GraphQLDirective({
|
|
193
|
+
* name: 'tag',
|
|
194
|
+
* locations: [DirectiveLocation.FIELD_DEFINITION],
|
|
195
|
+
* });
|
|
196
|
+
*
|
|
197
|
+
* tag.toJSON(); // => '@tag'
|
|
198
|
+
* JSON.stringify({ directive: tag }); // => '{"directive":"@tag"}'
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
48
201
|
toJSON(): string;
|
|
49
202
|
}
|
|
203
|
+
/** Configuration used to construct a GraphQLDirective. */
|
|
50
204
|
export interface GraphQLDirectiveConfig {
|
|
205
|
+
/** The GraphQL name for this schema element. */
|
|
51
206
|
name: string;
|
|
207
|
+
/** Human-readable description for this schema element, if provided. */
|
|
52
208
|
description?: Maybe<string>;
|
|
209
|
+
/** Locations where this directive may be applied. */
|
|
53
210
|
locations: ReadonlyArray<DirectiveLocation>;
|
|
211
|
+
/** Arguments accepted by this field or directive. */
|
|
54
212
|
args?: Maybe<GraphQLFieldConfigArgumentMap>;
|
|
213
|
+
/** Whether this directive may appear more than once at the same location. */
|
|
55
214
|
isRepeatable?: Maybe<boolean>;
|
|
215
|
+
/** Reason this element is deprecated, if one was provided. */
|
|
56
216
|
deprecationReason?: Maybe<string>;
|
|
217
|
+
/** Extension fields to include in the formatted result. */
|
|
57
218
|
extensions?: Maybe<Readonly<GraphQLDirectiveExtensions>>;
|
|
219
|
+
/** AST node from which this schema element was built, if available. */
|
|
58
220
|
astNode?: Maybe<DirectiveDefinitionNode>;
|
|
221
|
+
/** AST extension nodes applied to this schema element. */
|
|
59
222
|
extensionASTNodes?: Maybe<ReadonlyArray<DirectiveExtensionNode>>;
|
|
60
223
|
}
|
|
61
224
|
interface GraphQLDirectiveNormalizedConfig extends GraphQLDirectiveConfig {
|
|
@@ -64,34 +227,46 @@ interface GraphQLDirectiveNormalizedConfig extends GraphQLDirectiveConfig {
|
|
|
64
227
|
extensions: Readonly<GraphQLDirectiveExtensions>;
|
|
65
228
|
extensionASTNodes: ReadonlyArray<DirectiveExtensionNode>;
|
|
66
229
|
}
|
|
67
|
-
/**
|
|
68
|
-
* Used to conditionally include fields or fragments.
|
|
69
|
-
*/
|
|
230
|
+
/** Used to conditionally include fields or fragments. */
|
|
70
231
|
export declare const GraphQLIncludeDirective: GraphQLDirective;
|
|
71
|
-
/**
|
|
72
|
-
* Used to conditionally skip (exclude) fields or fragments.
|
|
73
|
-
*/
|
|
232
|
+
/** Used to conditionally skip (exclude) fields or fragments. */
|
|
74
233
|
export declare const GraphQLSkipDirective: GraphQLDirective;
|
|
75
|
-
/**
|
|
76
|
-
* Constant string used for default reason for a deprecation.
|
|
77
|
-
*/
|
|
234
|
+
/** Constant string used for default reason for a deprecation. */
|
|
78
235
|
export declare const DEFAULT_DEPRECATION_REASON = 'No longer supported';
|
|
79
236
|
/**
|
|
80
237
|
* Used to declare element of a GraphQL schema as deprecated.
|
|
238
|
+
*
|
|
239
|
+
* The optional `reason` argument defaults to `DEFAULT_DEPRECATION_REASON`.
|
|
81
240
|
*/
|
|
82
241
|
export declare const GraphQLDeprecatedDirective: GraphQLDirective;
|
|
83
|
-
/**
|
|
84
|
-
* Used to provide a URL for specifying the behavior of custom scalar definitions.
|
|
85
|
-
*/
|
|
242
|
+
/** Used to provide a URL for specifying the behavior of custom scalar definitions. */
|
|
86
243
|
export declare const GraphQLSpecifiedByDirective: GraphQLDirective;
|
|
87
|
-
/**
|
|
88
|
-
* Used to indicate an Input Object is a OneOf Input Object.
|
|
89
|
-
*/
|
|
244
|
+
/** Used to indicate an Input Object is a OneOf Input Object. */
|
|
90
245
|
export declare const GraphQLOneOfDirective: GraphQLDirective;
|
|
246
|
+
/** Full list of stable directives specified by GraphQL.js. */
|
|
247
|
+
export declare const specifiedDirectives: ReadonlyArray<GraphQLDirective>;
|
|
91
248
|
/**
|
|
92
|
-
*
|
|
249
|
+
* Returns true when the directive is one of the directives specified by GraphQL.
|
|
250
|
+
* @param directive - Directive to inspect.
|
|
251
|
+
* @returns True when the directive is specified by GraphQL.
|
|
252
|
+
* @example
|
|
253
|
+
* ```ts
|
|
254
|
+
* import {
|
|
255
|
+
* GraphQLDirective,
|
|
256
|
+
* GraphQLIncludeDirective,
|
|
257
|
+
* isSpecifiedDirective,
|
|
258
|
+
* } from 'graphql/type';
|
|
259
|
+
* import { DirectiveLocation } from 'graphql/language';
|
|
260
|
+
*
|
|
261
|
+
* const customDirective = new GraphQLDirective({
|
|
262
|
+
* name: 'auth',
|
|
263
|
+
* locations: [DirectiveLocation.FIELD_DEFINITION],
|
|
264
|
+
* });
|
|
265
|
+
*
|
|
266
|
+
* isSpecifiedDirective(GraphQLIncludeDirective); // => true
|
|
267
|
+
* isSpecifiedDirective(customDirective); // => false
|
|
268
|
+
* ```
|
|
93
269
|
*/
|
|
94
|
-
export declare const specifiedDirectives: ReadonlyArray<GraphQLDirective>;
|
|
95
270
|
export declare function isSpecifiedDirective(
|
|
96
271
|
directive: GraphQLDirective,
|
|
97
272
|
): boolean;
|
package/type/directives.js
CHANGED
|
@@ -34,12 +34,47 @@ var _definition = require('./definition.js');
|
|
|
34
34
|
|
|
35
35
|
var _scalars = require('./scalars.js');
|
|
36
36
|
|
|
37
|
+
/** @category Directives */
|
|
38
|
+
|
|
37
39
|
/**
|
|
38
40
|
* Test if the given value is a GraphQL directive.
|
|
41
|
+
* @param directive - Value to inspect.
|
|
42
|
+
* @returns True when the value is a GraphQLDirective.
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* import { DirectiveLocation } from 'graphql/language';
|
|
46
|
+
* import { GraphQLDirective, GraphQLString, isDirective } from 'graphql/type';
|
|
47
|
+
*
|
|
48
|
+
* const upper = new GraphQLDirective({
|
|
49
|
+
* name: 'upper',
|
|
50
|
+
* locations: [DirectiveLocation.FIELD_DEFINITION],
|
|
51
|
+
* });
|
|
52
|
+
*
|
|
53
|
+
* isDirective(upper); // => true
|
|
54
|
+
* isDirective(GraphQLString); // => false
|
|
55
|
+
* ```
|
|
39
56
|
*/
|
|
40
57
|
function isDirective(directive) {
|
|
41
58
|
return (0, _instanceOf.instanceOf)(directive, GraphQLDirective);
|
|
42
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Returns the value as a GraphQLDirective, or throws if it is not a directive.
|
|
62
|
+
* @param directive - Value to inspect.
|
|
63
|
+
* @returns The value typed as a GraphQLDirective.
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* import { DirectiveLocation } from 'graphql/language';
|
|
67
|
+
* import { assertDirective, GraphQLDirective, GraphQLString } from 'graphql/type';
|
|
68
|
+
*
|
|
69
|
+
* const upper = new GraphQLDirective({
|
|
70
|
+
* name: 'upper',
|
|
71
|
+
* locations: [DirectiveLocation.FIELD_DEFINITION],
|
|
72
|
+
* });
|
|
73
|
+
*
|
|
74
|
+
* assertDirective(upper); // => upper
|
|
75
|
+
* assertDirective(GraphQLString); // throws an error
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
43
78
|
|
|
44
79
|
function assertDirective(directive) {
|
|
45
80
|
if (!isDirective(directive)) {
|
|
@@ -52,7 +87,6 @@ function assertDirective(directive) {
|
|
|
52
87
|
}
|
|
53
88
|
/**
|
|
54
89
|
* Custom extensions
|
|
55
|
-
*
|
|
56
90
|
* @remarks
|
|
57
91
|
* Use a unique identifier name for your extension, for example the name of
|
|
58
92
|
* your library or project. Do not use a shortened identifier as this increases
|
|
@@ -65,6 +99,75 @@ function assertDirective(directive) {
|
|
|
65
99
|
* behavior. Type system creators will usually not create these directly.
|
|
66
100
|
*/
|
|
67
101
|
class GraphQLDirective {
|
|
102
|
+
/** The GraphQL name for this schema element. */
|
|
103
|
+
|
|
104
|
+
/** Human-readable description for this schema element, if provided. */
|
|
105
|
+
|
|
106
|
+
/** Locations where this directive may be applied. */
|
|
107
|
+
|
|
108
|
+
/** Arguments accepted by this field or directive. */
|
|
109
|
+
|
|
110
|
+
/** Whether this directive may appear more than once at the same location. */
|
|
111
|
+
|
|
112
|
+
/** Reason this element is deprecated, if one was provided. */
|
|
113
|
+
|
|
114
|
+
/** Extension fields to include in the formatted result. */
|
|
115
|
+
|
|
116
|
+
/** AST node from which this schema element was built, if available. */
|
|
117
|
+
|
|
118
|
+
/** AST extension nodes applied to this schema element. */
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Creates a GraphQLDirective instance.
|
|
122
|
+
* @param config - Configuration describing this object.
|
|
123
|
+
* @example
|
|
124
|
+
* ```ts
|
|
125
|
+
* import { DirectiveLocation, parse } from 'graphql/language';
|
|
126
|
+
* import {
|
|
127
|
+
* GraphQLBoolean,
|
|
128
|
+
* GraphQLDirective,
|
|
129
|
+
* GraphQLInt,
|
|
130
|
+
* GraphQLNonNull,
|
|
131
|
+
* } from 'graphql/type';
|
|
132
|
+
*
|
|
133
|
+
* const document = parse(`
|
|
134
|
+
* directive @cacheControl(maxAge: Int) repeatable on FIELD_DEFINITION
|
|
135
|
+
* extend directive @cacheControl(maxAge: Int) on FIELD_DEFINITION
|
|
136
|
+
* `);
|
|
137
|
+
* const definition = document.definitions[0];
|
|
138
|
+
*
|
|
139
|
+
* const cacheControl = new GraphQLDirective({
|
|
140
|
+
* name: 'cacheControl',
|
|
141
|
+
* description: 'Controls HTTP cache hints for a field.',
|
|
142
|
+
* locations: [DirectiveLocation.FIELD_DEFINITION],
|
|
143
|
+
* args: {
|
|
144
|
+
* inheritMaxAge: {
|
|
145
|
+
* description: 'Inherit the parent cache hint.',
|
|
146
|
+
* type: new GraphQLNonNull(GraphQLBoolean),
|
|
147
|
+
* defaultValue: false,
|
|
148
|
+
* deprecationReason: 'Use maxAge instead.',
|
|
149
|
+
* extensions: { scope: 'cache' },
|
|
150
|
+
* },
|
|
151
|
+
* maxAge: {
|
|
152
|
+
* type: GraphQLInt,
|
|
153
|
+
* astNode: definition.arguments[0],
|
|
154
|
+
* },
|
|
155
|
+
* },
|
|
156
|
+
* isRepeatable: true,
|
|
157
|
+
* deprecationReason: 'Use @cache instead.',
|
|
158
|
+
* extensions: { scope: 'cache' },
|
|
159
|
+
* astNode: definition,
|
|
160
|
+
* extensionASTNodes: [ document.definitions[1] ],
|
|
161
|
+
* });
|
|
162
|
+
*
|
|
163
|
+
* cacheControl.name; // => 'cacheControl'
|
|
164
|
+
* cacheControl.description; // => 'Controls HTTP cache hints for a field.'
|
|
165
|
+
* cacheControl.args[0].name; // => 'inheritMaxAge'
|
|
166
|
+
* cacheControl.args[0].defaultValue; // => false
|
|
167
|
+
* cacheControl.isRepeatable; // => true
|
|
168
|
+
* cacheControl.extensions; // => { scope: 'cache' }
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
68
171
|
constructor(config) {
|
|
69
172
|
var _config$isRepeatable, _config$extensionASTN, _config$args;
|
|
70
173
|
|
|
@@ -100,10 +203,37 @@ class GraphQLDirective {
|
|
|
100
203
|
);
|
|
101
204
|
this.args = (0, _definition.defineArguments)(args);
|
|
102
205
|
}
|
|
206
|
+
/**
|
|
207
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
208
|
+
* @returns The built-in string tag for this object.
|
|
209
|
+
*/
|
|
103
210
|
|
|
104
211
|
get [Symbol.toStringTag]() {
|
|
105
212
|
return 'GraphQLDirective';
|
|
106
213
|
}
|
|
214
|
+
/**
|
|
215
|
+
* Returns a normalized configuration object for this object.
|
|
216
|
+
* @returns A configuration object that can be used to recreate this object.
|
|
217
|
+
* @example
|
|
218
|
+
* ```ts
|
|
219
|
+
* import { DirectiveLocation } from 'graphql/language';
|
|
220
|
+
* import { GraphQLDirective, GraphQLString } from 'graphql/type';
|
|
221
|
+
*
|
|
222
|
+
* const tag = new GraphQLDirective({
|
|
223
|
+
* name: 'tag',
|
|
224
|
+
* locations: [DirectiveLocation.FIELD_DEFINITION],
|
|
225
|
+
* args: {
|
|
226
|
+
* name: { type: GraphQLString },
|
|
227
|
+
* },
|
|
228
|
+
* });
|
|
229
|
+
*
|
|
230
|
+
* const config = tag.toConfig();
|
|
231
|
+
* const tagCopy = new GraphQLDirective(config);
|
|
232
|
+
*
|
|
233
|
+
* config.args.name.type; // => GraphQLString
|
|
234
|
+
* tagCopy.args[0].name; // => 'name'
|
|
235
|
+
* ```
|
|
236
|
+
*/
|
|
107
237
|
|
|
108
238
|
toConfig() {
|
|
109
239
|
return {
|
|
@@ -118,21 +248,53 @@ class GraphQLDirective {
|
|
|
118
248
|
extensionASTNodes: this.extensionASTNodes,
|
|
119
249
|
};
|
|
120
250
|
}
|
|
251
|
+
/**
|
|
252
|
+
* Returns the schema coordinate identifying this directive.
|
|
253
|
+
* @returns The directive schema coordinate.
|
|
254
|
+
* @example
|
|
255
|
+
* ```ts
|
|
256
|
+
* import { DirectiveLocation } from 'graphql/language';
|
|
257
|
+
* import { GraphQLDirective } from 'graphql/type';
|
|
258
|
+
*
|
|
259
|
+
* const tag = new GraphQLDirective({
|
|
260
|
+
* name: 'tag',
|
|
261
|
+
* locations: [DirectiveLocation.FIELD_DEFINITION],
|
|
262
|
+
* });
|
|
263
|
+
*
|
|
264
|
+
* tag.toString(); // => '@tag'
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
121
267
|
|
|
122
268
|
toString() {
|
|
123
269
|
return '@' + this.name;
|
|
124
270
|
}
|
|
271
|
+
/**
|
|
272
|
+
* Returns the JSON representation used when this object is serialized.
|
|
273
|
+
* @returns The JSON-serializable representation.
|
|
274
|
+
* @example
|
|
275
|
+
* ```ts
|
|
276
|
+
* import { DirectiveLocation } from 'graphql/language';
|
|
277
|
+
* import { GraphQLDirective } from 'graphql/type';
|
|
278
|
+
*
|
|
279
|
+
* const tag = new GraphQLDirective({
|
|
280
|
+
* name: 'tag',
|
|
281
|
+
* locations: [DirectiveLocation.FIELD_DEFINITION],
|
|
282
|
+
* });
|
|
283
|
+
*
|
|
284
|
+
* tag.toJSON(); // => '@tag'
|
|
285
|
+
* JSON.stringify({ directive: tag }); // => '{"directive":"@tag"}'
|
|
286
|
+
* ```
|
|
287
|
+
*/
|
|
125
288
|
|
|
126
289
|
toJSON() {
|
|
127
290
|
return this.toString();
|
|
128
291
|
}
|
|
129
292
|
}
|
|
293
|
+
/** Configuration used to construct a GraphQLDirective. */
|
|
130
294
|
|
|
131
295
|
exports.GraphQLDirective = GraphQLDirective;
|
|
132
296
|
|
|
133
|
-
/**
|
|
134
|
-
* Used to conditionally include fields or fragments.
|
|
135
|
-
*/
|
|
297
|
+
/** Used to conditionally include fields or fragments. */
|
|
136
298
|
const GraphQLIncludeDirective = new GraphQLDirective({
|
|
137
299
|
name: 'include',
|
|
138
300
|
description:
|
|
@@ -149,9 +311,7 @@ const GraphQLIncludeDirective = new GraphQLDirective({
|
|
|
149
311
|
},
|
|
150
312
|
},
|
|
151
313
|
});
|
|
152
|
-
/**
|
|
153
|
-
* Used to conditionally skip (exclude) fields or fragments.
|
|
154
|
-
*/
|
|
314
|
+
/** Used to conditionally skip (exclude) fields or fragments. */
|
|
155
315
|
|
|
156
316
|
exports.GraphQLIncludeDirective = GraphQLIncludeDirective;
|
|
157
317
|
const GraphQLSkipDirective = new GraphQLDirective({
|
|
@@ -170,14 +330,14 @@ const GraphQLSkipDirective = new GraphQLDirective({
|
|
|
170
330
|
},
|
|
171
331
|
},
|
|
172
332
|
});
|
|
173
|
-
/**
|
|
174
|
-
* Constant string used for default reason for a deprecation.
|
|
175
|
-
*/
|
|
333
|
+
/** Constant string used for default reason for a deprecation. */
|
|
176
334
|
|
|
177
335
|
exports.GraphQLSkipDirective = GraphQLSkipDirective;
|
|
178
336
|
const DEFAULT_DEPRECATION_REASON = 'No longer supported';
|
|
179
337
|
/**
|
|
180
338
|
* Used to declare element of a GraphQL schema as deprecated.
|
|
339
|
+
*
|
|
340
|
+
* The optional `reason` argument defaults to `DEFAULT_DEPRECATION_REASON`.
|
|
181
341
|
*/
|
|
182
342
|
|
|
183
343
|
exports.DEFAULT_DEPRECATION_REASON = DEFAULT_DEPRECATION_REASON;
|
|
@@ -200,9 +360,7 @@ const GraphQLDeprecatedDirective = new GraphQLDirective({
|
|
|
200
360
|
},
|
|
201
361
|
},
|
|
202
362
|
});
|
|
203
|
-
/**
|
|
204
|
-
* Used to provide a URL for specifying the behavior of custom scalar definitions.
|
|
205
|
-
*/
|
|
363
|
+
/** Used to provide a URL for specifying the behavior of custom scalar definitions. */
|
|
206
364
|
|
|
207
365
|
exports.GraphQLDeprecatedDirective = GraphQLDeprecatedDirective;
|
|
208
366
|
const GraphQLSpecifiedByDirective = new GraphQLDirective({
|
|
@@ -216,9 +374,7 @@ const GraphQLSpecifiedByDirective = new GraphQLDirective({
|
|
|
216
374
|
},
|
|
217
375
|
},
|
|
218
376
|
});
|
|
219
|
-
/**
|
|
220
|
-
* Used to indicate an Input Object is a OneOf Input Object.
|
|
221
|
-
*/
|
|
377
|
+
/** Used to indicate an Input Object is a OneOf Input Object. */
|
|
222
378
|
|
|
223
379
|
exports.GraphQLSpecifiedByDirective = GraphQLSpecifiedByDirective;
|
|
224
380
|
const GraphQLOneOfDirective = new GraphQLDirective({
|
|
@@ -228,9 +384,7 @@ const GraphQLOneOfDirective = new GraphQLDirective({
|
|
|
228
384
|
locations: [_directiveLocation.DirectiveLocation.INPUT_OBJECT],
|
|
229
385
|
args: {},
|
|
230
386
|
});
|
|
231
|
-
/**
|
|
232
|
-
* The full list of specified directives.
|
|
233
|
-
*/
|
|
387
|
+
/** Full list of stable directives specified by GraphQL.js. */
|
|
234
388
|
|
|
235
389
|
exports.GraphQLOneOfDirective = GraphQLOneOfDirective;
|
|
236
390
|
const specifiedDirectives = Object.freeze([
|
|
@@ -240,6 +394,29 @@ const specifiedDirectives = Object.freeze([
|
|
|
240
394
|
GraphQLSpecifiedByDirective,
|
|
241
395
|
GraphQLOneOfDirective,
|
|
242
396
|
]);
|
|
397
|
+
/**
|
|
398
|
+
* Returns true when the directive is one of the directives specified by GraphQL.
|
|
399
|
+
* @param directive - Directive to inspect.
|
|
400
|
+
* @returns True when the directive is specified by GraphQL.
|
|
401
|
+
* @example
|
|
402
|
+
* ```ts
|
|
403
|
+
* import {
|
|
404
|
+
* GraphQLDirective,
|
|
405
|
+
* GraphQLIncludeDirective,
|
|
406
|
+
* isSpecifiedDirective,
|
|
407
|
+
* } from 'graphql/type';
|
|
408
|
+
* import { DirectiveLocation } from 'graphql/language';
|
|
409
|
+
*
|
|
410
|
+
* const customDirective = new GraphQLDirective({
|
|
411
|
+
* name: 'auth',
|
|
412
|
+
* locations: [DirectiveLocation.FIELD_DEFINITION],
|
|
413
|
+
* });
|
|
414
|
+
*
|
|
415
|
+
* isSpecifiedDirective(GraphQLIncludeDirective); // => true
|
|
416
|
+
* isSpecifiedDirective(customDirective); // => false
|
|
417
|
+
* ```
|
|
418
|
+
*/
|
|
419
|
+
|
|
243
420
|
exports.specifiedDirectives = specifiedDirectives;
|
|
244
421
|
|
|
245
422
|
function isSpecifiedDirective(directive) {
|