diff options
author | RaindropsSys <contact@minteck.org> | 2023-06-22 23:06:12 +0200 |
---|---|---|
committer | RaindropsSys <contact@minteck.org> | 2023-06-22 23:06:12 +0200 |
commit | 23563c7188e089929b60f9e10721c6fc43a220ff (patch) | |
tree | edfe2b009c82900d4ac27db02222d2f68dcad846 /includes/external/school/node_modules/graphql/validation/rules/KnownDirectivesRule.mjs | |
parent | 7a7a49332df7c852abbaa33c7e8e87f93d064d61 (diff) | |
download | pluralconnect-23563c7188e089929b60f9e10721c6fc43a220ff.tar.gz pluralconnect-23563c7188e089929b60f9e10721c6fc43a220ff.tar.bz2 pluralconnect-23563c7188e089929b60f9e10721c6fc43a220ff.zip |
Updated 15 files, added includes/maintenance/deleteUnusedAssets.php and deleted 4944 files (automated)
Diffstat (limited to 'includes/external/school/node_modules/graphql/validation/rules/KnownDirectivesRule.mjs')
-rw-r--r-- | includes/external/school/node_modules/graphql/validation/rules/KnownDirectivesRule.mjs | 134 |
1 files changed, 0 insertions, 134 deletions
diff --git a/includes/external/school/node_modules/graphql/validation/rules/KnownDirectivesRule.mjs b/includes/external/school/node_modules/graphql/validation/rules/KnownDirectivesRule.mjs deleted file mode 100644 index 8889bbb..0000000 --- a/includes/external/school/node_modules/graphql/validation/rules/KnownDirectivesRule.mjs +++ /dev/null @@ -1,134 +0,0 @@ -import inspect from "../../jsutils/inspect.mjs"; -import invariant from "../../jsutils/invariant.mjs"; -import { GraphQLError } from "../../error/GraphQLError.mjs"; -import { Kind } from "../../language/kinds.mjs"; -import { DirectiveLocation } from "../../language/directiveLocation.mjs"; -import { specifiedDirectives } from "../../type/directives.mjs"; - -/** - * Known directives - * - * A GraphQL document is only valid if all `@directives` are known by the - * schema and legally positioned. - */ -export function KnownDirectivesRule(context) { - var locationsMap = Object.create(null); - var schema = context.getSchema(); - var definedDirectives = schema ? schema.getDirectives() : specifiedDirectives; - - for (var _i2 = 0; _i2 < definedDirectives.length; _i2++) { - var directive = definedDirectives[_i2]; - locationsMap[directive.name] = directive.locations; - } - - var astDefinitions = context.getDocument().definitions; - - for (var _i4 = 0; _i4 < astDefinitions.length; _i4++) { - var def = astDefinitions[_i4]; - - if (def.kind === Kind.DIRECTIVE_DEFINITION) { - locationsMap[def.name.value] = def.locations.map(function (name) { - return name.value; - }); - } - } - - return { - Directive: function Directive(node, _key, _parent, _path, ancestors) { - var name = node.name.value; - var locations = locationsMap[name]; - - if (!locations) { - context.reportError(new GraphQLError("Unknown directive \"@".concat(name, "\"."), node)); - return; - } - - var candidateLocation = getDirectiveLocationForASTPath(ancestors); - - if (candidateLocation && locations.indexOf(candidateLocation) === -1) { - context.reportError(new GraphQLError("Directive \"@".concat(name, "\" may not be used on ").concat(candidateLocation, "."), node)); - } - } - }; -} - -function getDirectiveLocationForASTPath(ancestors) { - var appliedTo = ancestors[ancestors.length - 1]; - !Array.isArray(appliedTo) || invariant(0); - - switch (appliedTo.kind) { - case Kind.OPERATION_DEFINITION: - return getDirectiveLocationForOperation(appliedTo.operation); - - case Kind.FIELD: - return DirectiveLocation.FIELD; - - case Kind.FRAGMENT_SPREAD: - return DirectiveLocation.FRAGMENT_SPREAD; - - case Kind.INLINE_FRAGMENT: - return DirectiveLocation.INLINE_FRAGMENT; - - case Kind.FRAGMENT_DEFINITION: - return DirectiveLocation.FRAGMENT_DEFINITION; - - case Kind.VARIABLE_DEFINITION: - return DirectiveLocation.VARIABLE_DEFINITION; - - case Kind.SCHEMA_DEFINITION: - case Kind.SCHEMA_EXTENSION: - return DirectiveLocation.SCHEMA; - - case Kind.SCALAR_TYPE_DEFINITION: - case Kind.SCALAR_TYPE_EXTENSION: - return DirectiveLocation.SCALAR; - - case Kind.OBJECT_TYPE_DEFINITION: - case Kind.OBJECT_TYPE_EXTENSION: - return DirectiveLocation.OBJECT; - - case Kind.FIELD_DEFINITION: - return DirectiveLocation.FIELD_DEFINITION; - - case Kind.INTERFACE_TYPE_DEFINITION: - case Kind.INTERFACE_TYPE_EXTENSION: - return DirectiveLocation.INTERFACE; - - case Kind.UNION_TYPE_DEFINITION: - case Kind.UNION_TYPE_EXTENSION: - return DirectiveLocation.UNION; - - case Kind.ENUM_TYPE_DEFINITION: - case Kind.ENUM_TYPE_EXTENSION: - return DirectiveLocation.ENUM; - - case Kind.ENUM_VALUE_DEFINITION: - return DirectiveLocation.ENUM_VALUE; - - case Kind.INPUT_OBJECT_TYPE_DEFINITION: - case Kind.INPUT_OBJECT_TYPE_EXTENSION: - return DirectiveLocation.INPUT_OBJECT; - - case Kind.INPUT_VALUE_DEFINITION: - { - var parentNode = ancestors[ancestors.length - 3]; - return parentNode.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION ? DirectiveLocation.INPUT_FIELD_DEFINITION : DirectiveLocation.ARGUMENT_DEFINITION; - } - } -} - -function getDirectiveLocationForOperation(operation) { - switch (operation) { - case 'query': - return DirectiveLocation.QUERY; - - case 'mutation': - return DirectiveLocation.MUTATION; - - case 'subscription': - return DirectiveLocation.SUBSCRIPTION; - } // istanbul ignore next (Not reachable. All possible types have been considered) - - - false || invariant(0, 'Unexpected operation: ' + inspect(operation)); -} |