graphql 17.0.0-beta.2 → 17.0.0
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/README.md +3 -5
- package/__dev__/diagnostics.d.mts +1 -0
- package/__dev__/diagnostics.d.ts +1 -0
- package/__dev__/diagnostics.js +3 -0
- package/__dev__/diagnostics.mjs +3 -0
- package/diagnostics.d.mts +307 -0
- package/diagnostics.d.ts +307 -0
- package/diagnostics.js +75 -0
- package/diagnostics.js.map +1 -0
- package/diagnostics.mjs +70 -0
- package/diagnostics.mjs.map +1 -0
- package/error/GraphQLError.d.mts +3 -1
- package/error/GraphQLError.d.ts +3 -1
- package/error/GraphQLError.js +3 -3
- package/error/GraphQLError.js.map +1 -1
- package/error/GraphQLError.mjs +3 -3
- package/error/GraphQLError.mjs.map +1 -1
- package/error/locatedError.d.mts +1 -3
- package/error/locatedError.d.ts +1 -3
- package/error/locatedError.js.map +1 -1
- package/error/locatedError.mjs.map +1 -1
- package/execution/ExecutionArgs.d.mts +6 -0
- package/execution/ExecutionArgs.d.ts +6 -0
- package/execution/ExecutionArgs.js.map +1 -1
- package/execution/ExecutionArgs.mjs.map +1 -1
- package/execution/Executor.d.mts +19 -1
- package/execution/Executor.d.ts +19 -1
- package/execution/Executor.js +49 -4
- package/execution/Executor.js.map +1 -1
- package/execution/Executor.mjs +49 -4
- package/execution/Executor.mjs.map +1 -1
- package/execution/execute.d.mts +65 -44
- package/execution/execute.d.ts +65 -44
- package/execution/execute.js +73 -4
- package/execution/execute.js.map +1 -1
- package/execution/execute.mjs +73 -4
- package/execution/execute.mjs.map +1 -1
- package/execution/values.d.mts +17 -17
- package/execution/values.d.ts +17 -17
- package/execution/values.js.map +1 -1
- package/execution/values.mjs.map +1 -1
- package/index.d.mts +1 -0
- package/index.d.ts +1 -0
- package/index.js.map +1 -1
- package/index.mjs.map +1 -1
- package/language/parser.d.mts +20 -30
- package/language/parser.d.ts +20 -30
- package/language/parser.js +9 -9
- package/language/parser.js.map +1 -1
- package/language/parser.mjs +9 -9
- package/language/parser.mjs.map +1 -1
- package/language/predicates.d.mts +5 -1
- package/language/predicates.d.ts +5 -1
- package/language/predicates.js.map +1 -1
- package/language/predicates.mjs.map +1 -1
- package/language/source.d.mts +4 -5
- package/language/source.d.ts +4 -5
- package/language/source.js.map +1 -1
- package/language/source.mjs.map +1 -1
- package/language/visitor.d.mts +10 -2
- package/language/visitor.d.ts +10 -2
- package/language/visitor.js.map +1 -1
- package/language/visitor.mjs.map +1 -1
- package/package.json +2 -2
- package/type/definition.d.mts +96 -64
- package/type/definition.d.ts +96 -64
- package/type/definition.js.map +1 -1
- package/type/definition.mjs.map +1 -1
- package/type/directives.d.mts +3 -3
- package/type/directives.d.ts +3 -3
- package/type/directives.js.map +1 -1
- package/type/directives.mjs.map +1 -1
- package/type/schema.d.mts +4 -8
- package/type/schema.d.ts +4 -8
- package/type/schema.js.map +1 -1
- package/type/schema.mjs.map +1 -1
- package/type/validate.js +101 -30
- package/type/validate.js.map +1 -1
- package/type/validate.mjs +101 -30
- package/type/validate.mjs.map +1 -1
- package/utilities/TypeInfo.d.mts +1 -1
- package/utilities/TypeInfo.d.ts +1 -1
- package/utilities/TypeInfo.js.map +1 -1
- package/utilities/TypeInfo.mjs.map +1 -1
- package/utilities/buildASTSchema.d.mts +0 -1
- package/utilities/buildASTSchema.d.ts +0 -1
- package/utilities/buildASTSchema.js +0 -1
- package/utilities/buildASTSchema.js.map +1 -1
- package/utilities/buildASTSchema.mjs +0 -1
- package/utilities/buildASTSchema.mjs.map +1 -1
- package/utilities/buildClientSchema.d.mts +5 -1
- package/utilities/buildClientSchema.d.ts +5 -1
- package/utilities/buildClientSchema.js.map +1 -1
- package/utilities/buildClientSchema.mjs.map +1 -1
- package/utilities/coerceInputValue.d.mts +7 -6
- package/utilities/coerceInputValue.d.ts +7 -6
- package/utilities/coerceInputValue.js.map +1 -1
- package/utilities/coerceInputValue.mjs.map +1 -1
- package/utilities/concatAST.d.mts +4 -1
- package/utilities/concatAST.d.ts +4 -1
- package/utilities/concatAST.js.map +1 -1
- package/utilities/concatAST.mjs.map +1 -1
- package/utilities/extendSchema.d.mts +3 -3
- package/utilities/extendSchema.d.ts +3 -3
- package/utilities/extendSchema.js +5 -1
- package/utilities/extendSchema.js.map +1 -1
- package/utilities/extendSchema.mjs +5 -1
- package/utilities/extendSchema.mjs.map +1 -1
- package/utilities/introspectionFromSchema.d.mts +6 -2
- package/utilities/introspectionFromSchema.d.ts +6 -2
- package/utilities/introspectionFromSchema.js.map +1 -1
- package/utilities/introspectionFromSchema.mjs.map +1 -1
- package/utilities/lexicographicSortSchema.d.mts +5 -1
- package/utilities/lexicographicSortSchema.d.ts +5 -1
- package/utilities/lexicographicSortSchema.js.map +1 -1
- package/utilities/lexicographicSortSchema.mjs.map +1 -1
- package/utilities/printSchema.d.mts +5 -1
- package/utilities/printSchema.d.ts +5 -1
- package/utilities/printSchema.js.map +1 -1
- package/utilities/printSchema.mjs.map +1 -1
- package/utilities/replaceVariables.d.mts +4 -8
- package/utilities/replaceVariables.d.ts +4 -8
- package/utilities/replaceVariables.js.map +1 -1
- package/utilities/replaceVariables.mjs.map +1 -1
- package/utilities/stripIgnoredCharacters.d.mts +2 -2
- package/utilities/stripIgnoredCharacters.d.ts +2 -2
- package/utilities/stripIgnoredCharacters.js.map +1 -1
- package/utilities/stripIgnoredCharacters.mjs.map +1 -1
- package/utilities/typeComparators.d.mts +1 -5
- package/utilities/typeComparators.d.ts +1 -5
- package/utilities/typeComparators.js.map +1 -1
- package/utilities/typeComparators.mjs.map +1 -1
- package/utilities/validateInputValue.d.mts +10 -8
- package/utilities/validateInputValue.d.ts +10 -8
- package/utilities/validateInputValue.js.map +1 -1
- package/utilities/validateInputValue.mjs.map +1 -1
- package/validation/rules/DeferStreamDirectiveOnRootFieldRule.d.mts +4 -1
- package/validation/rules/DeferStreamDirectiveOnRootFieldRule.d.ts +4 -1
- package/validation/rules/DeferStreamDirectiveOnRootFieldRule.js +70 -17
- package/validation/rules/DeferStreamDirectiveOnRootFieldRule.js.map +1 -1
- package/validation/rules/DeferStreamDirectiveOnRootFieldRule.mjs +70 -17
- package/validation/rules/DeferStreamDirectiveOnRootFieldRule.mjs.map +1 -1
- package/validation/rules/DeferStreamDirectiveOnValidOperationsRule.d.mts +1 -1
- package/validation/rules/DeferStreamDirectiveOnValidOperationsRule.d.ts +1 -1
- package/validation/rules/DeferStreamDirectiveOnValidOperationsRule.js +90 -21
- package/validation/rules/DeferStreamDirectiveOnValidOperationsRule.js.map +1 -1
- package/validation/rules/DeferStreamDirectiveOnValidOperationsRule.mjs +91 -22
- package/validation/rules/DeferStreamDirectiveOnValidOperationsRule.mjs.map +1 -1
- package/validation/rules/ExecutableDefinitionsRule.d.mts +6 -2
- package/validation/rules/ExecutableDefinitionsRule.d.ts +6 -2
- package/validation/rules/ExecutableDefinitionsRule.js.map +1 -1
- package/validation/rules/ExecutableDefinitionsRule.mjs.map +1 -1
- package/validation/rules/FieldsOnCorrectTypeRule.d.mts +3 -1
- package/validation/rules/FieldsOnCorrectTypeRule.d.ts +3 -1
- package/validation/rules/FieldsOnCorrectTypeRule.js.map +1 -1
- package/validation/rules/FieldsOnCorrectTypeRule.mjs.map +1 -1
- package/validation/rules/FragmentsOnCompositeTypesRule.d.mts +6 -2
- package/validation/rules/FragmentsOnCompositeTypesRule.d.ts +6 -2
- package/validation/rules/FragmentsOnCompositeTypesRule.js.map +1 -1
- package/validation/rules/FragmentsOnCompositeTypesRule.mjs.map +1 -1
- package/validation/rules/KnownArgumentNamesRule.d.mts +3 -1
- package/validation/rules/KnownArgumentNamesRule.d.ts +3 -1
- package/validation/rules/KnownArgumentNamesRule.js.map +1 -1
- package/validation/rules/KnownArgumentNamesRule.mjs.map +1 -1
- package/validation/rules/KnownDirectivesRule.js +2 -1
- package/validation/rules/KnownDirectivesRule.js.map +1 -1
- package/validation/rules/KnownDirectivesRule.mjs +2 -1
- package/validation/rules/KnownDirectivesRule.mjs.map +1 -1
- package/validation/rules/KnownFragmentNamesRule.d.mts +3 -1
- package/validation/rules/KnownFragmentNamesRule.d.ts +3 -1
- package/validation/rules/KnownFragmentNamesRule.js.map +1 -1
- package/validation/rules/KnownFragmentNamesRule.mjs.map +1 -1
- package/validation/rules/LoneAnonymousOperationRule.d.mts +6 -2
- package/validation/rules/LoneAnonymousOperationRule.d.ts +6 -2
- package/validation/rules/LoneAnonymousOperationRule.js.map +1 -1
- package/validation/rules/LoneAnonymousOperationRule.mjs.map +1 -1
- package/validation/rules/MaxIntrospectionDepthRule.d.mts +6 -2
- package/validation/rules/MaxIntrospectionDepthRule.d.ts +6 -2
- package/validation/rules/MaxIntrospectionDepthRule.js.map +1 -1
- package/validation/rules/MaxIntrospectionDepthRule.mjs.map +1 -1
- package/validation/rules/NoUndefinedVariablesRule.d.mts +3 -1
- package/validation/rules/NoUndefinedVariablesRule.d.ts +3 -1
- package/validation/rules/NoUndefinedVariablesRule.js.map +1 -1
- package/validation/rules/NoUndefinedVariablesRule.mjs.map +1 -1
- package/validation/rules/NoUnusedFragmentsRule.d.mts +3 -1
- package/validation/rules/NoUnusedFragmentsRule.d.ts +3 -1
- package/validation/rules/NoUnusedFragmentsRule.js.map +1 -1
- package/validation/rules/NoUnusedFragmentsRule.mjs.map +1 -1
- package/validation/rules/NoUnusedVariablesRule.d.mts +3 -1
- package/validation/rules/NoUnusedVariablesRule.d.ts +3 -1
- package/validation/rules/NoUnusedVariablesRule.js.map +1 -1
- package/validation/rules/NoUnusedVariablesRule.mjs.map +1 -1
- package/validation/rules/OverlappingFieldsCanBeMergedRule.d.mts +6 -2
- package/validation/rules/OverlappingFieldsCanBeMergedRule.d.ts +6 -2
- package/validation/rules/OverlappingFieldsCanBeMergedRule.js.map +1 -1
- package/validation/rules/OverlappingFieldsCanBeMergedRule.mjs.map +1 -1
- package/validation/rules/PossibleFragmentSpreadsRule.d.mts +6 -2
- package/validation/rules/PossibleFragmentSpreadsRule.d.ts +6 -2
- package/validation/rules/PossibleFragmentSpreadsRule.js.map +1 -1
- package/validation/rules/PossibleFragmentSpreadsRule.mjs.map +1 -1
- package/validation/rules/ProvidedRequiredArgumentsRule.d.mts +6 -2
- package/validation/rules/ProvidedRequiredArgumentsRule.d.ts +6 -2
- package/validation/rules/ProvidedRequiredArgumentsRule.js.map +1 -1
- package/validation/rules/ProvidedRequiredArgumentsRule.mjs.map +1 -1
- package/validation/rules/SingleFieldSubscriptionsRule.d.mts +6 -2
- package/validation/rules/SingleFieldSubscriptionsRule.d.ts +6 -2
- package/validation/rules/SingleFieldSubscriptionsRule.js.map +1 -1
- package/validation/rules/SingleFieldSubscriptionsRule.mjs.map +1 -1
- package/validation/rules/UniqueArgumentNamesRule.d.mts +3 -1
- package/validation/rules/UniqueArgumentNamesRule.d.ts +3 -1
- package/validation/rules/UniqueArgumentNamesRule.js.map +1 -1
- package/validation/rules/UniqueArgumentNamesRule.mjs.map +1 -1
- package/validation/rules/UniqueDirectivesPerLocationRule.d.mts +6 -2
- package/validation/rules/UniqueDirectivesPerLocationRule.d.ts +6 -2
- package/validation/rules/UniqueDirectivesPerLocationRule.js.map +1 -1
- package/validation/rules/UniqueDirectivesPerLocationRule.mjs.map +1 -1
- package/validation/rules/UniqueFragmentNamesRule.d.mts +3 -1
- package/validation/rules/UniqueFragmentNamesRule.d.ts +3 -1
- package/validation/rules/UniqueFragmentNamesRule.js.map +1 -1
- package/validation/rules/UniqueFragmentNamesRule.mjs.map +1 -1
- package/validation/rules/UniqueInputFieldNamesRule.d.mts +6 -2
- package/validation/rules/UniqueInputFieldNamesRule.d.ts +6 -2
- package/validation/rules/UniqueInputFieldNamesRule.js.map +1 -1
- package/validation/rules/UniqueInputFieldNamesRule.mjs.map +1 -1
- package/validation/rules/UniqueOperationNamesRule.d.mts +3 -1
- package/validation/rules/UniqueOperationNamesRule.d.ts +3 -1
- package/validation/rules/UniqueOperationNamesRule.js.map +1 -1
- package/validation/rules/UniqueOperationNamesRule.mjs.map +1 -1
- package/validation/rules/UniqueVariableNamesRule.d.mts +3 -1
- package/validation/rules/UniqueVariableNamesRule.d.ts +3 -1
- package/validation/rules/UniqueVariableNamesRule.js.map +1 -1
- package/validation/rules/UniqueVariableNamesRule.mjs.map +1 -1
- package/validation/rules/ValuesOfCorrectTypeRule.d.mts +3 -1
- package/validation/rules/ValuesOfCorrectTypeRule.d.ts +3 -1
- package/validation/rules/ValuesOfCorrectTypeRule.js.map +1 -1
- package/validation/rules/ValuesOfCorrectTypeRule.mjs.map +1 -1
- package/validation/rules/VariablesAreInputTypesRule.d.mts +6 -2
- package/validation/rules/VariablesAreInputTypesRule.d.ts +6 -2
- package/validation/rules/VariablesAreInputTypesRule.js.map +1 -1
- package/validation/rules/VariablesAreInputTypesRule.mjs.map +1 -1
- package/validation/rules/VariablesInAllowedPositionRule.d.mts +6 -2
- package/validation/rules/VariablesInAllowedPositionRule.d.ts +6 -2
- package/validation/rules/VariablesInAllowedPositionRule.js.map +1 -1
- package/validation/rules/VariablesInAllowedPositionRule.mjs.map +1 -1
- package/validation/rules/custom/NoDeprecatedCustomRule.d.mts +3 -1
- package/validation/rules/custom/NoDeprecatedCustomRule.d.ts +3 -1
- package/validation/rules/custom/NoDeprecatedCustomRule.js.map +1 -1
- package/validation/rules/custom/NoDeprecatedCustomRule.mjs.map +1 -1
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.d.mts +6 -2
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.d.ts +6 -2
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.js.map +1 -1
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.mjs.map +1 -1
- package/validation/validate.d.mts +3 -6
- package/validation/validate.d.ts +3 -6
- package/validation/validate.js +6 -0
- package/validation/validate.js.map +1 -1
- package/validation/validate.mjs +6 -0
- package/validation/validate.mjs.map +1 -1
- package/version.js +2 -2
- package/version.js.map +1 -1
- package/version.mjs +2 -2
- package/version.mjs.map +1 -1
package/type/directives.d.mts
CHANGED
|
@@ -71,7 +71,7 @@ export declare class GraphQLDirective implements GraphQLSchemaElement {
|
|
|
71
71
|
isRepeatable: boolean;
|
|
72
72
|
/** Reason this element is deprecated, if one was provided. */
|
|
73
73
|
deprecationReason: Maybe<string>;
|
|
74
|
-
/**
|
|
74
|
+
/** Custom extension fields reserved for users. */
|
|
75
75
|
extensions: Readonly<GraphQLDirectiveExtensions>;
|
|
76
76
|
/** AST node from which this schema element was built, if available. */
|
|
77
77
|
astNode: Maybe<DirectiveDefinitionNode>;
|
|
@@ -117,7 +117,7 @@ export declare class GraphQLDirective implements GraphQLSchemaElement {
|
|
|
117
117
|
* deprecationReason: 'Use @cache instead.',
|
|
118
118
|
* extensions: { scope: 'cache' },
|
|
119
119
|
* astNode: definition,
|
|
120
|
-
* extensionASTNodes: [
|
|
120
|
+
* extensionASTNodes: [document.definitions[1]],
|
|
121
121
|
* });
|
|
122
122
|
*
|
|
123
123
|
* cacheControl.name; // => 'cacheControl'
|
|
@@ -208,7 +208,7 @@ export interface GraphQLDirectiveConfig {
|
|
|
208
208
|
isRepeatable?: Maybe<boolean>;
|
|
209
209
|
/** Reason this element is deprecated, if one was provided. */
|
|
210
210
|
deprecationReason?: Maybe<string>;
|
|
211
|
-
/**
|
|
211
|
+
/** Custom extension fields reserved for users. */
|
|
212
212
|
extensions?: Maybe<Readonly<GraphQLDirectiveExtensions>>;
|
|
213
213
|
/** AST node from which this schema element was built, if available. */
|
|
214
214
|
astNode?: Maybe<DirectiveDefinitionNode>;
|
package/type/directives.d.ts
CHANGED
|
@@ -71,7 +71,7 @@ export declare class GraphQLDirective implements GraphQLSchemaElement {
|
|
|
71
71
|
isRepeatable: boolean;
|
|
72
72
|
/** Reason this element is deprecated, if one was provided. */
|
|
73
73
|
deprecationReason: Maybe<string>;
|
|
74
|
-
/**
|
|
74
|
+
/** Custom extension fields reserved for users. */
|
|
75
75
|
extensions: Readonly<GraphQLDirectiveExtensions>;
|
|
76
76
|
/** AST node from which this schema element was built, if available. */
|
|
77
77
|
astNode: Maybe<DirectiveDefinitionNode>;
|
|
@@ -117,7 +117,7 @@ export declare class GraphQLDirective implements GraphQLSchemaElement {
|
|
|
117
117
|
* deprecationReason: 'Use @cache instead.',
|
|
118
118
|
* extensions: { scope: 'cache' },
|
|
119
119
|
* astNode: definition,
|
|
120
|
-
* extensionASTNodes: [
|
|
120
|
+
* extensionASTNodes: [document.definitions[1]],
|
|
121
121
|
* });
|
|
122
122
|
*
|
|
123
123
|
* cacheControl.name; // => 'cacheControl'
|
|
@@ -208,7 +208,7 @@ export interface GraphQLDirectiveConfig {
|
|
|
208
208
|
isRepeatable?: Maybe<boolean>;
|
|
209
209
|
/** Reason this element is deprecated, if one was provided. */
|
|
210
210
|
deprecationReason?: Maybe<string>;
|
|
211
|
-
/**
|
|
211
|
+
/** Custom extension fields reserved for users. */
|
|
212
212
|
extensions?: Maybe<Readonly<GraphQLDirectiveExtensions>>;
|
|
213
213
|
/** AST node from which this schema element was built, if available. */
|
|
214
214
|
astNode?: Maybe<DirectiveDefinitionNode>;
|
package/type/directives.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directives.js","sourceRoot":"","sources":["../../src/type/directives.ts"],"names":[],"mappings":";;;AA+CA,kCAEC;AAoBD,0CAOC;AAwbD,oDAEC;AApgBD,0DAAoD;AACpD,sDAAgD;AAChD,4DAAsD;AACtD,gEAA0D;AAC1D,0DAAoD;AAGpD,wDAA6D;AAM7D,2EAAqE;AAErE,mDAA6C;AAM7C,mDAAkE;AAClE,6CAAyE;AAGzE,MAAM,eAAe,GAAkB,MAAM,CAAC,WAAW,CAAC,CAAC;AAoB3D,SAAgB,WAAW,CAAC,SAAkB;IAC5C,OAAO,IAAA,0BAAU,EAAC,SAAS,EAAE,eAAe,EAAE,gBAAgB,CAAC,CAAC;AAClE,CAAC;AAoBD,SAAgB,eAAe,CAAC,SAAkB;IAChD,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC;QAC5B,MAA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B,MAAM,CAAC,MAAM,CAAC;IACZ,+BAAuB;IACvB,4BAAoB;IACpB,kCAA0B;IAC1B,mCAA2B;IAC3B,6BAAqB;CACtB,CAAC,CAAC;AAwBL,SAAgB,oBAAoB,CAAC,SAA2B;IAC9D,OAAO,2BAAmB,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,CAAC,CAAC;AACzE,CAAC","sourcesContent":["/** @category Directives */\n\nimport { devAssert } from '../jsutils/devAssert.ts';\nimport { inspect } from '../jsutils/inspect.ts';\nimport { instanceOf } from '../jsutils/instanceOf.ts';\nimport { isObjectLike } from '../jsutils/isObjectLike.ts';\nimport { keyValMap } from '../jsutils/keyValMap.ts';\nimport type { Maybe } from '../jsutils/Maybe.ts';\nimport type { ObjMap } from '../jsutils/ObjMap.ts';\nimport { toObjMapWithSymbols } from '../jsutils/toObjMap.ts';\n\nimport type {\n DirectiveDefinitionNode,\n DirectiveExtensionNode,\n} from '../language/ast.ts';\nimport { DirectiveLocation } from '../language/directiveLocation.ts';\n\nimport { assertName } from './assertName.ts';\nimport type {\n GraphQLArgumentConfig,\n GraphQLFieldNormalizedConfigArgumentMap,\n GraphQLSchemaElement,\n} from './definition.ts';\nimport { GraphQLArgument, GraphQLNonNull } from './definition.ts';\nimport { GraphQLBoolean, GraphQLInt, GraphQLString } from './scalars.ts';\n\n/** @private */\nconst directiveSymbol: unique symbol = Symbol('Directive');\n\n/**\n * Test if the given value is a GraphQL directive.\n * @param directive - Value to inspect.\n * @returns True when the value is a GraphQLDirective.\n * @example\n * ```ts\n * import { DirectiveLocation } from 'graphql/language';\n * import { GraphQLDirective, GraphQLString, isDirective } from 'graphql/type';\n *\n * const upper = new GraphQLDirective({\n * name: 'upper',\n * locations: [DirectiveLocation.FIELD_DEFINITION],\n * });\n *\n * isDirective(upper); // => true\n * isDirective(GraphQLString); // => false\n * ```\n */\nexport function isDirective(directive: unknown): directive is GraphQLDirective {\n return instanceOf(directive, directiveSymbol, GraphQLDirective);\n}\n\n/**\n * Returns the value as a GraphQLDirective, or throws if it is not a directive.\n * @param directive - Value to inspect.\n * @returns The value typed as a GraphQLDirective.\n * @example\n * ```ts\n * import { DirectiveLocation } from 'graphql/language';\n * import { assertDirective, GraphQLDirective, GraphQLString } from 'graphql/type';\n *\n * const upper = new GraphQLDirective({\n * name: 'upper',\n * locations: [DirectiveLocation.FIELD_DEFINITION],\n * });\n *\n * assertDirective(upper); // => upper\n * assertDirective(GraphQLString); // throws an error\n * ```\n */\nexport function assertDirective(directive: unknown): GraphQLDirective {\n if (!isDirective(directive)) {\n throw new Error(\n `Expected ${inspect(directive)} to be a GraphQL directive.`,\n );\n }\n return directive;\n}\n\n/**\n * Custom extensions\n * @remarks\n * Use a unique identifier name for your extension, for example the name of\n * your library or project. Do not use a shortened identifier as this increases\n * the risk of conflicts. We recommend you add at most one extension field,\n * an object which can contain all the values you need.\n */\nexport interface GraphQLDirectiveExtensions {\n [attributeName: string | symbol]: unknown;\n}\n\n/**\n * Directives are used by the GraphQL runtime as a way of modifying execution\n * behavior. Type system creators will usually not create these directly.\n */\nexport class GraphQLDirective implements GraphQLSchemaElement {\n /**\n * Internal runtime marker used to identify GraphQLDirective instances.\n * @private\n */\n readonly __kind: symbol;\n /** The GraphQL name for this schema element. */\n name: string;\n /** Human-readable description for this schema element, if provided. */\n description: Maybe<string>;\n /** Locations where this directive may be applied. */\n locations: ReadonlyArray<DirectiveLocation>;\n /** Arguments accepted by this field or directive. */\n args: ReadonlyArray<GraphQLArgument>;\n /** Whether this directive may appear more than once at the same location. */\n isRepeatable: boolean;\n /** Reason this element is deprecated, if one was provided. */\n deprecationReason: Maybe<string>;\n /** Extension fields to include in the formatted result. */\n extensions: Readonly<GraphQLDirectiveExtensions>;\n /** AST node from which this schema element was built, if available. */\n astNode: Maybe<DirectiveDefinitionNode>;\n /** AST extension nodes applied to this schema element. */\n extensionASTNodes: ReadonlyArray<DirectiveExtensionNode>;\n\n /**\n * Creates a GraphQLDirective instance.\n * @param config - Configuration describing this object.\n * @example\n * ```ts\n * import { DirectiveLocation, parse } from 'graphql/language';\n * import {\n * GraphQLBoolean,\n * GraphQLDirective,\n * GraphQLInt,\n * GraphQLNonNull,\n * } from 'graphql/type';\n *\n * const document = parse(`\n * directive @cacheControl(maxAge: Int) repeatable on FIELD_DEFINITION\n * extend directive @cacheControl(maxAge: Int) on FIELD_DEFINITION\n * `);\n * const definition = document.definitions[0];\n *\n * const cacheControl = new GraphQLDirective({\n * name: 'cacheControl',\n * description: 'Controls HTTP cache hints for a field.',\n * locations: [DirectiveLocation.FIELD_DEFINITION],\n * args: {\n * inheritMaxAge: {\n * description: 'Inherit the parent cache hint.',\n * type: new GraphQLNonNull(GraphQLBoolean),\n * default: { value: false },\n * deprecationReason: 'Use maxAge instead.',\n * extensions: { scope: 'cache' },\n * },\n * maxAge: {\n * type: GraphQLInt,\n * astNode: definition.arguments[0],\n * },\n * },\n * isRepeatable: true,\n * deprecationReason: 'Use @cache instead.',\n * extensions: { scope: 'cache' },\n * astNode: definition,\n * extensionASTNodes: [ document.definitions[1] ],\n * });\n *\n * cacheControl.name; // => 'cacheControl'\n * cacheControl.description; // => 'Controls HTTP cache hints for a field.'\n * cacheControl.args[0].name; // => 'inheritMaxAge'\n * cacheControl.args[0].default.value; // => false\n * cacheControl.isRepeatable; // => true\n * cacheControl.extensions; // => { scope: 'cache' }\n * ```\n */\n constructor(config: Readonly<GraphQLDirectiveConfig>) {\n this.__kind = directiveSymbol;\n this.name = assertName(config.name);\n this.description = config.description;\n this.locations = config.locations;\n this.isRepeatable = config.isRepeatable ?? false;\n this.deprecationReason = config.deprecationReason;\n this.extensions = toObjMapWithSymbols(config.extensions);\n this.astNode = config.astNode;\n this.extensionASTNodes = config.extensionASTNodes ?? [];\n\n devAssert(\n Array.isArray(config.locations),\n `@${this.name} locations must be an Array.`,\n );\n\n const args = config.args ?? {};\n devAssert(\n isObjectLike(args) && !Array.isArray(args),\n `@${this.name} args must be an object with argument names as keys.`,\n );\n\n this.args = Object.entries(args).map(\n ([argName, argConfig]) => new GraphQLArgument(this, argName, argConfig),\n );\n }\n\n /**\n * Returns the value used by `Object.prototype.toString`.\n * @returns The built-in string tag for this object.\n */\n get [Symbol.toStringTag](): string {\n return 'GraphQLDirective';\n }\n\n /**\n * Returns a normalized configuration object for this object.\n * @returns A configuration object that can be used to recreate this object.\n * @example\n * ```ts\n * import { DirectiveLocation } from 'graphql/language';\n * import { GraphQLDirective, GraphQLString } from 'graphql/type';\n *\n * const tag = new GraphQLDirective({\n * name: 'tag',\n * locations: [DirectiveLocation.FIELD_DEFINITION],\n * args: {\n * name: { type: GraphQLString },\n * },\n * });\n *\n * const config = tag.toConfig();\n * const tagCopy = new GraphQLDirective(config);\n *\n * config.args.name.type; // => GraphQLString\n * tagCopy.args[0].name; // => 'name'\n * ```\n */\n toConfig(): GraphQLDirectiveNormalizedConfig {\n return {\n name: this.name,\n description: this.description,\n locations: this.locations,\n args: keyValMap(\n this.args,\n (arg) => arg.name,\n (arg) => arg.toConfig(),\n ),\n isRepeatable: this.isRepeatable,\n deprecationReason: this.deprecationReason,\n extensions: this.extensions,\n astNode: this.astNode,\n extensionASTNodes: this.extensionASTNodes,\n };\n }\n\n /**\n * Returns the schema coordinate identifying this directive.\n * @returns The directive schema coordinate.\n * @example\n * ```ts\n * import { DirectiveLocation } from 'graphql/language';\n * import { GraphQLDirective } from 'graphql/type';\n *\n * const tag = new GraphQLDirective({\n * name: 'tag',\n * locations: [DirectiveLocation.FIELD_DEFINITION],\n * });\n *\n * tag.toString(); // => '@tag'\n * ```\n */\n toString(): string {\n return '@' + this.name;\n }\n\n /**\n * Returns the JSON representation used when this object is serialized.\n * @returns The JSON-serializable representation.\n * @example\n * ```ts\n * import { DirectiveLocation } from 'graphql/language';\n * import { GraphQLDirective } from 'graphql/type';\n *\n * const tag = new GraphQLDirective({\n * name: 'tag',\n * locations: [DirectiveLocation.FIELD_DEFINITION],\n * });\n *\n * tag.toJSON(); // => '@tag'\n * JSON.stringify({ directive: tag }); // => '{\"directive\":\"@tag\"}'\n * ```\n */\n toJSON(): string {\n return this.toString();\n }\n}\n\n/** Configuration used to construct a GraphQLDirective. */\nexport interface GraphQLDirectiveConfig {\n /** The GraphQL name for this schema element. */\n name: string;\n /** Human-readable description for this schema element, if provided. */\n description?: Maybe<string>;\n /** Locations where this directive may be applied. */\n locations: ReadonlyArray<DirectiveLocation>;\n /** Arguments accepted by this field or directive. */\n args?: Maybe<ObjMap<GraphQLArgumentConfig>>;\n /** Whether this directive may appear more than once at the same location. */\n isRepeatable?: Maybe<boolean>;\n /** Reason this element is deprecated, if one was provided. */\n deprecationReason?: Maybe<string>;\n /** Extension fields to include in the formatted result. */\n extensions?: Maybe<Readonly<GraphQLDirectiveExtensions>>;\n /** AST node from which this schema element was built, if available. */\n astNode?: Maybe<DirectiveDefinitionNode>;\n /** AST extension nodes applied to this schema element. */\n extensionASTNodes?: Maybe<ReadonlyArray<DirectiveExtensionNode>>;\n}\n\n/** @internal */\nexport interface GraphQLDirectiveNormalizedConfig extends GraphQLDirectiveConfig {\n args: GraphQLFieldNormalizedConfigArgumentMap;\n isRepeatable: boolean;\n extensions: Readonly<GraphQLDirectiveExtensions>;\n extensionASTNodes: ReadonlyArray<DirectiveExtensionNode>;\n}\n\n/** Used to conditionally include fields or fragments. */\nexport const GraphQLIncludeDirective: GraphQLDirective = new GraphQLDirective({\n name: 'include',\n description:\n 'Directs the executor to include this field or fragment only when the `if` argument is true.',\n locations: [\n DirectiveLocation.FIELD,\n DirectiveLocation.FRAGMENT_SPREAD,\n DirectiveLocation.INLINE_FRAGMENT,\n ],\n args: {\n if: {\n type: new GraphQLNonNull(GraphQLBoolean),\n description: 'Included when true.',\n },\n },\n});\n\n/** Used to conditionally skip (exclude) fields or fragments. */\nexport const GraphQLSkipDirective: GraphQLDirective = new GraphQLDirective({\n name: 'skip',\n description:\n 'Directs the executor to skip this field or fragment when the `if` argument is true.',\n locations: [\n DirectiveLocation.FIELD,\n DirectiveLocation.FRAGMENT_SPREAD,\n DirectiveLocation.INLINE_FRAGMENT,\n ],\n args: {\n if: {\n type: new GraphQLNonNull(GraphQLBoolean),\n description: 'Skipped when true.',\n },\n },\n});\n\n/**\n * Experimental directive used to conditionally defer fragments.\n *\n * This directive is exported for schemas that explicitly opt in to incremental\n * delivery. It is not included in `specifiedDirectives`.\n */\nexport const GraphQLDeferDirective: GraphQLDirective = new GraphQLDirective({\n name: 'defer',\n description:\n 'Directs the executor to defer this fragment when the `if` argument is true or undefined.',\n locations: [\n DirectiveLocation.FRAGMENT_SPREAD,\n DirectiveLocation.INLINE_FRAGMENT,\n ],\n args: {\n if: {\n type: new GraphQLNonNull(GraphQLBoolean),\n description: 'Deferred when true or undefined.',\n default: { value: true },\n },\n label: {\n type: GraphQLString,\n description: 'Unique name',\n },\n },\n});\n\n/**\n * Experimental directive used to conditionally stream list fields.\n *\n * This directive is exported for schemas that explicitly opt in to incremental\n * delivery. It is not included in `specifiedDirectives`.\n */\nexport const GraphQLStreamDirective: GraphQLDirective = new GraphQLDirective({\n name: 'stream',\n description:\n 'Directs the executor to stream plural fields when the `if` argument is true or undefined.',\n locations: [DirectiveLocation.FIELD],\n args: {\n initialCount: {\n default: { value: 0 },\n type: new GraphQLNonNull(GraphQLInt),\n description: 'Number of items to return immediately',\n },\n if: {\n type: new GraphQLNonNull(GraphQLBoolean),\n description: 'Stream when true or undefined.',\n default: { value: true },\n },\n label: {\n type: GraphQLString,\n description: 'Unique name',\n },\n },\n});\n\n/** Constant string used for default reason for a deprecation. */\nexport const DEFAULT_DEPRECATION_REASON = 'No longer supported';\n\n/**\n * Used to declare element of a GraphQL schema as deprecated.\n *\n * The `reason` argument is non-null and defaults to\n * `DEFAULT_DEPRECATION_REASON`.\n */\nexport const GraphQLDeprecatedDirective: GraphQLDirective =\n new GraphQLDirective({\n name: 'deprecated',\n description: 'Marks an element of a GraphQL schema as no longer supported.',\n locations: [\n DirectiveLocation.FIELD_DEFINITION,\n DirectiveLocation.ARGUMENT_DEFINITION,\n DirectiveLocation.INPUT_FIELD_DEFINITION,\n DirectiveLocation.ENUM_VALUE,\n DirectiveLocation.DIRECTIVE_DEFINITION,\n ],\n args: {\n reason: {\n type: new GraphQLNonNull(GraphQLString),\n description:\n 'Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).',\n default: { value: DEFAULT_DEPRECATION_REASON },\n },\n },\n });\n\n/** Used to provide a URL for specifying the behavior of custom scalar definitions. */\nexport const GraphQLSpecifiedByDirective: GraphQLDirective =\n new GraphQLDirective({\n name: 'specifiedBy',\n description: 'Exposes a URL that specifies the behavior of this scalar.',\n locations: [DirectiveLocation.SCALAR],\n args: {\n url: {\n type: new GraphQLNonNull(GraphQLString),\n description: 'The URL that specifies the behavior of this scalar.',\n },\n },\n });\n\n/** Used to indicate an Input Object is a OneOf Input Object. */\nexport const GraphQLOneOfDirective: GraphQLDirective = new GraphQLDirective({\n name: 'oneOf',\n description:\n 'Indicates exactly one field must be supplied and this field must not be `null`.',\n locations: [DirectiveLocation.INPUT_OBJECT],\n args: {},\n});\n\n/**\n * Disables error propagation (experimental).\n *\n * @internal\n */\nexport const GraphQLDisableErrorPropagationDirective: GraphQLDirective =\n new GraphQLDirective({\n name: 'experimental_disableErrorPropagation',\n description: 'Disables error propagation.',\n locations: [\n DirectiveLocation.QUERY,\n DirectiveLocation.MUTATION,\n DirectiveLocation.SUBSCRIPTION,\n ],\n });\n\n/**\n * Full list of stable directives specified by GraphQL.js.\n *\n * Experimental `@defer` and `@stream` are exported separately and are not\n * included in this list.\n */\nexport const specifiedDirectives: ReadonlyArray<GraphQLDirective> =\n Object.freeze([\n GraphQLIncludeDirective,\n GraphQLSkipDirective,\n GraphQLDeprecatedDirective,\n GraphQLSpecifiedByDirective,\n GraphQLOneOfDirective,\n ]);\n\n/**\n * Returns true when the directive is one of the directives specified by GraphQL.\n * @param directive - Directive to inspect.\n * @returns True when the directive is specified by GraphQL.\n * @example\n * ```ts\n * import {\n * GraphQLDirective,\n * GraphQLIncludeDirective,\n * isSpecifiedDirective,\n * } from 'graphql/type';\n * import { DirectiveLocation } from 'graphql/language';\n *\n * const customDirective = new GraphQLDirective({\n * name: 'auth',\n * locations: [DirectiveLocation.FIELD_DEFINITION],\n * });\n *\n * isSpecifiedDirective(GraphQLIncludeDirective); // => true\n * isSpecifiedDirective(customDirective); // => false\n * ```\n */\nexport function isSpecifiedDirective(directive: GraphQLDirective): boolean {\n return specifiedDirectives.some(({ name }) => name === directive.name);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"directives.js","sourceRoot":"","sources":["../../src/type/directives.ts"],"names":[],"mappings":";;;AA+CA,kCAEC;AAoBD,0CAOC;AAwbD,oDAEC;AApgBD,0DAAoD;AACpD,sDAAgD;AAChD,4DAAsD;AACtD,gEAA0D;AAC1D,0DAAoD;AAGpD,wDAA6D;AAM7D,2EAAqE;AAErE,mDAA6C;AAM7C,mDAAkE;AAClE,6CAAyE;AAGzE,MAAM,eAAe,GAAkB,MAAM,CAAC,WAAW,CAAC,CAAC;AAoB3D,SAAgB,WAAW,CAAC,SAAkB;IAC5C,OAAO,IAAA,0BAAU,EAAC,SAAS,EAAE,eAAe,EAAE,gBAAgB,CAAC,CAAC;AAClE,CAAC;AAoBD,SAAgB,eAAe,CAAC,SAAkB;IAChD,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CACb,YAAY,IAAA,oBAAO,EAAC,SAAS,CAAC,6BAA6B,CAC5D,CAAC;IACJ,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAkBD,MAAa,gBAAgB;IA4E3B,YAAY,MAAwC;QAClD,IAAI,CAAC,MAAM,GAAG,eAAe,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAA,0BAAU,EAAC,MAAM,CAAC,IAAI,CAAC,CA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AC","sourcesContent":["/** @category Directives */\n\nimport { devAssert } from '../jsutils/devAssert.ts';\nimport { inspect } from '../jsutils/inspect.ts';\nimport { instanceOf } from '../jsutils/instanceOf.ts';\nimport { isObjectLike } from '../jsutils/isObjectLike.ts';\nimport { keyValMap } from '../jsutils/keyValMap.ts';\nimport type { Maybe } from '../jsutils/Maybe.ts';\nimport type { ObjMap } from '../jsutils/ObjMap.ts';\nimport { toObjMapWithSymbols } from '../jsutils/toObjMap.ts';\n\nimport type {\n DirectiveDefinitionNode,\n DirectiveExtensionNode,\n} from '../language/ast.ts';\nimport { DirectiveLocation } from '../language/directiveLocation.ts';\n\nimport { assertName } from './assertName.ts';\nimport type {\n GraphQLArgumentConfig,\n GraphQLFieldNormalizedConfigArgumentMap,\n GraphQLSchemaElement,\n} from './definition.ts';\nimport { GraphQLArgument, GraphQLNonNull } from './definition.ts';\nimport { GraphQLBoolean, GraphQLInt, GraphQLString } from './scalars.ts';\n\n/** @private */\nconst directiveSymbol: unique symbol = Symbol('Directive');\n\n/**\n * Test if the given value is a GraphQL directive.\n * @param directive - Value to inspect.\n * @returns True when the value is a GraphQLDirective.\n * @example\n * ```ts\n * import { DirectiveLocation } from 'graphql/language';\n * import { GraphQLDirective, GraphQLString, isDirective } from 'graphql/type';\n *\n * const upper = new GraphQLDirective({\n * name: 'upper',\n * locations: [DirectiveLocation.FIELD_DEFINITION],\n * });\n *\n * isDirective(upper); // => true\n * isDirective(GraphQLString); // => false\n * ```\n */\nexport function isDirective(directive: unknown): directive is GraphQLDirective {\n return instanceOf(directive, directiveSymbol, GraphQLDirective);\n}\n\n/**\n * Returns the value as a GraphQLDirective, or throws if it is not a directive.\n * @param directive - Value to inspect.\n * @returns The value typed as a GraphQLDirective.\n * @example\n * ```ts\n * import { DirectiveLocation } from 'graphql/language';\n * import { assertDirective, GraphQLDirective, GraphQLString } from 'graphql/type';\n *\n * const upper = new GraphQLDirective({\n * name: 'upper',\n * locations: [DirectiveLocation.FIELD_DEFINITION],\n * });\n *\n * assertDirective(upper); // => upper\n * assertDirective(GraphQLString); // throws an error\n * ```\n */\nexport function assertDirective(directive: unknown): GraphQLDirective {\n if (!isDirective(directive)) {\n throw new Error(\n `Expected ${inspect(directive)} to be a GraphQL directive.`,\n );\n }\n return directive;\n}\n\n/**\n * Custom extensions\n * @remarks\n * Use a unique identifier name for your extension, for example the name of\n * your library or project. Do not use a shortened identifier as this increases\n * the risk of conflicts. We recommend you add at most one extension field,\n * an object which can contain all the values you need.\n */\nexport interface GraphQLDirectiveExtensions {\n [attributeName: string | symbol]: unknown;\n}\n\n/**\n * Directives are used by the GraphQL runtime as a way of modifying execution\n * behavior. Type system creators will usually not create these directly.\n */\nexport class GraphQLDirective implements GraphQLSchemaElement {\n /**\n * Internal runtime marker used to identify GraphQLDirective instances.\n * @private\n */\n readonly __kind: symbol;\n /** The GraphQL name for this schema element. */\n name: string;\n /** Human-readable description for this schema element, if provided. */\n description: Maybe<string>;\n /** Locations where this directive may be applied. */\n locations: ReadonlyArray<DirectiveLocation>;\n /** Arguments accepted by this field or directive. */\n args: ReadonlyArray<GraphQLArgument>;\n /** Whether this directive may appear more than once at the same location. */\n isRepeatable: boolean;\n /** Reason this element is deprecated, if one was provided. */\n deprecationReason: Maybe<string>;\n /** Custom extension fields reserved for users. */\n extensions: Readonly<GraphQLDirectiveExtensions>;\n /** AST node from which this schema element was built, if available. */\n astNode: Maybe<DirectiveDefinitionNode>;\n /** AST extension nodes applied to this schema element. */\n extensionASTNodes: ReadonlyArray<DirectiveExtensionNode>;\n\n /**\n * Creates a GraphQLDirective instance.\n * @param config - Configuration describing this object.\n * @example\n * ```ts\n * import { DirectiveLocation, parse } from 'graphql/language';\n * import {\n * GraphQLBoolean,\n * GraphQLDirective,\n * GraphQLInt,\n * GraphQLNonNull,\n * } from 'graphql/type';\n *\n * const document = parse(`\n * directive @cacheControl(maxAge: Int) repeatable on FIELD_DEFINITION\n * extend directive @cacheControl(maxAge: Int) on FIELD_DEFINITION\n * `);\n * const definition = document.definitions[0];\n *\n * const cacheControl = new GraphQLDirective({\n * name: 'cacheControl',\n * description: 'Controls HTTP cache hints for a field.',\n * locations: [DirectiveLocation.FIELD_DEFINITION],\n * args: {\n * inheritMaxAge: {\n * description: 'Inherit the parent cache hint.',\n * type: new GraphQLNonNull(GraphQLBoolean),\n * default: { value: false },\n * deprecationReason: 'Use maxAge instead.',\n * extensions: { scope: 'cache' },\n * },\n * maxAge: {\n * type: GraphQLInt,\n * astNode: definition.arguments[0],\n * },\n * },\n * isRepeatable: true,\n * deprecationReason: 'Use @cache instead.',\n * extensions: { scope: 'cache' },\n * astNode: definition,\n * extensionASTNodes: [document.definitions[1]],\n * });\n *\n * cacheControl.name; // => 'cacheControl'\n * cacheControl.description; // => 'Controls HTTP cache hints for a field.'\n * cacheControl.args[0].name; // => 'inheritMaxAge'\n * cacheControl.args[0].default.value; // => false\n * cacheControl.isRepeatable; // => true\n * cacheControl.extensions; // => { scope: 'cache' }\n * ```\n */\n constructor(config: Readonly<GraphQLDirectiveConfig>) {\n this.__kind = directiveSymbol;\n this.name = assertName(config.name);\n this.description = config.description;\n this.locations = config.locations;\n this.isRepeatable = config.isRepeatable ?? false;\n this.deprecationReason = config.deprecationReason;\n this.extensions = toObjMapWithSymbols(config.extensions);\n this.astNode = config.astNode;\n this.extensionASTNodes = config.extensionASTNodes ?? [];\n\n devAssert(\n Array.isArray(config.locations),\n `@${this.name} locations must be an Array.`,\n );\n\n const args = config.args ?? {};\n devAssert(\n isObjectLike(args) && !Array.isArray(args),\n `@${this.name} args must be an object with argument names as keys.`,\n );\n\n this.args = Object.entries(args).map(\n ([argName, argConfig]) => new GraphQLArgument(this, argName, argConfig),\n );\n }\n\n /**\n * Returns the value used by `Object.prototype.toString`.\n * @returns The built-in string tag for this object.\n */\n get [Symbol.toStringTag](): string {\n return 'GraphQLDirective';\n }\n\n /**\n * Returns a normalized configuration object for this object.\n * @returns A configuration object that can be used to recreate this object.\n * @example\n * ```ts\n * import { DirectiveLocation } from 'graphql/language';\n * import { GraphQLDirective, GraphQLString } from 'graphql/type';\n *\n * const tag = new GraphQLDirective({\n * name: 'tag',\n * locations: [DirectiveLocation.FIELD_DEFINITION],\n * args: {\n * name: { type: GraphQLString },\n * },\n * });\n *\n * const config = tag.toConfig();\n * const tagCopy = new GraphQLDirective(config);\n *\n * config.args.name.type; // => GraphQLString\n * tagCopy.args[0].name; // => 'name'\n * ```\n */\n toConfig(): GraphQLDirectiveNormalizedConfig {\n return {\n name: this.name,\n description: this.description,\n locations: this.locations,\n args: keyValMap(\n this.args,\n (arg) => arg.name,\n (arg) => arg.toConfig(),\n ),\n isRepeatable: this.isRepeatable,\n deprecationReason: this.deprecationReason,\n extensions: this.extensions,\n astNode: this.astNode,\n extensionASTNodes: this.extensionASTNodes,\n };\n }\n\n /**\n * Returns the schema coordinate identifying this directive.\n * @returns The directive schema coordinate.\n * @example\n * ```ts\n * import { DirectiveLocation } from 'graphql/language';\n * import { GraphQLDirective } from 'graphql/type';\n *\n * const tag = new GraphQLDirective({\n * name: 'tag',\n * locations: [DirectiveLocation.FIELD_DEFINITION],\n * });\n *\n * tag.toString(); // => '@tag'\n * ```\n */\n toString(): string {\n return '@' + this.name;\n }\n\n /**\n * Returns the JSON representation used when this object is serialized.\n * @returns The JSON-serializable representation.\n * @example\n * ```ts\n * import { DirectiveLocation } from 'graphql/language';\n * import { GraphQLDirective } from 'graphql/type';\n *\n * const tag = new GraphQLDirective({\n * name: 'tag',\n * locations: [DirectiveLocation.FIELD_DEFINITION],\n * });\n *\n * tag.toJSON(); // => '@tag'\n * JSON.stringify({ directive: tag }); // => '{\"directive\":\"@tag\"}'\n * ```\n */\n toJSON(): string {\n return this.toString();\n }\n}\n\n/** Configuration used to construct a GraphQLDirective. */\nexport interface GraphQLDirectiveConfig {\n /** The GraphQL name for this schema element. */\n name: string;\n /** Human-readable description for this schema element, if provided. */\n description?: Maybe<string>;\n /** Locations where this directive may be applied. */\n locations: ReadonlyArray<DirectiveLocation>;\n /** Arguments accepted by this field or directive. */\n args?: Maybe<ObjMap<GraphQLArgumentConfig>>;\n /** Whether this directive may appear more than once at the same location. */\n isRepeatable?: Maybe<boolean>;\n /** Reason this element is deprecated, if one was provided. */\n deprecationReason?: Maybe<string>;\n /** Custom extension fields reserved for users. */\n extensions?: Maybe<Readonly<GraphQLDirectiveExtensions>>;\n /** AST node from which this schema element was built, if available. */\n astNode?: Maybe<DirectiveDefinitionNode>;\n /** AST extension nodes applied to this schema element. */\n extensionASTNodes?: Maybe<ReadonlyArray<DirectiveExtensionNode>>;\n}\n\n/** @internal */\nexport interface GraphQLDirectiveNormalizedConfig extends GraphQLDirectiveConfig {\n args: GraphQLFieldNormalizedConfigArgumentMap;\n isRepeatable: boolean;\n extensions: Readonly<GraphQLDirectiveExtensions>;\n extensionASTNodes: ReadonlyArray<DirectiveExtensionNode>;\n}\n\n/** Used to conditionally include fields or fragments. */\nexport const GraphQLIncludeDirective: GraphQLDirective = new GraphQLDirective({\n name: 'include',\n description:\n 'Directs the executor to include this field or fragment only when the `if` argument is true.',\n locations: [\n DirectiveLocation.FIELD,\n DirectiveLocation.FRAGMENT_SPREAD,\n DirectiveLocation.INLINE_FRAGMENT,\n ],\n args: {\n if: {\n type: new GraphQLNonNull(GraphQLBoolean),\n description: 'Included when true.',\n },\n },\n});\n\n/** Used to conditionally skip (exclude) fields or fragments. */\nexport const GraphQLSkipDirective: GraphQLDirective = new GraphQLDirective({\n name: 'skip',\n description:\n 'Directs the executor to skip this field or fragment when the `if` argument is true.',\n locations: [\n DirectiveLocation.FIELD,\n DirectiveLocation.FRAGMENT_SPREAD,\n DirectiveLocation.INLINE_FRAGMENT,\n ],\n args: {\n if: {\n type: new GraphQLNonNull(GraphQLBoolean),\n description: 'Skipped when true.',\n },\n },\n});\n\n/**\n * Experimental directive used to conditionally defer fragments.\n *\n * This directive is exported for schemas that explicitly opt in to incremental\n * delivery. It is not included in `specifiedDirectives`.\n */\nexport const GraphQLDeferDirective: GraphQLDirective = new GraphQLDirective({\n name: 'defer',\n description:\n 'Directs the executor to defer this fragment when the `if` argument is true or undefined.',\n locations: [\n DirectiveLocation.FRAGMENT_SPREAD,\n DirectiveLocation.INLINE_FRAGMENT,\n ],\n args: {\n if: {\n type: new GraphQLNonNull(GraphQLBoolean),\n description: 'Deferred when true or undefined.',\n default: { value: true },\n },\n label: {\n type: GraphQLString,\n description: 'Unique name',\n },\n },\n});\n\n/**\n * Experimental directive used to conditionally stream list fields.\n *\n * This directive is exported for schemas that explicitly opt in to incremental\n * delivery. It is not included in `specifiedDirectives`.\n */\nexport const GraphQLStreamDirective: GraphQLDirective = new GraphQLDirective({\n name: 'stream',\n description:\n 'Directs the executor to stream plural fields when the `if` argument is true or undefined.',\n locations: [DirectiveLocation.FIELD],\n args: {\n initialCount: {\n default: { value: 0 },\n type: new GraphQLNonNull(GraphQLInt),\n description: 'Number of items to return immediately',\n },\n if: {\n type: new GraphQLNonNull(GraphQLBoolean),\n description: 'Stream when true or undefined.',\n default: { value: true },\n },\n label: {\n type: GraphQLString,\n description: 'Unique name',\n },\n },\n});\n\n/** Constant string used for default reason for a deprecation. */\nexport const DEFAULT_DEPRECATION_REASON = 'No longer supported';\n\n/**\n * Used to declare element of a GraphQL schema as deprecated.\n *\n * The `reason` argument is non-null and defaults to\n * `DEFAULT_DEPRECATION_REASON`.\n */\nexport const GraphQLDeprecatedDirective: GraphQLDirective =\n new GraphQLDirective({\n name: 'deprecated',\n description: 'Marks an element of a GraphQL schema as no longer supported.',\n locations: [\n DirectiveLocation.FIELD_DEFINITION,\n DirectiveLocation.ARGUMENT_DEFINITION,\n DirectiveLocation.INPUT_FIELD_DEFINITION,\n DirectiveLocation.ENUM_VALUE,\n DirectiveLocation.DIRECTIVE_DEFINITION,\n ],\n args: {\n reason: {\n type: new GraphQLNonNull(GraphQLString),\n description:\n 'Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).',\n default: { value: DEFAULT_DEPRECATION_REASON },\n },\n },\n });\n\n/** Used to provide a URL for specifying the behavior of custom scalar definitions. */\nexport const GraphQLSpecifiedByDirective: GraphQLDirective =\n new GraphQLDirective({\n name: 'specifiedBy',\n description: 'Exposes a URL that specifies the behavior of this scalar.',\n locations: [DirectiveLocation.SCALAR],\n args: {\n url: {\n type: new GraphQLNonNull(GraphQLString),\n description: 'The URL that specifies the behavior of this scalar.',\n },\n },\n });\n\n/** Used to indicate an Input Object is a OneOf Input Object. */\nexport const GraphQLOneOfDirective: GraphQLDirective = new GraphQLDirective({\n name: 'oneOf',\n description:\n 'Indicates exactly one field must be supplied and this field must not be `null`.',\n locations: [DirectiveLocation.INPUT_OBJECT],\n args: {},\n});\n\n/**\n * Disables error propagation (experimental).\n *\n * @internal\n */\nexport const GraphQLDisableErrorPropagationDirective: GraphQLDirective =\n new GraphQLDirective({\n name: 'experimental_disableErrorPropagation',\n description: 'Disables error propagation.',\n locations: [\n DirectiveLocation.QUERY,\n DirectiveLocation.MUTATION,\n DirectiveLocation.SUBSCRIPTION,\n ],\n });\n\n/**\n * Full list of stable directives specified by GraphQL.js.\n *\n * Experimental `@defer` and `@stream` are exported separately and are not\n * included in this list.\n */\nexport const specifiedDirectives: ReadonlyArray<GraphQLDirective> =\n Object.freeze([\n GraphQLIncludeDirective,\n GraphQLSkipDirective,\n GraphQLDeprecatedDirective,\n GraphQLSpecifiedByDirective,\n GraphQLOneOfDirective,\n ]);\n\n/**\n * Returns true when the directive is one of the directives specified by GraphQL.\n * @param directive - Directive to inspect.\n * @returns True when the directive is specified by GraphQL.\n * @example\n * ```ts\n * import {\n * GraphQLDirective,\n * GraphQLIncludeDirective,\n * isSpecifiedDirective,\n * } from 'graphql/type';\n * import { DirectiveLocation } from 'graphql/language';\n *\n * const customDirective = new GraphQLDirective({\n * name: 'auth',\n * locations: [DirectiveLocation.FIELD_DEFINITION],\n * });\n *\n * isSpecifiedDirective(GraphQLIncludeDirective); // => true\n * isSpecifiedDirective(customDirective); // => false\n * ```\n */\nexport function isSpecifiedDirective(directive: GraphQLDirective): boolean {\n return specifiedDirectives.some(({ name }) => name === directive.name);\n}\n"]}
|
package/type/directives.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directives.js","sourceRoot":"","sources":["../../src/type/directives.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,iCAAgC;AACpD,OAAO,EAAE,OAAO,EAAE,+BAA8B;AAChD,OAAO,EAAE,UAAU,EAAE,kCAAiC;AACtD,OAAO,EAAE,YAAY,EAAE,oCAAmC;AAC1D,OAAO,EAAE,SAAS,EAAE,iCAAgC;AAGpD,OAAO,EAAE,mBAAmB,EAAE,gCAA+B;AAM7D,OAAO,EAAE,iBAAiB,EAAE,0CAAyC;AAErE,OAAO,EAAE,UAAU,EAAE,yBAAwB;AAM7C,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,yBAAwB;AAClE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,aAAa,EAAE,sBAAqB;AAGzE,MAAM,eAAe,GAAkB,MAAM,CAAC,WAAW,CAAC,CAAC;AAoB3D,MAAM,UAAU,WAAW,CAAC,SAAkB;IAC5C,OAAO,UAAU,CAAC,SAAS,EAAE,eAAe,EAAE,gBAAgB,CAAC,CAAC;AAClE,CAAC;AAoBD,MAAM,UAAU,eAAe,CAAC,SAAkB;IAChD,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CACb,YAAY,OAAO,CAAC,SAAS,CAAC,6BAA6B,CAC5D,CAAC;IACJ,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAkBD,MAAM,OAAO,gBAAgB;IA4E3B,YAAY,MAAwC;QAClD,IAAI,CAAC,MAAM,GAAG,eAAe,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,CAA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K,SAAS,CAAC,IAAI,CAAC,CAAC;AACzE,CAAC","sourcesContent":["/** @category Directives */\n\nimport { devAssert } from '../jsutils/devAssert.ts';\nimport { inspect } from '../jsutils/inspect.ts';\nimport { instanceOf } from '../jsutils/instanceOf.ts';\nimport { isObjectLike } from '../jsutils/isObjectLike.ts';\nimport { keyValMap } from '../jsutils/keyValMap.ts';\nimport type { Maybe } from '../jsutils/Maybe.ts';\nimport type { ObjMap } from '../jsutils/ObjMap.ts';\nimport { toObjMapWithSymbols } from '../jsutils/toObjMap.ts';\n\nimport type {\n DirectiveDefinitionNode,\n DirectiveExtensionNode,\n} from '../language/ast.ts';\nimport { DirectiveLocation } from '../language/directiveLocation.ts';\n\nimport { assertName } from './assertName.ts';\nimport type {\n GraphQLArgumentConfig,\n GraphQLFieldNormalizedConfigArgumentMap,\n GraphQLSchemaElement,\n} from './definition.ts';\nimport { GraphQLArgument, GraphQLNonNull } from './definition.ts';\nimport { GraphQLBoolean, GraphQLInt, GraphQLString } from './scalars.ts';\n\n/** @private */\nconst directiveSymbol: unique symbol = Symbol('Directive');\n\n/**\n * Test if the given value is a GraphQL directive.\n * @param directive - Value to inspect.\n * @returns True when the value is a GraphQLDirective.\n * @example\n * ```ts\n * import { DirectiveLocation } from 'graphql/language';\n * import { GraphQLDirective, GraphQLString, isDirective } from 'graphql/type';\n *\n * const upper = new GraphQLDirective({\n * name: 'upper',\n * locations: [DirectiveLocation.FIELD_DEFINITION],\n * });\n *\n * isDirective(upper); // => true\n * isDirective(GraphQLString); // => false\n * ```\n */\nexport function isDirective(directive: unknown): directive is GraphQLDirective {\n return instanceOf(directive, directiveSymbol, GraphQLDirective);\n}\n\n/**\n * Returns the value as a GraphQLDirective, or throws if it is not a directive.\n * @param directive - Value to inspect.\n * @returns The value typed as a GraphQLDirective.\n * @example\n * ```ts\n * import { DirectiveLocation } from 'graphql/language';\n * import { assertDirective, GraphQLDirective, GraphQLString } from 'graphql/type';\n *\n * const upper = new GraphQLDirective({\n * name: 'upper',\n * locations: [DirectiveLocation.FIELD_DEFINITION],\n * });\n *\n * assertDirective(upper); // => upper\n * assertDirective(GraphQLString); // throws an error\n * ```\n */\nexport function assertDirective(directive: unknown): GraphQLDirective {\n if (!isDirective(directive)) {\n throw new Error(\n `Expected ${inspect(directive)} to be a GraphQL directive.`,\n );\n }\n return directive;\n}\n\n/**\n * Custom extensions\n * @remarks\n * Use a unique identifier name for your extension, for example the name of\n * your library or project. Do not use a shortened identifier as this increases\n * the risk of conflicts. We recommend you add at most one extension field,\n * an object which can contain all the values you need.\n */\nexport interface GraphQLDirectiveExtensions {\n [attributeName: string | symbol]: unknown;\n}\n\n/**\n * Directives are used by the GraphQL runtime as a way of modifying execution\n * behavior. Type system creators will usually not create these directly.\n */\nexport class GraphQLDirective implements GraphQLSchemaElement {\n /**\n * Internal runtime marker used to identify GraphQLDirective instances.\n * @private\n */\n readonly __kind: symbol;\n /** The GraphQL name for this schema element. */\n name: string;\n /** Human-readable description for this schema element, if provided. */\n description: Maybe<string>;\n /** Locations where this directive may be applied. */\n locations: ReadonlyArray<DirectiveLocation>;\n /** Arguments accepted by this field or directive. */\n args: ReadonlyArray<GraphQLArgument>;\n /** Whether this directive may appear more than once at the same location. */\n isRepeatable: boolean;\n /** Reason this element is deprecated, if one was provided. */\n deprecationReason: Maybe<string>;\n /** Extension fields to include in the formatted result. */\n extensions: Readonly<GraphQLDirectiveExtensions>;\n /** AST node from which this schema element was built, if available. */\n astNode: Maybe<DirectiveDefinitionNode>;\n /** AST extension nodes applied to this schema element. */\n extensionASTNodes: ReadonlyArray<DirectiveExtensionNode>;\n\n /**\n * Creates a GraphQLDirective instance.\n * @param config - Configuration describing this object.\n * @example\n * ```ts\n * import { DirectiveLocation, parse } from 'graphql/language';\n * import {\n * GraphQLBoolean,\n * GraphQLDirective,\n * GraphQLInt,\n * GraphQLNonNull,\n * } from 'graphql/type';\n *\n * const document = parse(`\n * directive @cacheControl(maxAge: Int) repeatable on FIELD_DEFINITION\n * extend directive @cacheControl(maxAge: Int) on FIELD_DEFINITION\n * `);\n * const definition = document.definitions[0];\n *\n * const cacheControl = new GraphQLDirective({\n * name: 'cacheControl',\n * description: 'Controls HTTP cache hints for a field.',\n * locations: [DirectiveLocation.FIELD_DEFINITION],\n * args: {\n * inheritMaxAge: {\n * description: 'Inherit the parent cache hint.',\n * type: new GraphQLNonNull(GraphQLBoolean),\n * default: { value: false },\n * deprecationReason: 'Use maxAge instead.',\n * extensions: { scope: 'cache' },\n * },\n * maxAge: {\n * type: GraphQLInt,\n * astNode: definition.arguments[0],\n * },\n * },\n * isRepeatable: true,\n * deprecationReason: 'Use @cache instead.',\n * extensions: { scope: 'cache' },\n * astNode: definition,\n * extensionASTNodes: [ document.definitions[1] ],\n * });\n *\n * cacheControl.name; // => 'cacheControl'\n * cacheControl.description; // => 'Controls HTTP cache hints for a field.'\n * cacheControl.args[0].name; // => 'inheritMaxAge'\n * cacheControl.args[0].default.value; // => false\n * cacheControl.isRepeatable; // => true\n * cacheControl.extensions; // => { scope: 'cache' }\n * ```\n */\n constructor(config: Readonly<GraphQLDirectiveConfig>) {\n this.__kind = directiveSymbol;\n this.name = assertName(config.name);\n this.description = config.description;\n this.locations = config.locations;\n this.isRepeatable = config.isRepeatable ?? false;\n this.deprecationReason = config.deprecationReason;\n this.extensions = toObjMapWithSymbols(config.extensions);\n this.astNode = config.astNode;\n this.extensionASTNodes = config.extensionASTNodes ?? [];\n\n devAssert(\n Array.isArray(config.locations),\n `@${this.name} locations must be an Array.`,\n );\n\n const args = config.args ?? {};\n devAssert(\n isObjectLike(args) && !Array.isArray(args),\n `@${this.name} args must be an object with argument names as keys.`,\n );\n\n this.args = Object.entries(args).map(\n ([argName, argConfig]) => new GraphQLArgument(this, argName, argConfig),\n );\n }\n\n /**\n * Returns the value used by `Object.prototype.toString`.\n * @returns The built-in string tag for this object.\n */\n get [Symbol.toStringTag](): string {\n return 'GraphQLDirective';\n }\n\n /**\n * Returns a normalized configuration object for this object.\n * @returns A configuration object that can be used to recreate this object.\n * @example\n * ```ts\n * import { DirectiveLocation } from 'graphql/language';\n * import { GraphQLDirective, GraphQLString } from 'graphql/type';\n *\n * const tag = new GraphQLDirective({\n * name: 'tag',\n * locations: [DirectiveLocation.FIELD_DEFINITION],\n * args: {\n * name: { type: GraphQLString },\n * },\n * });\n *\n * const config = tag.toConfig();\n * const tagCopy = new GraphQLDirective(config);\n *\n * config.args.name.type; // => GraphQLString\n * tagCopy.args[0].name; // => 'name'\n * ```\n */\n toConfig(): GraphQLDirectiveNormalizedConfig {\n return {\n name: this.name,\n description: this.description,\n locations: this.locations,\n args: keyValMap(\n this.args,\n (arg) => arg.name,\n (arg) => arg.toConfig(),\n ),\n isRepeatable: this.isRepeatable,\n deprecationReason: this.deprecationReason,\n extensions: this.extensions,\n astNode: this.astNode,\n extensionASTNodes: this.extensionASTNodes,\n };\n }\n\n /**\n * Returns the schema coordinate identifying this directive.\n * @returns The directive schema coordinate.\n * @example\n * ```ts\n * import { DirectiveLocation } from 'graphql/language';\n * import { GraphQLDirective } from 'graphql/type';\n *\n * const tag = new GraphQLDirective({\n * name: 'tag',\n * locations: [DirectiveLocation.FIELD_DEFINITION],\n * });\n *\n * tag.toString(); // => '@tag'\n * ```\n */\n toString(): string {\n return '@' + this.name;\n }\n\n /**\n * Returns the JSON representation used when this object is serialized.\n * @returns The JSON-serializable representation.\n * @example\n * ```ts\n * import { DirectiveLocation } from 'graphql/language';\n * import { GraphQLDirective } from 'graphql/type';\n *\n * const tag = new GraphQLDirective({\n * name: 'tag',\n * locations: [DirectiveLocation.FIELD_DEFINITION],\n * });\n *\n * tag.toJSON(); // => '@tag'\n * JSON.stringify({ directive: tag }); // => '{\"directive\":\"@tag\"}'\n * ```\n */\n toJSON(): string {\n return this.toString();\n }\n}\n\n/** Configuration used to construct a GraphQLDirective. */\nexport interface GraphQLDirectiveConfig {\n /** The GraphQL name for this schema element. */\n name: string;\n /** Human-readable description for this schema element, if provided. */\n description?: Maybe<string>;\n /** Locations where this directive may be applied. */\n locations: ReadonlyArray<DirectiveLocation>;\n /** Arguments accepted by this field or directive. */\n args?: Maybe<ObjMap<GraphQLArgumentConfig>>;\n /** Whether this directive may appear more than once at the same location. */\n isRepeatable?: Maybe<boolean>;\n /** Reason this element is deprecated, if one was provided. */\n deprecationReason?: Maybe<string>;\n /** Extension fields to include in the formatted result. */\n extensions?: Maybe<Readonly<GraphQLDirectiveExtensions>>;\n /** AST node from which this schema element was built, if available. */\n astNode?: Maybe<DirectiveDefinitionNode>;\n /** AST extension nodes applied to this schema element. */\n extensionASTNodes?: Maybe<ReadonlyArray<DirectiveExtensionNode>>;\n}\n\n/** @internal */\nexport interface GraphQLDirectiveNormalizedConfig extends GraphQLDirectiveConfig {\n args: GraphQLFieldNormalizedConfigArgumentMap;\n isRepeatable: boolean;\n extensions: Readonly<GraphQLDirectiveExtensions>;\n extensionASTNodes: ReadonlyArray<DirectiveExtensionNode>;\n}\n\n/** Used to conditionally include fields or fragments. */\nexport const GraphQLIncludeDirective: GraphQLDirective = new GraphQLDirective({\n name: 'include',\n description:\n 'Directs the executor to include this field or fragment only when the `if` argument is true.',\n locations: [\n DirectiveLocation.FIELD,\n DirectiveLocation.FRAGMENT_SPREAD,\n DirectiveLocation.INLINE_FRAGMENT,\n ],\n args: {\n if: {\n type: new GraphQLNonNull(GraphQLBoolean),\n description: 'Included when true.',\n },\n },\n});\n\n/** Used to conditionally skip (exclude) fields or fragments. */\nexport const GraphQLSkipDirective: GraphQLDirective = new GraphQLDirective({\n name: 'skip',\n description:\n 'Directs the executor to skip this field or fragment when the `if` argument is true.',\n locations: [\n DirectiveLocation.FIELD,\n DirectiveLocation.FRAGMENT_SPREAD,\n DirectiveLocation.INLINE_FRAGMENT,\n ],\n args: {\n if: {\n type: new GraphQLNonNull(GraphQLBoolean),\n description: 'Skipped when true.',\n },\n },\n});\n\n/**\n * Experimental directive used to conditionally defer fragments.\n *\n * This directive is exported for schemas that explicitly opt in to incremental\n * delivery. It is not included in `specifiedDirectives`.\n */\nexport const GraphQLDeferDirective: GraphQLDirective = new GraphQLDirective({\n name: 'defer',\n description:\n 'Directs the executor to defer this fragment when the `if` argument is true or undefined.',\n locations: [\n DirectiveLocation.FRAGMENT_SPREAD,\n DirectiveLocation.INLINE_FRAGMENT,\n ],\n args: {\n if: {\n type: new GraphQLNonNull(GraphQLBoolean),\n description: 'Deferred when true or undefined.',\n default: { value: true },\n },\n label: {\n type: GraphQLString,\n description: 'Unique name',\n },\n },\n});\n\n/**\n * Experimental directive used to conditionally stream list fields.\n *\n * This directive is exported for schemas that explicitly opt in to incremental\n * delivery. It is not included in `specifiedDirectives`.\n */\nexport const GraphQLStreamDirective: GraphQLDirective = new GraphQLDirective({\n name: 'stream',\n description:\n 'Directs the executor to stream plural fields when the `if` argument is true or undefined.',\n locations: [DirectiveLocation.FIELD],\n args: {\n initialCount: {\n default: { value: 0 },\n type: new GraphQLNonNull(GraphQLInt),\n description: 'Number of items to return immediately',\n },\n if: {\n type: new GraphQLNonNull(GraphQLBoolean),\n description: 'Stream when true or undefined.',\n default: { value: true },\n },\n label: {\n type: GraphQLString,\n description: 'Unique name',\n },\n },\n});\n\n/** Constant string used for default reason for a deprecation. */\nexport const DEFAULT_DEPRECATION_REASON = 'No longer supported';\n\n/**\n * Used to declare element of a GraphQL schema as deprecated.\n *\n * The `reason` argument is non-null and defaults to\n * `DEFAULT_DEPRECATION_REASON`.\n */\nexport const GraphQLDeprecatedDirective: GraphQLDirective =\n new GraphQLDirective({\n name: 'deprecated',\n description: 'Marks an element of a GraphQL schema as no longer supported.',\n locations: [\n DirectiveLocation.FIELD_DEFINITION,\n DirectiveLocation.ARGUMENT_DEFINITION,\n DirectiveLocation.INPUT_FIELD_DEFINITION,\n DirectiveLocation.ENUM_VALUE,\n DirectiveLocation.DIRECTIVE_DEFINITION,\n ],\n args: {\n reason: {\n type: new GraphQLNonNull(GraphQLString),\n description:\n 'Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).',\n default: { value: DEFAULT_DEPRECATION_REASON },\n },\n },\n });\n\n/** Used to provide a URL for specifying the behavior of custom scalar definitions. */\nexport const GraphQLSpecifiedByDirective: GraphQLDirective =\n new GraphQLDirective({\n name: 'specifiedBy',\n description: 'Exposes a URL that specifies the behavior of this scalar.',\n locations: [DirectiveLocation.SCALAR],\n args: {\n url: {\n type: new GraphQLNonNull(GraphQLString),\n description: 'The URL that specifies the behavior of this scalar.',\n },\n },\n });\n\n/** Used to indicate an Input Object is a OneOf Input Object. */\nexport const GraphQLOneOfDirective: GraphQLDirective = new GraphQLDirective({\n name: 'oneOf',\n description:\n 'Indicates exactly one field must be supplied and this field must not be `null`.',\n locations: [DirectiveLocation.INPUT_OBJECT],\n args: {},\n});\n\n/**\n * Disables error propagation (experimental).\n *\n * @internal\n */\nexport const GraphQLDisableErrorPropagationDirective: GraphQLDirective =\n new GraphQLDirective({\n name: 'experimental_disableErrorPropagation',\n description: 'Disables error propagation.',\n locations: [\n DirectiveLocation.QUERY,\n DirectiveLocation.MUTATION,\n DirectiveLocation.SUBSCRIPTION,\n ],\n });\n\n/**\n * Full list of stable directives specified by GraphQL.js.\n *\n * Experimental `@defer` and `@stream` are exported separately and are not\n * included in this list.\n */\nexport const specifiedDirectives: ReadonlyArray<GraphQLDirective> =\n Object.freeze([\n GraphQLIncludeDirective,\n GraphQLSkipDirective,\n GraphQLDeprecatedDirective,\n GraphQLSpecifiedByDirective,\n GraphQLOneOfDirective,\n ]);\n\n/**\n * Returns true when the directive is one of the directives specified by GraphQL.\n * @param directive - Directive to inspect.\n * @returns True when the directive is specified by GraphQL.\n * @example\n * ```ts\n * import {\n * GraphQLDirective,\n * GraphQLIncludeDirective,\n * isSpecifiedDirective,\n * } from 'graphql/type';\n * import { DirectiveLocation } from 'graphql/language';\n *\n * const customDirective = new GraphQLDirective({\n * name: 'auth',\n * locations: [DirectiveLocation.FIELD_DEFINITION],\n * });\n *\n * isSpecifiedDirective(GraphQLIncludeDirective); // => true\n * isSpecifiedDirective(customDirective); // => false\n * ```\n */\nexport function isSpecifiedDirective(directive: GraphQLDirective): boolean {\n return specifiedDirectives.some(({ name }) => name === directive.name);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"directives.js","sourceRoot":"","sources":["../../src/type/directives.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,iCAAgC;AACpD,OAAO,EAAE,OAAO,EAAE,+BAA8B;AAChD,OAAO,EAAE,UAAU,EAAE,kCAAiC;AACtD,OAAO,EAAE,YAAY,EAAE,oCAAmC;AAC1D,OAAO,EAAE,SAAS,EAAE,iCAAgC;AAGpD,OAAO,EAAE,mBAAmB,EAAE,gCAA+B;AAM7D,OAAO,EAAE,iBAAiB,EAAE,0CAAyC;AAErE,OAAO,EAAE,UAAU,EAAE,yBAAwB;AAM7C,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,yBAAwB;AAClE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,aAAa,EAAE,sBAAqB;AAGzE,MAAM,eAAe,GAAkB,MAAM,CAAC,WAAW,CAAC,CAAC;AAoB3D,MAAM,UAAU,WAAW,CAAC,SAAkB;IAC5C,OAAO,UAAU,CAAC,SAAS,EAAE,eAAe,EAAE,gBAAgB,CAAC,CAAC;AAClE,CAAC;AAoBD,MAAM,UAAU,eAAe,CAAC,SAAkB;IAChD,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CACb,YAAY,OAAO,CAAC,SAAS,CAAC,6BAA6B,CAC5D,CAAC;IACJ,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAkBD,MAAM,OAAO,gBAAgB;IA4E3B,YAAY,MAAwC;QAClD,IAAI,CAAC,MAAM,GAAG,eAAe,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,CA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AK,SAAS,CAAC,IAAI,CAAC,CAAC;AACzE,CAAC","sourcesContent":["/** @category Directives */\n\nimport { devAssert } from '../jsutils/devAssert.ts';\nimport { inspect } from '../jsutils/inspect.ts';\nimport { instanceOf } from '../jsutils/instanceOf.ts';\nimport { isObjectLike } from '../jsutils/isObjectLike.ts';\nimport { keyValMap } from '../jsutils/keyValMap.ts';\nimport type { Maybe } from '../jsutils/Maybe.ts';\nimport type { ObjMap } from '../jsutils/ObjMap.ts';\nimport { toObjMapWithSymbols } from '../jsutils/toObjMap.ts';\n\nimport type {\n DirectiveDefinitionNode,\n DirectiveExtensionNode,\n} from '../language/ast.ts';\nimport { DirectiveLocation } from '../language/directiveLocation.ts';\n\nimport { assertName } from './assertName.ts';\nimport type {\n GraphQLArgumentConfig,\n GraphQLFieldNormalizedConfigArgumentMap,\n GraphQLSchemaElement,\n} from './definition.ts';\nimport { GraphQLArgument, GraphQLNonNull } from './definition.ts';\nimport { GraphQLBoolean, GraphQLInt, GraphQLString } from './scalars.ts';\n\n/** @private */\nconst directiveSymbol: unique symbol = Symbol('Directive');\n\n/**\n * Test if the given value is a GraphQL directive.\n * @param directive - Value to inspect.\n * @returns True when the value is a GraphQLDirective.\n * @example\n * ```ts\n * import { DirectiveLocation } from 'graphql/language';\n * import { GraphQLDirective, GraphQLString, isDirective } from 'graphql/type';\n *\n * const upper = new GraphQLDirective({\n * name: 'upper',\n * locations: [DirectiveLocation.FIELD_DEFINITION],\n * });\n *\n * isDirective(upper); // => true\n * isDirective(GraphQLString); // => false\n * ```\n */\nexport function isDirective(directive: unknown): directive is GraphQLDirective {\n return instanceOf(directive, directiveSymbol, GraphQLDirective);\n}\n\n/**\n * Returns the value as a GraphQLDirective, or throws if it is not a directive.\n * @param directive - Value to inspect.\n * @returns The value typed as a GraphQLDirective.\n * @example\n * ```ts\n * import { DirectiveLocation } from 'graphql/language';\n * import { assertDirective, GraphQLDirective, GraphQLString } from 'graphql/type';\n *\n * const upper = new GraphQLDirective({\n * name: 'upper',\n * locations: [DirectiveLocation.FIELD_DEFINITION],\n * });\n *\n * assertDirective(upper); // => upper\n * assertDirective(GraphQLString); // throws an error\n * ```\n */\nexport function assertDirective(directive: unknown): GraphQLDirective {\n if (!isDirective(directive)) {\n throw new Error(\n `Expected ${inspect(directive)} to be a GraphQL directive.`,\n );\n }\n return directive;\n}\n\n/**\n * Custom extensions\n * @remarks\n * Use a unique identifier name for your extension, for example the name of\n * your library or project. Do not use a shortened identifier as this increases\n * the risk of conflicts. We recommend you add at most one extension field,\n * an object which can contain all the values you need.\n */\nexport interface GraphQLDirectiveExtensions {\n [attributeName: string | symbol]: unknown;\n}\n\n/**\n * Directives are used by the GraphQL runtime as a way of modifying execution\n * behavior. Type system creators will usually not create these directly.\n */\nexport class GraphQLDirective implements GraphQLSchemaElement {\n /**\n * Internal runtime marker used to identify GraphQLDirective instances.\n * @private\n */\n readonly __kind: symbol;\n /** The GraphQL name for this schema element. */\n name: string;\n /** Human-readable description for this schema element, if provided. */\n description: Maybe<string>;\n /** Locations where this directive may be applied. */\n locations: ReadonlyArray<DirectiveLocation>;\n /** Arguments accepted by this field or directive. */\n args: ReadonlyArray<GraphQLArgument>;\n /** Whether this directive may appear more than once at the same location. */\n isRepeatable: boolean;\n /** Reason this element is deprecated, if one was provided. */\n deprecationReason: Maybe<string>;\n /** Custom extension fields reserved for users. */\n extensions: Readonly<GraphQLDirectiveExtensions>;\n /** AST node from which this schema element was built, if available. */\n astNode: Maybe<DirectiveDefinitionNode>;\n /** AST extension nodes applied to this schema element. */\n extensionASTNodes: ReadonlyArray<DirectiveExtensionNode>;\n\n /**\n * Creates a GraphQLDirective instance.\n * @param config - Configuration describing this object.\n * @example\n * ```ts\n * import { DirectiveLocation, parse } from 'graphql/language';\n * import {\n * GraphQLBoolean,\n * GraphQLDirective,\n * GraphQLInt,\n * GraphQLNonNull,\n * } from 'graphql/type';\n *\n * const document = parse(`\n * directive @cacheControl(maxAge: Int) repeatable on FIELD_DEFINITION\n * extend directive @cacheControl(maxAge: Int) on FIELD_DEFINITION\n * `);\n * const definition = document.definitions[0];\n *\n * const cacheControl = new GraphQLDirective({\n * name: 'cacheControl',\n * description: 'Controls HTTP cache hints for a field.',\n * locations: [DirectiveLocation.FIELD_DEFINITION],\n * args: {\n * inheritMaxAge: {\n * description: 'Inherit the parent cache hint.',\n * type: new GraphQLNonNull(GraphQLBoolean),\n * default: { value: false },\n * deprecationReason: 'Use maxAge instead.',\n * extensions: { scope: 'cache' },\n * },\n * maxAge: {\n * type: GraphQLInt,\n * astNode: definition.arguments[0],\n * },\n * },\n * isRepeatable: true,\n * deprecationReason: 'Use @cache instead.',\n * extensions: { scope: 'cache' },\n * astNode: definition,\n * extensionASTNodes: [document.definitions[1]],\n * });\n *\n * cacheControl.name; // => 'cacheControl'\n * cacheControl.description; // => 'Controls HTTP cache hints for a field.'\n * cacheControl.args[0].name; // => 'inheritMaxAge'\n * cacheControl.args[0].default.value; // => false\n * cacheControl.isRepeatable; // => true\n * cacheControl.extensions; // => { scope: 'cache' }\n * ```\n */\n constructor(config: Readonly<GraphQLDirectiveConfig>) {\n this.__kind = directiveSymbol;\n this.name = assertName(config.name);\n this.description = config.description;\n this.locations = config.locations;\n this.isRepeatable = config.isRepeatable ?? false;\n this.deprecationReason = config.deprecationReason;\n this.extensions = toObjMapWithSymbols(config.extensions);\n this.astNode = config.astNode;\n this.extensionASTNodes = config.extensionASTNodes ?? [];\n\n devAssert(\n Array.isArray(config.locations),\n `@${this.name} locations must be an Array.`,\n );\n\n const args = config.args ?? {};\n devAssert(\n isObjectLike(args) && !Array.isArray(args),\n `@${this.name} args must be an object with argument names as keys.`,\n );\n\n this.args = Object.entries(args).map(\n ([argName, argConfig]) => new GraphQLArgument(this, argName, argConfig),\n );\n }\n\n /**\n * Returns the value used by `Object.prototype.toString`.\n * @returns The built-in string tag for this object.\n */\n get [Symbol.toStringTag](): string {\n return 'GraphQLDirective';\n }\n\n /**\n * Returns a normalized configuration object for this object.\n * @returns A configuration object that can be used to recreate this object.\n * @example\n * ```ts\n * import { DirectiveLocation } from 'graphql/language';\n * import { GraphQLDirective, GraphQLString } from 'graphql/type';\n *\n * const tag = new GraphQLDirective({\n * name: 'tag',\n * locations: [DirectiveLocation.FIELD_DEFINITION],\n * args: {\n * name: { type: GraphQLString },\n * },\n * });\n *\n * const config = tag.toConfig();\n * const tagCopy = new GraphQLDirective(config);\n *\n * config.args.name.type; // => GraphQLString\n * tagCopy.args[0].name; // => 'name'\n * ```\n */\n toConfig(): GraphQLDirectiveNormalizedConfig {\n return {\n name: this.name,\n description: this.description,\n locations: this.locations,\n args: keyValMap(\n this.args,\n (arg) => arg.name,\n (arg) => arg.toConfig(),\n ),\n isRepeatable: this.isRepeatable,\n deprecationReason: this.deprecationReason,\n extensions: this.extensions,\n astNode: this.astNode,\n extensionASTNodes: this.extensionASTNodes,\n };\n }\n\n /**\n * Returns the schema coordinate identifying this directive.\n * @returns The directive schema coordinate.\n * @example\n * ```ts\n * import { DirectiveLocation } from 'graphql/language';\n * import { GraphQLDirective } from 'graphql/type';\n *\n * const tag = new GraphQLDirective({\n * name: 'tag',\n * locations: [DirectiveLocation.FIELD_DEFINITION],\n * });\n *\n * tag.toString(); // => '@tag'\n * ```\n */\n toString(): string {\n return '@' + this.name;\n }\n\n /**\n * Returns the JSON representation used when this object is serialized.\n * @returns The JSON-serializable representation.\n * @example\n * ```ts\n * import { DirectiveLocation } from 'graphql/language';\n * import { GraphQLDirective } from 'graphql/type';\n *\n * const tag = new GraphQLDirective({\n * name: 'tag',\n * locations: [DirectiveLocation.FIELD_DEFINITION],\n * });\n *\n * tag.toJSON(); // => '@tag'\n * JSON.stringify({ directive: tag }); // => '{\"directive\":\"@tag\"}'\n * ```\n */\n toJSON(): string {\n return this.toString();\n }\n}\n\n/** Configuration used to construct a GraphQLDirective. */\nexport interface GraphQLDirectiveConfig {\n /** The GraphQL name for this schema element. */\n name: string;\n /** Human-readable description for this schema element, if provided. */\n description?: Maybe<string>;\n /** Locations where this directive may be applied. */\n locations: ReadonlyArray<DirectiveLocation>;\n /** Arguments accepted by this field or directive. */\n args?: Maybe<ObjMap<GraphQLArgumentConfig>>;\n /** Whether this directive may appear more than once at the same location. */\n isRepeatable?: Maybe<boolean>;\n /** Reason this element is deprecated, if one was provided. */\n deprecationReason?: Maybe<string>;\n /** Custom extension fields reserved for users. */\n extensions?: Maybe<Readonly<GraphQLDirectiveExtensions>>;\n /** AST node from which this schema element was built, if available. */\n astNode?: Maybe<DirectiveDefinitionNode>;\n /** AST extension nodes applied to this schema element. */\n extensionASTNodes?: Maybe<ReadonlyArray<DirectiveExtensionNode>>;\n}\n\n/** @internal */\nexport interface GraphQLDirectiveNormalizedConfig extends GraphQLDirectiveConfig {\n args: GraphQLFieldNormalizedConfigArgumentMap;\n isRepeatable: boolean;\n extensions: Readonly<GraphQLDirectiveExtensions>;\n extensionASTNodes: ReadonlyArray<DirectiveExtensionNode>;\n}\n\n/** Used to conditionally include fields or fragments. */\nexport const GraphQLIncludeDirective: GraphQLDirective = new GraphQLDirective({\n name: 'include',\n description:\n 'Directs the executor to include this field or fragment only when the `if` argument is true.',\n locations: [\n DirectiveLocation.FIELD,\n DirectiveLocation.FRAGMENT_SPREAD,\n DirectiveLocation.INLINE_FRAGMENT,\n ],\n args: {\n if: {\n type: new GraphQLNonNull(GraphQLBoolean),\n description: 'Included when true.',\n },\n },\n});\n\n/** Used to conditionally skip (exclude) fields or fragments. */\nexport const GraphQLSkipDirective: GraphQLDirective = new GraphQLDirective({\n name: 'skip',\n description:\n 'Directs the executor to skip this field or fragment when the `if` argument is true.',\n locations: [\n DirectiveLocation.FIELD,\n DirectiveLocation.FRAGMENT_SPREAD,\n DirectiveLocation.INLINE_FRAGMENT,\n ],\n args: {\n if: {\n type: new GraphQLNonNull(GraphQLBoolean),\n description: 'Skipped when true.',\n },\n },\n});\n\n/**\n * Experimental directive used to conditionally defer fragments.\n *\n * This directive is exported for schemas that explicitly opt in to incremental\n * delivery. It is not included in `specifiedDirectives`.\n */\nexport const GraphQLDeferDirective: GraphQLDirective = new GraphQLDirective({\n name: 'defer',\n description:\n 'Directs the executor to defer this fragment when the `if` argument is true or undefined.',\n locations: [\n DirectiveLocation.FRAGMENT_SPREAD,\n DirectiveLocation.INLINE_FRAGMENT,\n ],\n args: {\n if: {\n type: new GraphQLNonNull(GraphQLBoolean),\n description: 'Deferred when true or undefined.',\n default: { value: true },\n },\n label: {\n type: GraphQLString,\n description: 'Unique name',\n },\n },\n});\n\n/**\n * Experimental directive used to conditionally stream list fields.\n *\n * This directive is exported for schemas that explicitly opt in to incremental\n * delivery. It is not included in `specifiedDirectives`.\n */\nexport const GraphQLStreamDirective: GraphQLDirective = new GraphQLDirective({\n name: 'stream',\n description:\n 'Directs the executor to stream plural fields when the `if` argument is true or undefined.',\n locations: [DirectiveLocation.FIELD],\n args: {\n initialCount: {\n default: { value: 0 },\n type: new GraphQLNonNull(GraphQLInt),\n description: 'Number of items to return immediately',\n },\n if: {\n type: new GraphQLNonNull(GraphQLBoolean),\n description: 'Stream when true or undefined.',\n default: { value: true },\n },\n label: {\n type: GraphQLString,\n description: 'Unique name',\n },\n },\n});\n\n/** Constant string used for default reason for a deprecation. */\nexport const DEFAULT_DEPRECATION_REASON = 'No longer supported';\n\n/**\n * Used to declare element of a GraphQL schema as deprecated.\n *\n * The `reason` argument is non-null and defaults to\n * `DEFAULT_DEPRECATION_REASON`.\n */\nexport const GraphQLDeprecatedDirective: GraphQLDirective =\n new GraphQLDirective({\n name: 'deprecated',\n description: 'Marks an element of a GraphQL schema as no longer supported.',\n locations: [\n DirectiveLocation.FIELD_DEFINITION,\n DirectiveLocation.ARGUMENT_DEFINITION,\n DirectiveLocation.INPUT_FIELD_DEFINITION,\n DirectiveLocation.ENUM_VALUE,\n DirectiveLocation.DIRECTIVE_DEFINITION,\n ],\n args: {\n reason: {\n type: new GraphQLNonNull(GraphQLString),\n description:\n 'Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).',\n default: { value: DEFAULT_DEPRECATION_REASON },\n },\n },\n });\n\n/** Used to provide a URL for specifying the behavior of custom scalar definitions. */\nexport const GraphQLSpecifiedByDirective: GraphQLDirective =\n new GraphQLDirective({\n name: 'specifiedBy',\n description: 'Exposes a URL that specifies the behavior of this scalar.',\n locations: [DirectiveLocation.SCALAR],\n args: {\n url: {\n type: new GraphQLNonNull(GraphQLString),\n description: 'The URL that specifies the behavior of this scalar.',\n },\n },\n });\n\n/** Used to indicate an Input Object is a OneOf Input Object. */\nexport const GraphQLOneOfDirective: GraphQLDirective = new GraphQLDirective({\n name: 'oneOf',\n description:\n 'Indicates exactly one field must be supplied and this field must not be `null`.',\n locations: [DirectiveLocation.INPUT_OBJECT],\n args: {},\n});\n\n/**\n * Disables error propagation (experimental).\n *\n * @internal\n */\nexport const GraphQLDisableErrorPropagationDirective: GraphQLDirective =\n new GraphQLDirective({\n name: 'experimental_disableErrorPropagation',\n description: 'Disables error propagation.',\n locations: [\n DirectiveLocation.QUERY,\n DirectiveLocation.MUTATION,\n DirectiveLocation.SUBSCRIPTION,\n ],\n });\n\n/**\n * Full list of stable directives specified by GraphQL.js.\n *\n * Experimental `@defer` and `@stream` are exported separately and are not\n * included in this list.\n */\nexport const specifiedDirectives: ReadonlyArray<GraphQLDirective> =\n Object.freeze([\n GraphQLIncludeDirective,\n GraphQLSkipDirective,\n GraphQLDeprecatedDirective,\n GraphQLSpecifiedByDirective,\n GraphQLOneOfDirective,\n ]);\n\n/**\n * Returns true when the directive is one of the directives specified by GraphQL.\n * @param directive - Directive to inspect.\n * @returns True when the directive is specified by GraphQL.\n * @example\n * ```ts\n * import {\n * GraphQLDirective,\n * GraphQLIncludeDirective,\n * isSpecifiedDirective,\n * } from 'graphql/type';\n * import { DirectiveLocation } from 'graphql/language';\n *\n * const customDirective = new GraphQLDirective({\n * name: 'auth',\n * locations: [DirectiveLocation.FIELD_DEFINITION],\n * });\n *\n * isSpecifiedDirective(GraphQLIncludeDirective); // => true\n * isSpecifiedDirective(customDirective); // => false\n * ```\n */\nexport function isSpecifiedDirective(directive: GraphQLDirective): boolean {\n return specifiedDirectives.some(({ name }) => name === directive.name);\n}\n"]}
|
package/type/schema.d.mts
CHANGED
|
@@ -143,7 +143,7 @@ export interface GraphQLSchemaExtensions {
|
|
|
143
143
|
export declare class GraphQLSchema {
|
|
144
144
|
/** Human-readable description for this schema element, if provided. */
|
|
145
145
|
description: Maybe<string>;
|
|
146
|
-
/**
|
|
146
|
+
/** Custom extension fields reserved for users. */
|
|
147
147
|
extensions: Readonly<GraphQLSchemaExtensions>;
|
|
148
148
|
/** AST node from which this schema element was built, if available. */
|
|
149
149
|
astNode: Maybe<SchemaDefinitionNode>;
|
|
@@ -164,11 +164,7 @@ export declare class GraphQLSchema {
|
|
|
164
164
|
* @example
|
|
165
165
|
* ```ts
|
|
166
166
|
* // Create a schema with the required query root.
|
|
167
|
-
* import {
|
|
168
|
-
* GraphQLObjectType,
|
|
169
|
-
* GraphQLSchema,
|
|
170
|
-
* GraphQLString,
|
|
171
|
-
* } from 'graphql/type';
|
|
167
|
+
* import { GraphQLObjectType, GraphQLSchema, GraphQLString } from 'graphql/type';
|
|
172
168
|
*
|
|
173
169
|
* const Query = new GraphQLObjectType({
|
|
174
170
|
* name: 'Query',
|
|
@@ -240,7 +236,7 @@ export declare class GraphQLSchema {
|
|
|
240
236
|
* directives: [authDirective],
|
|
241
237
|
* extensions: { owner: 'platform' },
|
|
242
238
|
* astNode: schemaDocument.definitions[0],
|
|
243
|
-
* extensionASTNodes: [
|
|
239
|
+
* extensionASTNodes: [schemaDocument.definitions[1]],
|
|
244
240
|
* assumeValid: true,
|
|
245
241
|
* });
|
|
246
242
|
*
|
|
@@ -629,7 +625,7 @@ export interface GraphQLSchemaConfig extends GraphQLSchemaValidationOptions {
|
|
|
629
625
|
types?: Maybe<ReadonlyArray<GraphQLNamedType>>;
|
|
630
626
|
/** Directives available in this schema or applied to this AST node. */
|
|
631
627
|
directives?: Maybe<ReadonlyArray<GraphQLDirective>>;
|
|
632
|
-
/**
|
|
628
|
+
/** Custom extension fields reserved for users. */
|
|
633
629
|
extensions?: Maybe<Readonly<GraphQLSchemaExtensions>>;
|
|
634
630
|
/** AST node from which this schema element was built, if available. */
|
|
635
631
|
astNode?: Maybe<SchemaDefinitionNode>;
|
package/type/schema.d.ts
CHANGED
|
@@ -143,7 +143,7 @@ export interface GraphQLSchemaExtensions {
|
|
|
143
143
|
export declare class GraphQLSchema {
|
|
144
144
|
/** Human-readable description for this schema element, if provided. */
|
|
145
145
|
description: Maybe<string>;
|
|
146
|
-
/**
|
|
146
|
+
/** Custom extension fields reserved for users. */
|
|
147
147
|
extensions: Readonly<GraphQLSchemaExtensions>;
|
|
148
148
|
/** AST node from which this schema element was built, if available. */
|
|
149
149
|
astNode: Maybe<SchemaDefinitionNode>;
|
|
@@ -164,11 +164,7 @@ export declare class GraphQLSchema {
|
|
|
164
164
|
* @example
|
|
165
165
|
* ```ts
|
|
166
166
|
* // Create a schema with the required query root.
|
|
167
|
-
* import {
|
|
168
|
-
* GraphQLObjectType,
|
|
169
|
-
* GraphQLSchema,
|
|
170
|
-
* GraphQLString,
|
|
171
|
-
* } from 'graphql/type';
|
|
167
|
+
* import { GraphQLObjectType, GraphQLSchema, GraphQLString } from 'graphql/type';
|
|
172
168
|
*
|
|
173
169
|
* const Query = new GraphQLObjectType({
|
|
174
170
|
* name: 'Query',
|
|
@@ -240,7 +236,7 @@ export declare class GraphQLSchema {
|
|
|
240
236
|
* directives: [authDirective],
|
|
241
237
|
* extensions: { owner: 'platform' },
|
|
242
238
|
* astNode: schemaDocument.definitions[0],
|
|
243
|
-
* extensionASTNodes: [
|
|
239
|
+
* extensionASTNodes: [schemaDocument.definitions[1]],
|
|
244
240
|
* assumeValid: true,
|
|
245
241
|
* });
|
|
246
242
|
*
|
|
@@ -629,7 +625,7 @@ export interface GraphQLSchemaConfig extends GraphQLSchemaValidationOptions {
|
|
|
629
625
|
types?: Maybe<ReadonlyArray<GraphQLNamedType>>;
|
|
630
626
|
/** Directives available in this schema or applied to this AST node. */
|
|
631
627
|
directives?: Maybe<ReadonlyArray<GraphQLDirective>>;
|
|
632
|
-
/**
|
|
628
|
+
/** Custom extension fields reserved for users. */
|
|
633
629
|
extensions?: Maybe<Readonly<GraphQLSchemaExtensions>>;
|
|
634
630
|
/** AST node from which this schema element was built, if available. */
|
|
635
631
|
astNode?: Maybe<SchemaDefinitionNode>;
|
package/type/schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/type/schema.ts"],"names":[],"mappings":";;;AA4DA,4BAEC;AAqBD,oCAKC;AAtFD,sDAAgD;AAChD,4DAAsD;AAGtD,wDAA6D;AAQ7D,+CAAuD;AAWvD,mDAMyB;AAEzB,mDAAmE;AACnE,yDAK4B;AAqB5B,SAAgB,QAAQ,CAAC,MAAe;IACtC,OAAO,IAAA,0BAAU,EAAC,MAAM,EAAE,YAAY,EAAE,aAAa,CAAC,CAAC;AACzD,CAAC;AAqBD,SAAgB,YAAY,CAAC,MAAe;IAC1C,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,YAAY,IAAA,oBAAO,EAAC,MAAM,CAAC,0BAA0B,CAAC,CAAC;IACzE,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAeD,MAAM,YAAY,GAAkB,MAAM,CAAC,QAAQ,CAAC,CAAC;AAqFrD,MAAa,aAAa;IAmIxB,YAAY,MAAqC;QA9HxC,WAAM,GAAwB,YAAY,CAAC;QAiIlD,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,IAAI,KAAK,CAAC;QAE/C,IAAI,CAAC,kBAAkB,GAAG,MAAM,CAAC,WAAW,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QAEv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SAAS,EAAE,CAAC,EAAE,CAAC;gBACzD,sBAAsB,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YAC9C,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["/** @category Schema */\n\nimport { inspect } from '../jsutils/inspect.ts';\nimport { instanceOf } from '../jsutils/instanceOf.ts';\nimport type { Maybe } from '../jsutils/Maybe.ts';\nimport type { ObjMap } from '../jsutils/ObjMap.ts';\nimport { toObjMapWithSymbols } from '../jsutils/toObjMap.ts';\n\nimport type { GraphQLError } from '../error/GraphQLError.ts';\n\nimport type {\n SchemaDefinitionNode,\n SchemaExtensionNode,\n} from '../language/ast.ts';\nimport { OperationTypeNode } from '../language/ast.ts';\n\nimport type {\n GraphQLAbstractType,\n GraphQLCompositeType,\n GraphQLField,\n GraphQLInterfaceType,\n GraphQLNamedType,\n GraphQLObjectType,\n GraphQLType,\n} from './definition.ts';\nimport {\n getNamedType,\n isInputObjectType,\n isInterfaceType,\n isObjectType,\n isUnionType,\n} from './definition.ts';\nimport type { GraphQLDirective } from './directives.ts';\nimport { isDirective, specifiedDirectives } from './directives.ts';\nimport {\n __Schema,\n SchemaMetaFieldDef,\n TypeMetaFieldDef,\n TypeNameMetaFieldDef,\n} from './introspection.ts';\n\n/**\n * Test if the given value is a GraphQL schema.\n * @param schema - Value to inspect.\n * @returns True when the value is a GraphQLSchema.\n * @example\n * ```ts\n * import { buildSchema } from 'graphql/utilities';\n * import { GraphQLString, isSchema } from 'graphql/type';\n *\n * const schema = buildSchema(`\n * type Query {\n * greeting: String\n * }\n * `);\n *\n * isSchema(schema); // => true\n * isSchema(GraphQLString); // => false\n * ```\n */\nexport function isSchema(schema: unknown): schema is GraphQLSchema {\n return instanceOf(schema, schemaSymbol, GraphQLSchema);\n}\n\n/**\n * Returns the value as a GraphQLSchema, or throws if it is not a schema.\n * @param schema - GraphQL schema to use.\n * @returns The value typed as a GraphQLSchema.\n * @example\n * ```ts\n * import { buildSchema } from 'graphql/utilities';\n * import { assertSchema, GraphQLString } from 'graphql/type';\n *\n * const schema = buildSchema(`\n * type Query {\n * greeting: String\n * }\n * `);\n *\n * assertSchema(schema); // => schema\n * assertSchema(GraphQLString); // throws an error\n * ```\n */\nexport function assertSchema(schema: unknown): GraphQLSchema {\n if (!isSchema(schema)) {\n throw new Error(`Expected ${inspect(schema)} to be a GraphQL schema.`);\n }\n return schema;\n}\n\n/**\n * Custom extensions\n * @remarks\n * Use a unique identifier name for your extension, for example the name of\n * your library or project. Do not use a shortened identifier as this increases\n * the risk of conflicts. We recommend you add at most one extension field,\n * an object which can contain all the values you need.\n */\nexport interface GraphQLSchemaExtensions {\n [attributeName: string | symbol]: unknown;\n}\n\n/** @private */\nconst schemaSymbol: unique symbol = Symbol('Schema');\n\n/**\n * Schema Definition\n *\n * A Schema is created by supplying the root types of each type of operation,\n * query and mutation (optional). A schema definition is then supplied to the\n * validator and executor.\n * @example\n * ```ts\n * const MyAppQueryRootType = new GraphQLObjectType({\n * name: 'Query',\n * fields: {\n * greeting: { type: GraphQLString },\n * },\n * });\n *\n * const MyAppMutationRootType = new GraphQLObjectType({\n * name: 'Mutation',\n * fields: {\n * setGreeting: { type: GraphQLString },\n * },\n * });\n *\n * const MyAppSchema = new GraphQLSchema({\n * query: MyAppQueryRootType,\n * mutation: MyAppMutationRootType,\n * });\n * ```\n * @example\n * When the schema is constructed, by default only the types that are reachable\n * by traversing the root types are included, other types must be explicitly\n * referenced.\n *\n * ```ts\n * const characterInterface = new GraphQLInterfaceType({\n * name: 'Character',\n * fields: {\n * name: { type: GraphQLString },\n * },\n * });\n *\n * const humanType = new GraphQLObjectType({\n * name: 'Human',\n * interfaces: [characterInterface],\n * fields: {\n * name: { type: GraphQLString },\n * },\n * });\n *\n * const droidType = new GraphQLObjectType({\n * name: 'Droid',\n * interfaces: [characterInterface],\n * fields: {\n * name: { type: GraphQLString },\n * },\n * });\n *\n * const schema = new GraphQLSchema({\n * query: new GraphQLObjectType({\n * name: 'Query',\n * fields: {\n * hero: { type: characterInterface },\n * },\n * }),\n * // Since this schema references only the `Character` interface it's\n * // necessary to explicitly list the types that implement it if\n * // you want them to be included in the final schema.\n * types: [humanType, droidType],\n * });\n * ```\n * @example\n * If an array of `directives` are provided to GraphQLSchema, that will be the\n * exact list of directives represented and allowed. If `directives` is not\n * provided then a default set of the specified directives (e.g. `@include` and\n * `@skip`) will be used. If you wish to provide *additional* directives to\n * these specified directives, you must explicitly declare them.\n *\n * ```ts\n * const MyAppSchema = new GraphQLSchema({\n * query: MyAppQueryRootType,\n * directives: specifiedDirectives.concat([myCustomDirective]),\n * });\n * ```\n */\nexport class GraphQLSchema {\n /**\n * Internal runtime marker used to identify GraphQLSchema instances.\n * @private\n */\n readonly __kind: typeof schemaSymbol = schemaSymbol;\n /** Human-readable description for this schema element, if provided. */\n description: Maybe<string>;\n /** Extension fields to include in the formatted result. */\n extensions: Readonly<GraphQLSchemaExtensions>;\n /** AST node from which this schema element was built, if available. */\n astNode: Maybe<SchemaDefinitionNode>;\n /** AST extension nodes applied to this schema element. */\n extensionASTNodes: ReadonlyArray<SchemaExtensionNode>;\n\n /** Whether this schema instance skips validation checks. */\n assumeValid: boolean;\n /**\n * Cached schema validation errors, if validation has already run.\n * @private\n */\n __validationErrors: Maybe<ReadonlyArray<GraphQLError>>;\n\n private _queryType: Maybe<GraphQLObjectType>;\n private _mutationType: Maybe<GraphQLObjectType>;\n private _subscriptionType: Maybe<GraphQLObjectType>;\n private _directives: ReadonlyArray<GraphQLDirective>;\n private _typeMap: TypeMap;\n private _subTypeMap: Map<\n GraphQLAbstractType,\n Set<GraphQLObjectType | GraphQLInterfaceType>\n >;\n\n private _implementationsMap: ObjMap<{\n objects: Array<GraphQLObjectType>;\n interfaces: Array<GraphQLInterfaceType>;\n }>;\n\n /**\n * Creates a GraphQLSchema instance.\n * @param config - Configuration describing this object.\n * @example\n * ```ts\n * // Create a schema with the required query root.\n * import {\n * GraphQLObjectType,\n * GraphQLSchema,\n * GraphQLString,\n * } from 'graphql/type';\n *\n * const Query = new GraphQLObjectType({\n * name: 'Query',\n * fields: {\n * greeting: {\n * type: GraphQLString,\n * resolve: () => 'Hello',\n * },\n * },\n * });\n *\n * const schema = new GraphQLSchema({\n * description: 'The application schema.',\n * query: Query,\n * });\n *\n * schema.getQueryType(); // => Query\n * schema.description; // => 'The application schema.'\n * ```\n * @example\n * ```ts\n * // This variant configures every schema option, including directives and extensions.\n * import { DirectiveLocation, parse } from 'graphql/language';\n * import {\n * GraphQLBoolean,\n * GraphQLDirective,\n * GraphQLObjectType,\n * GraphQLSchema,\n * GraphQLString,\n * } from 'graphql/type';\n *\n * const Query = new GraphQLObjectType({\n * name: 'Query',\n * fields: { greeting: { type: GraphQLString } },\n * });\n * const Mutation = new GraphQLObjectType({\n * name: 'Mutation',\n * fields: { setGreeting: { type: GraphQLString } },\n * });\n * const Subscription = new GraphQLObjectType({\n * name: 'Subscription',\n * fields: { greetingChanged: { type: GraphQLString } },\n * });\n * const AuditEvent = new GraphQLObjectType({\n * name: 'AuditEvent',\n * fields: { message: { type: GraphQLString } },\n * });\n * const authDirective = new GraphQLDirective({\n * name: 'auth',\n * locations: [DirectiveLocation.FIELD_DEFINITION],\n * args: { required: { type: GraphQLBoolean } },\n * });\n * const schemaDocument = parse(`\n * schema {\n * query: Query\n * mutation: Mutation\n * subscription: Subscription\n * }\n *\n * extend schema @auth\n * `);\n *\n * const schema = new GraphQLSchema({\n * description: 'Operations exposed by the application.',\n * query: Query,\n * mutation: Mutation,\n * subscription: Subscription,\n * types: [AuditEvent],\n * directives: [authDirective],\n * extensions: { owner: 'platform' },\n * astNode: schemaDocument.definitions[0],\n * extensionASTNodes: [ schemaDocument.definitions[1] ],\n * assumeValid: true,\n * });\n *\n * schema.getMutationType(); // => Mutation\n * schema.getSubscriptionType(); // => Subscription\n * schema.getType('AuditEvent'); // => AuditEvent\n * schema.getDirective('auth'); // => authDirective\n * schema.extensions; // => { owner: 'platform' }\n * ```\n */\n constructor(config: Readonly<GraphQLSchemaConfig>) {\n // If this schema was built from a source known to be valid, then it may be\n // marked with assumeValid to avoid an additional type system validation.\n this.assumeValid = config.assumeValid ?? false;\n // Used as a cache for validateSchema().\n this.__validationErrors = config.assumeValid === true ? [] : undefined;\n\n this.description = config.description;\n this.extensions = toObjMapWithSymbols(config.extensions);\n this.astNode = config.astNode;\n this.extensionASTNodes = config.extensionASTNodes ?? [];\n\n this._queryType = config.query;\n this._mutationType = config.mutation;\n this._subscriptionType = config.subscription;\n // Provide specified directives (e.g. @include and @skip) by default.\n this._directives = config.directives ?? specifiedDirectives;\n\n // To preserve order of user-provided types, we add first to add them to\n // the set of \"collected\" types, so `collectReferencedTypes` ignore them.\n const allReferencedTypes = new Set<GraphQLNamedType>(config.types);\n if (config.types != null) {\n for (const type of config.types) {\n // When we ready to process this type, we remove it from \"collected\" types\n // and then add it together with all dependent types in the correct position.\n allReferencedTypes.delete(type);\n collectReferencedTypes(type, allReferencedTypes);\n }\n }\n\n if (this._queryType != null) {\n collectReferencedTypes(this._queryType, allReferencedTypes);\n }\n if (this._mutationType != null) {\n collectReferencedTypes(this._mutationType, allReferencedTypes);\n }\n if (this._subscriptionType != null) {\n collectReferencedTypes(this._subscriptionType, allReferencedTypes);\n }\n\n for (const directive of this._directives) {\n // Directives are not validated until validateSchema() is called.\n if (isDirective(directive)) {\n for (const arg of directive.args) {\n collectReferencedTypes(arg.type, allReferencedTypes);\n }\n }\n }\n collectReferencedTypes(__Schema, allReferencedTypes);\n\n // Storing the resulting map for reference by the schema.\n this._typeMap = Object.create(null);\n this._subTypeMap = new Map();\n // Keep track of all implementations by interface name.\n this._implementationsMap = Object.create(null);\n\n for (const namedType of allReferencedTypes) {\n if (namedType == null) {\n continue;\n }\n\n const typeName = namedType.name;\n if (this._typeMap[typeName] !== undefined) {\n throw new Error(\n `Schema must contain uniquely named types but contains multiple types named \"${typeName}\".`,\n );\n }\n this._typeMap[typeName] = namedType;\n\n if (isInterfaceType(namedType)) {\n // Store implementations by interface.\n for (const iface of namedType.getInterfaces()) {\n if (isInterfaceType(iface)) {\n let implementations = this._implementationsMap[iface.name];\n implementations ??= this._implementationsMap[iface.name] = {\n objects: [],\n interfaces: [],\n };\n\n implementations.interfaces.push(namedType);\n }\n }\n } else if (isObjectType(namedType)) {\n // Store implementations by objects.\n for (const iface of namedType.getInterfaces()) {\n if (isInterfaceType(iface)) {\n let implementations = this._implementationsMap[iface.name];\n implementations ??= this._implementationsMap[iface.name] = {\n objects: [],\n interfaces: [],\n };\n\n implementations.objects.push(namedType);\n }\n }\n }\n }\n }\n\n /**\n * Returns the value used by `Object.prototype.toString`.\n * @returns The built-in string tag for this object.\n */\n get [Symbol.toStringTag](): string {\n return 'GraphQLSchema';\n }\n\n /**\n * Returns the root object type for query operations.\n * @returns The query root type, if this schema defines one.\n * @example\n * ```ts\n * import { buildSchema } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * greeting: String\n * }\n * `);\n *\n * schema.getQueryType()?.name; // => 'Query'\n * ```\n */\n getQueryType(): Maybe<GraphQLObjectType> {\n return this._queryType;\n }\n\n /**\n * Returns the root object type for mutation operations.\n * @returns The mutation root type, if this schema defines one.\n * @example\n * ```ts\n * import { buildSchema } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * greeting: String\n * }\n *\n * type Mutation {\n * setGreeting(value: String!): String\n * }\n * `);\n *\n * schema.getMutationType()?.name; // => 'Mutation'\n * ```\n */\n getMutationType(): Maybe<GraphQLObjectType> {\n return this._mutationType;\n }\n\n /**\n * Returns the root object type for subscription operations.\n * @returns The subscription root type, if this schema defines one.\n * @example\n * ```ts\n * import { buildSchema } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * greeting: String\n * }\n *\n * type Subscription {\n * greetings: String\n * }\n * `);\n *\n * schema.getSubscriptionType()?.name; // => 'Subscription'\n * ```\n */\n getSubscriptionType(): Maybe<GraphQLObjectType> {\n return this._subscriptionType;\n }\n\n /**\n * Returns the root object type for the requested operation kind.\n * @param operation - Operation kind to resolve.\n * @returns The root object type for the operation kind, if this schema defines one.\n * @example\n * ```ts\n * import { OperationTypeNode } from 'graphql/language';\n * import { buildSchema } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * greeting: String\n * }\n *\n * type Mutation {\n * setGreeting(value: String!): String\n * }\n * `);\n *\n * schema.getRootType(OperationTypeNode.QUERY)?.name; // => 'Query'\n * schema.getRootType(OperationTypeNode.MUTATION)?.name; // => 'Mutation'\n * schema.getRootType(OperationTypeNode.SUBSCRIPTION); // => undefined\n * ```\n */\n getRootType(operation: OperationTypeNode): Maybe<GraphQLObjectType> {\n switch (operation) {\n case OperationTypeNode.QUERY:\n return this.getQueryType();\n case OperationTypeNode.MUTATION:\n return this.getMutationType();\n case OperationTypeNode.SUBSCRIPTION:\n return this.getSubscriptionType();\n }\n }\n\n /**\n * Returns all named types known to this schema.\n * @returns A map of schema types keyed by type name.\n * @example\n * ```ts\n * import { buildSchema } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type User {\n * name: String\n * }\n *\n * type Query {\n * viewer: User\n * }\n * `);\n *\n * const typeMap = schema.getTypeMap();\n *\n * typeMap.User.name; // => 'User'\n * typeMap.Query.name; // => 'Query'\n * typeMap.String.name; // => 'String'\n * ```\n */\n getTypeMap(): TypeMap {\n return this._typeMap;\n }\n\n /**\n * Returns the named type with the provided name.\n * @param name - The GraphQL name to look up.\n * @returns The named schema type, if one exists.\n * @example\n * ```ts\n * import { buildSchema } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type User {\n * name: String\n * }\n *\n * type Query {\n * viewer: User\n * }\n * `);\n *\n * schema.getType('User')?.toString(); // => 'User'\n * schema.getType('Missing'); // => undefined\n * ```\n */\n getType(name: string): GraphQLNamedType | undefined {\n return this.getTypeMap()[name];\n }\n\n /**\n * Returns object types that may be returned for an abstract type.\n * @param abstractType - Interface or union type to inspect.\n * @returns Object types that may satisfy the abstract type.\n * @example\n * ```ts\n * import { buildSchema } from 'graphql/utilities';\n * import { assertInterfaceType, assertUnionType } from 'graphql/type';\n *\n * const schema = buildSchema(`\n * interface Node {\n * id: ID!\n * }\n *\n * type User implements Node {\n * id: ID!\n * }\n *\n * type Organization implements Node {\n * id: ID!\n * }\n *\n * union SearchResult = User | Organization\n *\n * type Query {\n * node: Node\n * search: [SearchResult]\n * }\n * `);\n *\n * const Node = assertInterfaceType(schema.getType('Node'));\n * const SearchResult = assertUnionType(schema.getType('SearchResult'));\n *\n * schema.getPossibleTypes(Node).map((type) => type.name); // => ['User', 'Organization']\n * schema.getPossibleTypes(SearchResult).map((type) => type.name); // => ['User', 'Organization']\n * ```\n */\n getPossibleTypes(\n abstractType: GraphQLAbstractType,\n ): ReadonlyArray<GraphQLObjectType> {\n return isUnionType(abstractType)\n ? abstractType.getTypes()\n : this.getImplementations(abstractType).objects;\n }\n\n /**\n * Returns objects and interfaces that implement an interface type.\n * @param interfaceType - Interface type to inspect.\n * @returns Object and interface implementations of the interface.\n * @example\n * ```ts\n * import { buildSchema } from 'graphql/utilities';\n * import { assertInterfaceType } from 'graphql/type';\n *\n * const schema = buildSchema(`\n * interface Resource {\n * url: String!\n * }\n *\n * interface Image implements Resource {\n * url: String!\n * width: Int\n * }\n *\n * type Photo implements Resource & Image {\n * url: String!\n * width: Int\n * }\n *\n * type Query {\n * resource: Resource\n * }\n * `);\n *\n * const Resource = assertInterfaceType(schema.getType('Resource'));\n * const implementations = schema.getImplementations(Resource);\n *\n * implementations.interfaces.map((type) => type.name); // => ['Image']\n * implementations.objects.map((type) => type.name); // => ['Photo']\n * ```\n */\n getImplementations(interfaceType: GraphQLInterfaceType): {\n objects: ReadonlyArray<GraphQLObjectType>;\n interfaces: ReadonlyArray<GraphQLInterfaceType>;\n } {\n const implementations = this._implementationsMap[interfaceType.name];\n return implementations ?? { objects: [], interfaces: [] };\n }\n\n /**\n * Returns whether one type is a possible runtime subtype of an abstract type.\n * @param abstractType - Interface or union type to inspect.\n * @param maybeSubType - Object or interface type to test as a possible subtype.\n * @returns True when the subtype may satisfy the abstract type.\n * @example\n * ```ts\n * import { buildSchema } from 'graphql/utilities';\n * import { assertInterfaceType, assertObjectType } from 'graphql/type';\n *\n * const schema = buildSchema(`\n * interface Node {\n * id: ID!\n * }\n *\n * type User implements Node {\n * id: ID!\n * }\n *\n * type Review {\n * body: String\n * }\n *\n * type Query {\n * node: Node\n * review: Review\n * }\n * `);\n *\n * const Node = assertInterfaceType(schema.getType('Node'));\n * const User = assertObjectType(schema.getType('User'));\n * const Review = assertObjectType(schema.getType('Review'));\n *\n * schema.isSubType(Node, User); // => true\n * schema.isSubType(Node, Review); // => false\n * ```\n */\n isSubType(\n abstractType: GraphQLAbstractType,\n maybeSubType: GraphQLObjectType | GraphQLInterfaceType,\n ): boolean {\n let set = this._subTypeMap.get(abstractType);\n if (set === undefined) {\n if (isUnionType(abstractType)) {\n set = new Set<GraphQLObjectType>(abstractType.getTypes());\n } else {\n const implementations = this.getImplementations(abstractType);\n set = new Set<GraphQLObjectType | GraphQLInterfaceType>([\n ...implementations.objects,\n ...implementations.interfaces,\n ]);\n }\n\n this._subTypeMap.set(abstractType, set);\n }\n return set.has(maybeSubType);\n }\n\n /**\n * Returns directives available in this schema.\n * @returns Directives available in this schema.\n * @example\n * ```ts\n * import { buildSchema } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * directive @upper on FIELD_DEFINITION\n *\n * type Query {\n * greeting: String @upper\n * }\n * `);\n *\n * schema.getDirectives().map((directive) => directive.name); // => ['include', 'skip', 'deprecated', 'specifiedBy', 'oneOf', 'upper']\n * ```\n */\n getDirectives(): ReadonlyArray<GraphQLDirective> {\n return this._directives;\n }\n\n /**\n * Returns the current directive definition.\n * @param name - The GraphQL name to look up.\n * @returns The current directive definition, if known.\n * @example\n * ```ts\n * import { buildSchema } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * directive @upper on FIELD_DEFINITION\n *\n * type Query {\n * greeting: String @upper\n * }\n * `);\n *\n * schema.getDirective('upper')?.name; // => 'upper'\n * schema.getDirective('missing'); // => undefined\n * ```\n */\n getDirective(name: string): Maybe<GraphQLDirective> {\n return this.getDirectives().find((directive) => directive.name === name);\n }\n\n /**\n * This method looks up the field on the given type definition.\n * It has special casing for the three introspection fields, `__schema`,\n * `__type` and `__typename`.\n *\n * `__typename` is special because it can always be queried as a field, even\n * in situations where no other fields are allowed, like on a Union.\n *\n * `__schema` and `__type` could get automatically added to the query type,\n * but that would require mutating type definitions, which would cause issues.\n * @param parentType - Composite type to look up the field on.\n * @param fieldName - Field name to look up.\n * @returns The field definition, including supported introspection fields.\n * @example\n * ```ts\n * import { buildSchema } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * greeting: String\n * }\n * `);\n * const queryType = schema.getQueryType();\n *\n * schema.getField(queryType, 'greeting')?.name; // => 'greeting'\n * schema.getField(queryType, '__typename')?.name; // => '__typename'\n * schema.getField(queryType, 'missing'); // => undefined\n * ```\n */\n getField(\n parentType: GraphQLCompositeType,\n fieldName: string,\n ): GraphQLField<unknown, unknown> | undefined {\n switch (fieldName) {\n case SchemaMetaFieldDef.name:\n return this.getQueryType() === parentType\n ? SchemaMetaFieldDef\n : undefined;\n case TypeMetaFieldDef.name:\n return this.getQueryType() === parentType\n ? TypeMetaFieldDef\n : undefined;\n case TypeNameMetaFieldDef.name:\n return TypeNameMetaFieldDef;\n }\n\n // this function is part \"hot\" path inside executor and check presence\n // of 'getFields' is faster than to use `!isUnionType`\n if ('getFields' in parentType) {\n return parentType.getFields()[fieldName];\n }\n return undefined;\n }\n\n /**\n * Returns a normalized configuration object for this object.\n *\n * The returned config preserves the original `assumeValid` flag so the schema\n * can be recreated with the same validation behavior.\n * @returns A configuration object that can be used to recreate this object.\n * @example\n * ```ts\n * import { buildSchema } from 'graphql/utilities';\n * import { GraphQLSchema } from 'graphql/type';\n *\n * const schema = buildSchema(`\n * type Query {\n * greeting: String\n * }\n * `);\n *\n * const config = schema.toConfig();\n * const schemaCopy = new GraphQLSchema(config);\n *\n * config.query?.name; // => 'Query'\n * schemaCopy.getQueryType()?.name; // => 'Query'\n * ```\n */\n toConfig(): GraphQLSchemaNormalizedConfig {\n return {\n description: this.description,\n query: this.getQueryType(),\n mutation: this.getMutationType(),\n subscription: this.getSubscriptionType(),\n types: Object.values(this.getTypeMap()),\n directives: this.getDirectives(),\n extensions: this.extensions,\n astNode: this.astNode,\n extensionASTNodes: this.extensionASTNodes,\n assumeValid: this.assumeValid,\n };\n }\n}\n\ntype TypeMap = ObjMap<GraphQLNamedType>;\n\n/** @internal */\nexport interface GraphQLSchemaValidationOptions {\n /**\n * When building a schema from a GraphQL service's introspection result, it\n * might be safe to assume the schema is valid. Set to true to assume the\n * produced schema is valid.\n *\n * Default: false\n *\n * @internal\n */\n assumeValid?: boolean | undefined;\n}\n\n/** Configuration used to construct a GraphQLSchema. */\nexport interface GraphQLSchemaConfig extends GraphQLSchemaValidationOptions {\n /** Human-readable description for this schema element, if provided. */\n description?: Maybe<string>;\n /** Root object type for query operations. */\n query?: Maybe<GraphQLObjectType>;\n /** Root object type for mutation operations. */\n mutation?: Maybe<GraphQLObjectType>;\n /** Root object type for subscription operations. */\n subscription?: Maybe<GraphQLObjectType>;\n /** Object types that belong to this union type. */\n types?: Maybe<ReadonlyArray<GraphQLNamedType>>;\n /** Directives available in this schema or applied to this AST node. */\n directives?: Maybe<ReadonlyArray<GraphQLDirective>>;\n /** Extension fields to include in the formatted result. */\n extensions?: Maybe<Readonly<GraphQLSchemaExtensions>>;\n /** AST node from which this schema element was built, if available. */\n astNode?: Maybe<SchemaDefinitionNode>;\n /** AST extension nodes applied to this schema element. */\n extensionASTNodes?: Maybe<ReadonlyArray<SchemaExtensionNode>>;\n}\n\n/** @internal */\nexport interface GraphQLSchemaNormalizedConfig extends GraphQLSchemaConfig {\n description: Maybe<string>;\n types: ReadonlyArray<GraphQLNamedType>;\n directives: ReadonlyArray<GraphQLDirective>;\n extensions: Readonly<GraphQLSchemaExtensions>;\n extensionASTNodes: ReadonlyArray<SchemaExtensionNode>;\n assumeValid: boolean;\n}\n\nfunction collectReferencedTypes(\n type: GraphQLType,\n typeSet: Set<GraphQLNamedType>,\n): Set<GraphQLNamedType> {\n const namedType = getNamedType(type);\n\n if (!typeSet.has(namedType)) {\n typeSet.add(namedType);\n if (isUnionType(namedType)) {\n for (const memberType of namedType.getTypes()) {\n collectReferencedTypes(memberType, typeSet);\n }\n } else if (isObjectType(namedType) || isInterfaceType(namedType)) {\n for (const interfaceType of namedType.getInterfaces()) {\n collectReferencedTypes(interfaceType, typeSet);\n }\n\n for (const field of Object.values(namedType.getFields())) {\n collectReferencedTypes(field.type, typeSet);\n for (const arg of field.args) {\n collectReferencedTypes(arg.type, typeSet);\n }\n }\n } else if (isInputObjectType(namedType)) {\n for (const field of Object.values(namedType.getFields())) {\n collectReferencedTypes(field.type, typeSet);\n }\n }\n }\n\n return typeSet;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/type/schema.ts"],"names":[],"mappings":";;;AA4DA,4BAEC;AAqBD,oCAKC;AAtFD,sDAAgD;AAChD,4DAAsD;AAGtD,wDAA6D;AAQ7D,+CAAuD;AAWvD,mDAMyB;AAEzB,mDAAmE;AACnE,yDAK4B;AAqB5B,SAAgB,QAAQ,CAAC,MAAe;IACtC,OAAO,IAAA,0BAAU,EAAC,MAAM,EAAE,YAAY,EAAE,aAAa,CAAC,CAAC;AACzD,CAAC;AAqBD,SAAgB,YAAY,CAAC,MAAe;IAC1C,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,YAAY,IAAA,oBAAO,EAAC,MAAM,CAAC,0BAA0B,CAAC,CAAC;IACzE,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAeD,MAAM,YAAY,GAAkB,MAAM,CAAC,QAAQ,CAAC,C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AAM,GAAG,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;oBAC7B,sBAAsB,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;gBAC5C,CAAC;YACH,CAAC;QACH,CAAC;aAAM,IAAI,IAAA,iCAAiB,EAAC,SAAS,CAAC,EAAE,CAAC;YACxC,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC;gBACzD,sBAAsB,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YAC9C,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["/** @category Schema */\n\nimport { inspect } from '../jsutils/inspect.ts';\nimport { instanceOf } from '../jsutils/instanceOf.ts';\nimport type { Maybe } from '../jsutils/Maybe.ts';\nimport type { ObjMap } from '../jsutils/ObjMap.ts';\nimport { toObjMapWithSymbols } from '../jsutils/toObjMap.ts';\n\nimport type { GraphQLError } from '../error/GraphQLError.ts';\n\nimport type {\n SchemaDefinitionNode,\n SchemaExtensionNode,\n} from '../language/ast.ts';\nimport { OperationTypeNode } from '../language/ast.ts';\n\nimport type {\n GraphQLAbstractType,\n GraphQLCompositeType,\n GraphQLField,\n GraphQLInterfaceType,\n GraphQLNamedType,\n GraphQLObjectType,\n GraphQLType,\n} from './definition.ts';\nimport {\n getNamedType,\n isInputObjectType,\n isInterfaceType,\n isObjectType,\n isUnionType,\n} from './definition.ts';\nimport type { GraphQLDirective } from './directives.ts';\nimport { isDirective, specifiedDirectives } from './directives.ts';\nimport {\n __Schema,\n SchemaMetaFieldDef,\n TypeMetaFieldDef,\n TypeNameMetaFieldDef,\n} from './introspection.ts';\n\n/**\n * Test if the given value is a GraphQL schema.\n * @param schema - Value to inspect.\n * @returns True when the value is a GraphQLSchema.\n * @example\n * ```ts\n * import { buildSchema } from 'graphql/utilities';\n * import { GraphQLString, isSchema } from 'graphql/type';\n *\n * const schema = buildSchema(`\n * type Query {\n * greeting: String\n * }\n * `);\n *\n * isSchema(schema); // => true\n * isSchema(GraphQLString); // => false\n * ```\n */\nexport function isSchema(schema: unknown): schema is GraphQLSchema {\n return instanceOf(schema, schemaSymbol, GraphQLSchema);\n}\n\n/**\n * Returns the value as a GraphQLSchema, or throws if it is not a schema.\n * @param schema - GraphQL schema to use.\n * @returns The value typed as a GraphQLSchema.\n * @example\n * ```ts\n * import { buildSchema } from 'graphql/utilities';\n * import { assertSchema, GraphQLString } from 'graphql/type';\n *\n * const schema = buildSchema(`\n * type Query {\n * greeting: String\n * }\n * `);\n *\n * assertSchema(schema); // => schema\n * assertSchema(GraphQLString); // throws an error\n * ```\n */\nexport function assertSchema(schema: unknown): GraphQLSchema {\n if (!isSchema(schema)) {\n throw new Error(`Expected ${inspect(schema)} to be a GraphQL schema.`);\n }\n return schema;\n}\n\n/**\n * Custom extensions\n * @remarks\n * Use a unique identifier name for your extension, for example the name of\n * your library or project. Do not use a shortened identifier as this increases\n * the risk of conflicts. We recommend you add at most one extension field,\n * an object which can contain all the values you need.\n */\nexport interface GraphQLSchemaExtensions {\n [attributeName: string | symbol]: unknown;\n}\n\n/** @private */\nconst schemaSymbol: unique symbol = Symbol('Schema');\n\n/**\n * Schema Definition\n *\n * A Schema is created by supplying the root types of each type of operation,\n * query and mutation (optional). A schema definition is then supplied to the\n * validator and executor.\n * @example\n * ```ts\n * const MyAppQueryRootType = new GraphQLObjectType({\n * name: 'Query',\n * fields: {\n * greeting: { type: GraphQLString },\n * },\n * });\n *\n * const MyAppMutationRootType = new GraphQLObjectType({\n * name: 'Mutation',\n * fields: {\n * setGreeting: { type: GraphQLString },\n * },\n * });\n *\n * const MyAppSchema = new GraphQLSchema({\n * query: MyAppQueryRootType,\n * mutation: MyAppMutationRootType,\n * });\n * ```\n * @example\n * When the schema is constructed, by default only the types that are reachable\n * by traversing the root types are included, other types must be explicitly\n * referenced.\n *\n * ```ts\n * const characterInterface = new GraphQLInterfaceType({\n * name: 'Character',\n * fields: {\n * name: { type: GraphQLString },\n * },\n * });\n *\n * const humanType = new GraphQLObjectType({\n * name: 'Human',\n * interfaces: [characterInterface],\n * fields: {\n * name: { type: GraphQLString },\n * },\n * });\n *\n * const droidType = new GraphQLObjectType({\n * name: 'Droid',\n * interfaces: [characterInterface],\n * fields: {\n * name: { type: GraphQLString },\n * },\n * });\n *\n * const schema = new GraphQLSchema({\n * query: new GraphQLObjectType({\n * name: 'Query',\n * fields: {\n * hero: { type: characterInterface },\n * },\n * }),\n * // Since this schema references only the `Character` interface it's\n * // necessary to explicitly list the types that implement it if\n * // you want them to be included in the final schema.\n * types: [humanType, droidType],\n * });\n * ```\n * @example\n * If an array of `directives` are provided to GraphQLSchema, that will be the\n * exact list of directives represented and allowed. If `directives` is not\n * provided then a default set of the specified directives (e.g. `@include` and\n * `@skip`) will be used. If you wish to provide *additional* directives to\n * these specified directives, you must explicitly declare them.\n *\n * ```ts\n * const MyAppSchema = new GraphQLSchema({\n * query: MyAppQueryRootType,\n * directives: specifiedDirectives.concat([myCustomDirective]),\n * });\n * ```\n */\nexport class GraphQLSchema {\n /**\n * Internal runtime marker used to identify GraphQLSchema instances.\n * @private\n */\n readonly __kind: typeof schemaSymbol = schemaSymbol;\n /** Human-readable description for this schema element, if provided. */\n description: Maybe<string>;\n /** Custom extension fields reserved for users. */\n extensions: Readonly<GraphQLSchemaExtensions>;\n /** AST node from which this schema element was built, if available. */\n astNode: Maybe<SchemaDefinitionNode>;\n /** AST extension nodes applied to this schema element. */\n extensionASTNodes: ReadonlyArray<SchemaExtensionNode>;\n\n /** Whether this schema instance skips validation checks. */\n assumeValid: boolean;\n /**\n * Cached schema validation errors, if validation has already run.\n * @private\n */\n __validationErrors: Maybe<ReadonlyArray<GraphQLError>>;\n\n private _queryType: Maybe<GraphQLObjectType>;\n private _mutationType: Maybe<GraphQLObjectType>;\n private _subscriptionType: Maybe<GraphQLObjectType>;\n private _directives: ReadonlyArray<GraphQLDirective>;\n private _typeMap: TypeMap;\n private _subTypeMap: Map<\n GraphQLAbstractType,\n Set<GraphQLObjectType | GraphQLInterfaceType>\n >;\n\n private _implementationsMap: ObjMap<{\n objects: Array<GraphQLObjectType>;\n interfaces: Array<GraphQLInterfaceType>;\n }>;\n\n /**\n * Creates a GraphQLSchema instance.\n * @param config - Configuration describing this object.\n * @example\n * ```ts\n * // Create a schema with the required query root.\n * import { GraphQLObjectType, GraphQLSchema, GraphQLString } from 'graphql/type';\n *\n * const Query = new GraphQLObjectType({\n * name: 'Query',\n * fields: {\n * greeting: {\n * type: GraphQLString,\n * resolve: () => 'Hello',\n * },\n * },\n * });\n *\n * const schema = new GraphQLSchema({\n * description: 'The application schema.',\n * query: Query,\n * });\n *\n * schema.getQueryType(); // => Query\n * schema.description; // => 'The application schema.'\n * ```\n * @example\n * ```ts\n * // This variant configures every schema option, including directives and extensions.\n * import { DirectiveLocation, parse } from 'graphql/language';\n * import {\n * GraphQLBoolean,\n * GraphQLDirective,\n * GraphQLObjectType,\n * GraphQLSchema,\n * GraphQLString,\n * } from 'graphql/type';\n *\n * const Query = new GraphQLObjectType({\n * name: 'Query',\n * fields: { greeting: { type: GraphQLString } },\n * });\n * const Mutation = new GraphQLObjectType({\n * name: 'Mutation',\n * fields: { setGreeting: { type: GraphQLString } },\n * });\n * const Subscription = new GraphQLObjectType({\n * name: 'Subscription',\n * fields: { greetingChanged: { type: GraphQLString } },\n * });\n * const AuditEvent = new GraphQLObjectType({\n * name: 'AuditEvent',\n * fields: { message: { type: GraphQLString } },\n * });\n * const authDirective = new GraphQLDirective({\n * name: 'auth',\n * locations: [DirectiveLocation.FIELD_DEFINITION],\n * args: { required: { type: GraphQLBoolean } },\n * });\n * const schemaDocument = parse(`\n * schema {\n * query: Query\n * mutation: Mutation\n * subscription: Subscription\n * }\n *\n * extend schema @auth\n * `);\n *\n * const schema = new GraphQLSchema({\n * description: 'Operations exposed by the application.',\n * query: Query,\n * mutation: Mutation,\n * subscription: Subscription,\n * types: [AuditEvent],\n * directives: [authDirective],\n * extensions: { owner: 'platform' },\n * astNode: schemaDocument.definitions[0],\n * extensionASTNodes: [schemaDocument.definitions[1]],\n * assumeValid: true,\n * });\n *\n * schema.getMutationType(); // => Mutation\n * schema.getSubscriptionType(); // => Subscription\n * schema.getType('AuditEvent'); // => AuditEvent\n * schema.getDirective('auth'); // => authDirective\n * schema.extensions; // => { owner: 'platform' }\n * ```\n */\n constructor(config: Readonly<GraphQLSchemaConfig>) {\n // If this schema was built from a source known to be valid, then it may be\n // marked with assumeValid to avoid an additional type system validation.\n this.assumeValid = config.assumeValid ?? false;\n // Used as a cache for validateSchema().\n this.__validationErrors = config.assumeValid === true ? [] : undefined;\n\n this.description = config.description;\n this.extensions = toObjMapWithSymbols(config.extensions);\n this.astNode = config.astNode;\n this.extensionASTNodes = config.extensionASTNodes ?? [];\n\n this._queryType = config.query;\n this._mutationType = config.mutation;\n this._subscriptionType = config.subscription;\n // Provide specified directives (e.g. @include and @skip) by default.\n this._directives = config.directives ?? specifiedDirectives;\n\n // To preserve order of user-provided types, we add first to add them to\n // the set of \"collected\" types, so `collectReferencedTypes` ignore them.\n const allReferencedTypes = new Set<GraphQLNamedType>(config.types);\n if (config.types != null) {\n for (const type of config.types) {\n // When we ready to process this type, we remove it from \"collected\" types\n // and then add it together with all dependent types in the correct position.\n allReferencedTypes.delete(type);\n collectReferencedTypes(type, allReferencedTypes);\n }\n }\n\n if (this._queryType != null) {\n collectReferencedTypes(this._queryType, allReferencedTypes);\n }\n if (this._mutationType != null) {\n collectReferencedTypes(this._mutationType, allReferencedTypes);\n }\n if (this._subscriptionType != null) {\n collectReferencedTypes(this._subscriptionType, allReferencedTypes);\n }\n\n for (const directive of this._directives) {\n // Directives are not validated until validateSchema() is called.\n if (isDirective(directive)) {\n for (const arg of directive.args) {\n collectReferencedTypes(arg.type, allReferencedTypes);\n }\n }\n }\n collectReferencedTypes(__Schema, allReferencedTypes);\n\n // Storing the resulting map for reference by the schema.\n this._typeMap = Object.create(null);\n this._subTypeMap = new Map();\n // Keep track of all implementations by interface name.\n this._implementationsMap = Object.create(null);\n\n for (const namedType of allReferencedTypes) {\n if (namedType == null) {\n continue;\n }\n\n const typeName = namedType.name;\n if (this._typeMap[typeName] !== undefined) {\n throw new Error(\n `Schema must contain uniquely named types but contains multiple types named \"${typeName}\".`,\n );\n }\n this._typeMap[typeName] = namedType;\n\n if (isInterfaceType(namedType)) {\n // Store implementations by interface.\n for (const iface of namedType.getInterfaces()) {\n if (isInterfaceType(iface)) {\n let implementations = this._implementationsMap[iface.name];\n implementations ??= this._implementationsMap[iface.name] = {\n objects: [],\n interfaces: [],\n };\n\n implementations.interfaces.push(namedType);\n }\n }\n } else if (isObjectType(namedType)) {\n // Store implementations by objects.\n for (const iface of namedType.getInterfaces()) {\n if (isInterfaceType(iface)) {\n let implementations = this._implementationsMap[iface.name];\n implementations ??= this._implementationsMap[iface.name] = {\n objects: [],\n interfaces: [],\n };\n\n implementations.objects.push(namedType);\n }\n }\n }\n }\n }\n\n /**\n * Returns the value used by `Object.prototype.toString`.\n * @returns The built-in string tag for this object.\n */\n get [Symbol.toStringTag](): string {\n return 'GraphQLSchema';\n }\n\n /**\n * Returns the root object type for query operations.\n * @returns The query root type, if this schema defines one.\n * @example\n * ```ts\n * import { buildSchema } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * greeting: String\n * }\n * `);\n *\n * schema.getQueryType()?.name; // => 'Query'\n * ```\n */\n getQueryType(): Maybe<GraphQLObjectType> {\n return this._queryType;\n }\n\n /**\n * Returns the root object type for mutation operations.\n * @returns The mutation root type, if this schema defines one.\n * @example\n * ```ts\n * import { buildSchema } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * greeting: String\n * }\n *\n * type Mutation {\n * setGreeting(value: String!): String\n * }\n * `);\n *\n * schema.getMutationType()?.name; // => 'Mutation'\n * ```\n */\n getMutationType(): Maybe<GraphQLObjectType> {\n return this._mutationType;\n }\n\n /**\n * Returns the root object type for subscription operations.\n * @returns The subscription root type, if this schema defines one.\n * @example\n * ```ts\n * import { buildSchema } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * greeting: String\n * }\n *\n * type Subscription {\n * greetings: String\n * }\n * `);\n *\n * schema.getSubscriptionType()?.name; // => 'Subscription'\n * ```\n */\n getSubscriptionType(): Maybe<GraphQLObjectType> {\n return this._subscriptionType;\n }\n\n /**\n * Returns the root object type for the requested operation kind.\n * @param operation - Operation kind to resolve.\n * @returns The root object type for the operation kind, if this schema defines one.\n * @example\n * ```ts\n * import { OperationTypeNode } from 'graphql/language';\n * import { buildSchema } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * greeting: String\n * }\n *\n * type Mutation {\n * setGreeting(value: String!): String\n * }\n * `);\n *\n * schema.getRootType(OperationTypeNode.QUERY)?.name; // => 'Query'\n * schema.getRootType(OperationTypeNode.MUTATION)?.name; // => 'Mutation'\n * schema.getRootType(OperationTypeNode.SUBSCRIPTION); // => undefined\n * ```\n */\n getRootType(operation: OperationTypeNode): Maybe<GraphQLObjectType> {\n switch (operation) {\n case OperationTypeNode.QUERY:\n return this.getQueryType();\n case OperationTypeNode.MUTATION:\n return this.getMutationType();\n case OperationTypeNode.SUBSCRIPTION:\n return this.getSubscriptionType();\n }\n }\n\n /**\n * Returns all named types known to this schema.\n * @returns A map of schema types keyed by type name.\n * @example\n * ```ts\n * import { buildSchema } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type User {\n * name: String\n * }\n *\n * type Query {\n * viewer: User\n * }\n * `);\n *\n * const typeMap = schema.getTypeMap();\n *\n * typeMap.User.name; // => 'User'\n * typeMap.Query.name; // => 'Query'\n * typeMap.String.name; // => 'String'\n * ```\n */\n getTypeMap(): TypeMap {\n return this._typeMap;\n }\n\n /**\n * Returns the named type with the provided name.\n * @param name - The GraphQL name to look up.\n * @returns The named schema type, if one exists.\n * @example\n * ```ts\n * import { buildSchema } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type User {\n * name: String\n * }\n *\n * type Query {\n * viewer: User\n * }\n * `);\n *\n * schema.getType('User')?.toString(); // => 'User'\n * schema.getType('Missing'); // => undefined\n * ```\n */\n getType(name: string): GraphQLNamedType | undefined {\n return this.getTypeMap()[name];\n }\n\n /**\n * Returns object types that may be returned for an abstract type.\n * @param abstractType - Interface or union type to inspect.\n * @returns Object types that may satisfy the abstract type.\n * @example\n * ```ts\n * import { buildSchema } from 'graphql/utilities';\n * import { assertInterfaceType, assertUnionType } from 'graphql/type';\n *\n * const schema = buildSchema(`\n * interface Node {\n * id: ID!\n * }\n *\n * type User implements Node {\n * id: ID!\n * }\n *\n * type Organization implements Node {\n * id: ID!\n * }\n *\n * union SearchResult = User | Organization\n *\n * type Query {\n * node: Node\n * search: [SearchResult]\n * }\n * `);\n *\n * const Node = assertInterfaceType(schema.getType('Node'));\n * const SearchResult = assertUnionType(schema.getType('SearchResult'));\n *\n * schema.getPossibleTypes(Node).map((type) => type.name); // => ['User', 'Organization']\n * schema.getPossibleTypes(SearchResult).map((type) => type.name); // => ['User', 'Organization']\n * ```\n */\n getPossibleTypes(\n abstractType: GraphQLAbstractType,\n ): ReadonlyArray<GraphQLObjectType> {\n return isUnionType(abstractType)\n ? abstractType.getTypes()\n : this.getImplementations(abstractType).objects;\n }\n\n /**\n * Returns objects and interfaces that implement an interface type.\n * @param interfaceType - Interface type to inspect.\n * @returns Object and interface implementations of the interface.\n * @example\n * ```ts\n * import { buildSchema } from 'graphql/utilities';\n * import { assertInterfaceType } from 'graphql/type';\n *\n * const schema = buildSchema(`\n * interface Resource {\n * url: String!\n * }\n *\n * interface Image implements Resource {\n * url: String!\n * width: Int\n * }\n *\n * type Photo implements Resource & Image {\n * url: String!\n * width: Int\n * }\n *\n * type Query {\n * resource: Resource\n * }\n * `);\n *\n * const Resource = assertInterfaceType(schema.getType('Resource'));\n * const implementations = schema.getImplementations(Resource);\n *\n * implementations.interfaces.map((type) => type.name); // => ['Image']\n * implementations.objects.map((type) => type.name); // => ['Photo']\n * ```\n */\n getImplementations(interfaceType: GraphQLInterfaceType): {\n objects: ReadonlyArray<GraphQLObjectType>;\n interfaces: ReadonlyArray<GraphQLInterfaceType>;\n } {\n const implementations = this._implementationsMap[interfaceType.name];\n return implementations ?? { objects: [], interfaces: [] };\n }\n\n /**\n * Returns whether one type is a possible runtime subtype of an abstract type.\n * @param abstractType - Interface or union type to inspect.\n * @param maybeSubType - Object or interface type to test as a possible subtype.\n * @returns True when the subtype may satisfy the abstract type.\n * @example\n * ```ts\n * import { buildSchema } from 'graphql/utilities';\n * import { assertInterfaceType, assertObjectType } from 'graphql/type';\n *\n * const schema = buildSchema(`\n * interface Node {\n * id: ID!\n * }\n *\n * type User implements Node {\n * id: ID!\n * }\n *\n * type Review {\n * body: String\n * }\n *\n * type Query {\n * node: Node\n * review: Review\n * }\n * `);\n *\n * const Node = assertInterfaceType(schema.getType('Node'));\n * const User = assertObjectType(schema.getType('User'));\n * const Review = assertObjectType(schema.getType('Review'));\n *\n * schema.isSubType(Node, User); // => true\n * schema.isSubType(Node, Review); // => false\n * ```\n */\n isSubType(\n abstractType: GraphQLAbstractType,\n maybeSubType: GraphQLObjectType | GraphQLInterfaceType,\n ): boolean {\n let set = this._subTypeMap.get(abstractType);\n if (set === undefined) {\n if (isUnionType(abstractType)) {\n set = new Set<GraphQLObjectType>(abstractType.getTypes());\n } else {\n const implementations = this.getImplementations(abstractType);\n set = new Set<GraphQLObjectType | GraphQLInterfaceType>([\n ...implementations.objects,\n ...implementations.interfaces,\n ]);\n }\n\n this._subTypeMap.set(abstractType, set);\n }\n return set.has(maybeSubType);\n }\n\n /**\n * Returns directives available in this schema.\n * @returns Directives available in this schema.\n * @example\n * ```ts\n * import { buildSchema } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * directive @upper on FIELD_DEFINITION\n *\n * type Query {\n * greeting: String @upper\n * }\n * `);\n *\n * schema.getDirectives().map((directive) => directive.name); // => ['include', 'skip', 'deprecated', 'specifiedBy', 'oneOf', 'upper']\n * ```\n */\n getDirectives(): ReadonlyArray<GraphQLDirective> {\n return this._directives;\n }\n\n /**\n * Returns the current directive definition.\n * @param name - The GraphQL name to look up.\n * @returns The current directive definition, if known.\n * @example\n * ```ts\n * import { buildSchema } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * directive @upper on FIELD_DEFINITION\n *\n * type Query {\n * greeting: String @upper\n * }\n * `);\n *\n * schema.getDirective('upper')?.name; // => 'upper'\n * schema.getDirective('missing'); // => undefined\n * ```\n */\n getDirective(name: string): Maybe<GraphQLDirective> {\n return this.getDirectives().find((directive) => directive.name === name);\n }\n\n /**\n * This method looks up the field on the given type definition.\n * It has special casing for the three introspection fields, `__schema`,\n * `__type` and `__typename`.\n *\n * `__typename` is special because it can always be queried as a field, even\n * in situations where no other fields are allowed, like on a Union.\n *\n * `__schema` and `__type` could get automatically added to the query type,\n * but that would require mutating type definitions, which would cause issues.\n * @param parentType - Composite type to look up the field on.\n * @param fieldName - Field name to look up.\n * @returns The field definition, including supported introspection fields.\n * @example\n * ```ts\n * import { buildSchema } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * greeting: String\n * }\n * `);\n * const queryType = schema.getQueryType();\n *\n * schema.getField(queryType, 'greeting')?.name; // => 'greeting'\n * schema.getField(queryType, '__typename')?.name; // => '__typename'\n * schema.getField(queryType, 'missing'); // => undefined\n * ```\n */\n getField(\n parentType: GraphQLCompositeType,\n fieldName: string,\n ): GraphQLField<unknown, unknown> | undefined {\n switch (fieldName) {\n case SchemaMetaFieldDef.name:\n return this.getQueryType() === parentType\n ? SchemaMetaFieldDef\n : undefined;\n case TypeMetaFieldDef.name:\n return this.getQueryType() === parentType\n ? TypeMetaFieldDef\n : undefined;\n case TypeNameMetaFieldDef.name:\n return TypeNameMetaFieldDef;\n }\n\n // this function is part \"hot\" path inside executor and check presence\n // of 'getFields' is faster than to use `!isUnionType`\n if ('getFields' in parentType) {\n return parentType.getFields()[fieldName];\n }\n return undefined;\n }\n\n /**\n * Returns a normalized configuration object for this object.\n *\n * The returned config preserves the original `assumeValid` flag so the schema\n * can be recreated with the same validation behavior.\n * @returns A configuration object that can be used to recreate this object.\n * @example\n * ```ts\n * import { buildSchema } from 'graphql/utilities';\n * import { GraphQLSchema } from 'graphql/type';\n *\n * const schema = buildSchema(`\n * type Query {\n * greeting: String\n * }\n * `);\n *\n * const config = schema.toConfig();\n * const schemaCopy = new GraphQLSchema(config);\n *\n * config.query?.name; // => 'Query'\n * schemaCopy.getQueryType()?.name; // => 'Query'\n * ```\n */\n toConfig(): GraphQLSchemaNormalizedConfig {\n return {\n description: this.description,\n query: this.getQueryType(),\n mutation: this.getMutationType(),\n subscription: this.getSubscriptionType(),\n types: Object.values(this.getTypeMap()),\n directives: this.getDirectives(),\n extensions: this.extensions,\n astNode: this.astNode,\n extensionASTNodes: this.extensionASTNodes,\n assumeValid: this.assumeValid,\n };\n }\n}\n\ntype TypeMap = ObjMap<GraphQLNamedType>;\n\n/** @internal */\nexport interface GraphQLSchemaValidationOptions {\n /**\n * When building a schema from a GraphQL service's introspection result, it\n * might be safe to assume the schema is valid. Set to true to assume the\n * produced schema is valid.\n *\n * Default: false\n *\n * @internal\n */\n assumeValid?: boolean | undefined;\n}\n\n/** Configuration used to construct a GraphQLSchema. */\nexport interface GraphQLSchemaConfig extends GraphQLSchemaValidationOptions {\n /** Human-readable description for this schema element, if provided. */\n description?: Maybe<string>;\n /** Root object type for query operations. */\n query?: Maybe<GraphQLObjectType>;\n /** Root object type for mutation operations. */\n mutation?: Maybe<GraphQLObjectType>;\n /** Root object type for subscription operations. */\n subscription?: Maybe<GraphQLObjectType>;\n /** Object types that belong to this union type. */\n types?: Maybe<ReadonlyArray<GraphQLNamedType>>;\n /** Directives available in this schema or applied to this AST node. */\n directives?: Maybe<ReadonlyArray<GraphQLDirective>>;\n /** Custom extension fields reserved for users. */\n extensions?: Maybe<Readonly<GraphQLSchemaExtensions>>;\n /** AST node from which this schema element was built, if available. */\n astNode?: Maybe<SchemaDefinitionNode>;\n /** AST extension nodes applied to this schema element. */\n extensionASTNodes?: Maybe<ReadonlyArray<SchemaExtensionNode>>;\n}\n\n/** @internal */\nexport interface GraphQLSchemaNormalizedConfig extends GraphQLSchemaConfig {\n description: Maybe<string>;\n types: ReadonlyArray<GraphQLNamedType>;\n directives: ReadonlyArray<GraphQLDirective>;\n extensions: Readonly<GraphQLSchemaExtensions>;\n extensionASTNodes: ReadonlyArray<SchemaExtensionNode>;\n assumeValid: boolean;\n}\n\nfunction collectReferencedTypes(\n type: GraphQLType,\n typeSet: Set<GraphQLNamedType>,\n): Set<GraphQLNamedType> {\n const namedType = getNamedType(type);\n\n if (!typeSet.has(namedType)) {\n typeSet.add(namedType);\n if (isUnionType(namedType)) {\n for (const memberType of namedType.getTypes()) {\n collectReferencedTypes(memberType, typeSet);\n }\n } else if (isObjectType(namedType) || isInterfaceType(namedType)) {\n for (const interfaceType of namedType.getInterfaces()) {\n collectReferencedTypes(interfaceType, typeSet);\n }\n\n for (const field of Object.values(namedType.getFields())) {\n collectReferencedTypes(field.type, typeSet);\n for (const arg of field.args) {\n collectReferencedTypes(arg.type, typeSet);\n }\n }\n } else if (isInputObjectType(namedType)) {\n for (const field of Object.values(namedType.getFields())) {\n collectReferencedTypes(field.type, typeSet);\n }\n }\n }\n\n return typeSet;\n}\n"]}
|