diff --git a/grafast/grafast/src/steps/__inputDynamicScalar.ts b/grafast/grafast/src/steps/__inputDynamicScalar.ts index 7abdc5e04..6772f56a9 100644 --- a/grafast/grafast/src/steps/__inputDynamicScalar.ts +++ b/grafast/grafast/src/steps/__inputDynamicScalar.ts @@ -129,6 +129,7 @@ export class __InputDynamicScalarStep< return converted; }; + /** @internal */ eval(): TLeaf { const variableValues = this.variableNames.map((variableName, i) => this.getDep<__TrackedValueStep>(i).eval(), @@ -136,6 +137,7 @@ export class __InputDynamicScalarStep< return this.valueFromValues(variableValues); } + /** @internal */ evalIs(expectedValue: undefined | null | 0): boolean { if ( expectedValue === undefined || diff --git a/grafast/grafast/src/steps/__inputList.ts b/grafast/grafast/src/steps/__inputList.ts index 8aa3a4c96..28b5367cd 100644 --- a/grafast/grafast/src/steps/__inputList.ts +++ b/grafast/grafast/src/steps/__inputList.ts @@ -95,6 +95,7 @@ export class __InputListStep< return itemPlan; } + /** @internal */ eval(): any[] | null { if (this.inputValues?.kind === "NullValue") { return null; @@ -113,6 +114,7 @@ export class __InputListStep< return list; } + /** @internal */ evalIs(value: null | undefined | 0): boolean { if (value === undefined) { return this.inputValues === value; @@ -125,6 +127,7 @@ export class __InputListStep< } } + /** @internal */ evalLength(): number | null { if (this.inputValues === undefined) { return null; diff --git a/grafast/grafast/src/steps/__inputObject.ts b/grafast/grafast/src/steps/__inputObject.ts index 1db79cf97..91909d546 100644 --- a/grafast/grafast/src/steps/__inputObject.ts +++ b/grafast/grafast/src/steps/__inputObject.ts @@ -128,6 +128,7 @@ export class __InputObjectStep< return step; } + /** @internal */ eval(): any { if (this.inputValues?.kind === "NullValue") { return null; @@ -140,6 +141,7 @@ export class __InputObjectStep< return resultValues; } + /** @internal */ evalIs(value: null | undefined | 0): boolean { if (value === undefined) { return this.inputValues === value; @@ -156,6 +158,7 @@ export class __InputObjectStep< } } + /** @internal */ evalIsEmpty(): boolean { return ( this.inputValues?.kind === "ObjectValue" && @@ -164,6 +167,7 @@ export class __InputObjectStep< } // Written without consulting spec. + /** @internal */ evalHas(attrName: string): boolean { if (!this.inputValues) { return false; @@ -177,6 +181,7 @@ export class __InputObjectStep< return !this.inputFields[attrName].step.evalIs(undefined); } + /** @internal */ evalKeys(): ReadonlyArray | null { if (this.inputValues === undefined) { return null; diff --git a/grafast/grafast/src/steps/__inputStaticLeaf.ts b/grafast/grafast/src/steps/__inputStaticLeaf.ts index 6e48f02c7..2af94f23c 100644 --- a/grafast/grafast/src/steps/__inputStaticLeaf.ts +++ b/grafast/grafast/src/steps/__inputStaticLeaf.ts @@ -55,10 +55,12 @@ export class __InputStaticLeafStep extends UnbatchedStep { return constant(this.coercedValue, false); } + /** @internal */ eval(): TLeaf { return this.coercedValue; } + /** @internal */ evalIs(expectedValue: unknown): boolean { return this.coercedValue === expectedValue; } diff --git a/grafast/grafast/src/steps/__trackedValue.ts b/grafast/grafast/src/steps/__trackedValue.ts index 96bd75d24..1d34da19d 100644 --- a/grafast/grafast/src/steps/__trackedValue.ts +++ b/grafast/grafast/src/steps/__trackedValue.ts @@ -292,6 +292,8 @@ export class __TrackedValueStep< * **WARNING**: avoid using this where possible, it causes OpPlans to split. * * **WARNING**: this is the most expensive eval, if you need to eval, prefer evalIs, evalHas, etc instead. + * + * @internal */ eval(): TData | undefined { const { path, value } = this; @@ -311,6 +313,8 @@ export class __TrackedValueStep< * Should only be used on scalars. * * **WARNING**: avoid using this where possible, it causes OpPlans to split. + * + * @internal */ evalIs(expectedValue: unknown): boolean { const { value, path } = this; @@ -324,6 +328,7 @@ export class __TrackedValueStep< return pass; } + /** @internal */ evalIsEmpty() { const { value, path } = this; const isEmpty = @@ -344,6 +349,8 @@ export class __TrackedValueStep< * check will always return the same (boolean) result. * * **WARNING**: avoid using this where possible, it causes OpPlans to split. + * + * @internal */ evalHas(key: string): boolean { const { value, path } = this; @@ -372,6 +379,8 @@ export class __TrackedValueStep< * check will always return the same result. * * **WARNING**: avoid using this where possible, it causes OpPlans to split. + * + * @internal */ evalKeys(): ReadonlyArray | null { const { value, path } = this; @@ -417,6 +426,8 @@ export class __TrackedValueStep< * the same length. * * **WARNING**: avoid using this where possible, it causes OpPlans to split. + * + * @internal */ evalLength(): number | null { const { value, path } = this; diff --git a/grafast/grafast/src/steps/constant.ts b/grafast/grafast/src/steps/constant.ts index 22d204cb8..11069c16d 100644 --- a/grafast/grafast/src/steps/constant.ts +++ b/grafast/grafast/src/steps/constant.ts @@ -71,14 +71,17 @@ export class ConstantStep extends UnbatchedStep { return arrayOfLength(count, this.data); } + /** @internal */ eval() { return this.data; } + /** @internal */ evalIs(value: any) { return this.data === value; } + /** @internal */ evalIsEmpty() { return ( typeof this.data === "object" && @@ -87,10 +90,12 @@ export class ConstantStep extends UnbatchedStep { ); } + /** @internal */ evalLength() { return Array.isArray(this.data) ? this.data.length : null; } + /** @internal */ evalKeys(): ReadonlyArray | null { if (this.data == null || typeof this.data !== "object") { return null;