UNPKG

grafast

Version:

Cutting edge GraphQL planning and execution engine

51 lines 1.87 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.__InputStaticLeafStep = void 0; exports.__inputStaticLeaf = __inputStaticLeaf; const tslib_1 = require("tslib"); const graphql = tslib_1.__importStar(require("graphql")); const global_js_1 = require("../global.js"); const step_js_1 = require("../step.js"); const constant_js_1 = require("./constant.js"); const { valueFromAST } = graphql; /** * Implements `InputStaticLeafStep` * * @see __InputDynamicScalarStep */ class __InputStaticLeafStep extends step_js_1.UnbatchedStep { static { this.$$export = { moduleName: "grafast", exportName: "__InputStaticLeafStep", }; } constructor(coercedValue) { super(); this.coercedValue = coercedValue; this.isSyncAndSafe = true; } unbatchedExecute() { return this.coercedValue; } optimize() { return (0, constant_js_1.constant)(this.coercedValue, false); } /** @internal */ eval() { return this.coercedValue; } /** @internal */ evalIs(expectedValue) { return this.coercedValue === expectedValue; } } exports.__InputStaticLeafStep = __InputStaticLeafStep; function __inputStaticLeaf(inputType, value) { // `coerceInputValue` throws on coercion failure. NOTE: it's only safe for // us to call coerceInputValue because we already know this is a scalar, // *not* a variable, and not an object/list therefore cannot _contain_ a // variable. Otherwise we'd need to process it via // operationPlan.trackedVariableValuesStep. const coercedValue = value != null ? valueFromAST(value, inputType) : value; return (0, global_js_1.operationPlan)().cacheImmutableStep("__inputStaticLeaf", coercedValue, () => new __InputStaticLeafStep(coercedValue)); } //# sourceMappingURL=__inputStaticLeaf.js.map