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/VariablesInAllowedPositionRule.js | |
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/VariablesInAllowedPositionRule.js')
-rw-r--r-- | includes/external/school/node_modules/graphql/validation/rules/VariablesInAllowedPositionRule.js | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/includes/external/school/node_modules/graphql/validation/rules/VariablesInAllowedPositionRule.js b/includes/external/school/node_modules/graphql/validation/rules/VariablesInAllowedPositionRule.js deleted file mode 100644 index ad0ce8c..0000000 --- a/includes/external/school/node_modules/graphql/validation/rules/VariablesInAllowedPositionRule.js +++ /dev/null @@ -1,87 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.VariablesInAllowedPositionRule = VariablesInAllowedPositionRule; - -var _inspect = _interopRequireDefault(require("../../jsutils/inspect.js")); - -var _GraphQLError = require("../../error/GraphQLError.js"); - -var _kinds = require("../../language/kinds.js"); - -var _definition = require("../../type/definition.js"); - -var _typeFromAST = require("../../utilities/typeFromAST.js"); - -var _typeComparators = require("../../utilities/typeComparators.js"); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -/** - * Variables passed to field arguments conform to type - */ -function VariablesInAllowedPositionRule(context) { - var varDefMap = Object.create(null); - return { - OperationDefinition: { - enter: function enter() { - varDefMap = Object.create(null); - }, - leave: function leave(operation) { - var usages = context.getRecursiveVariableUsages(operation); - - for (var _i2 = 0; _i2 < usages.length; _i2++) { - var _ref2 = usages[_i2]; - var node = _ref2.node; - var type = _ref2.type; - var defaultValue = _ref2.defaultValue; - var varName = node.name.value; - var varDef = varDefMap[varName]; - - if (varDef && type) { - // A var type is allowed if it is the same or more strict (e.g. is - // a subtype of) than the expected type. It can be more strict if - // the variable type is non-null when the expected type is nullable. - // If both are list types, the variable item type can be more strict - // than the expected item type (contravariant). - var schema = context.getSchema(); - var varType = (0, _typeFromAST.typeFromAST)(schema, varDef.type); - - if (varType && !allowedVariableUsage(schema, varType, varDef.defaultValue, type, defaultValue)) { - var varTypeStr = (0, _inspect.default)(varType); - var typeStr = (0, _inspect.default)(type); - context.reportError(new _GraphQLError.GraphQLError("Variable \"$".concat(varName, "\" of type \"").concat(varTypeStr, "\" used in position expecting type \"").concat(typeStr, "\"."), [varDef, node])); - } - } - } - } - }, - VariableDefinition: function VariableDefinition(node) { - varDefMap[node.variable.name.value] = node; - } - }; -} -/** - * Returns true if the variable is allowed in the location it was found, - * which includes considering if default values exist for either the variable - * or the location at which it is located. - */ - - -function allowedVariableUsage(schema, varType, varDefaultValue, locationType, locationDefaultValue) { - if ((0, _definition.isNonNullType)(locationType) && !(0, _definition.isNonNullType)(varType)) { - var hasNonNullVariableDefaultValue = varDefaultValue != null && varDefaultValue.kind !== _kinds.Kind.NULL; - var hasLocationDefaultValue = locationDefaultValue !== undefined; - - if (!hasNonNullVariableDefaultValue && !hasLocationDefaultValue) { - return false; - } - - var nullableLocationType = locationType.ofType; - return (0, _typeComparators.isTypeSubTypeOf)(schema, varType, nullableLocationType); - } - - return (0, _typeComparators.isTypeSubTypeOf)(schema, varType, locationType); -} |