Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark all eval methods as internal #2388

Open
wants to merge 1 commit into
base: function-arguments-runtime
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions grafast/grafast/src/steps/__inputDynamicScalar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,15 @@ export class __InputDynamicScalarStep<
return converted;
};

/** @internal */
eval(): TLeaf {
const variableValues = this.variableNames.map((variableName, i) =>
this.getDep<__TrackedValueStep>(i).eval(),
);
return this.valueFromValues(variableValues);
}

/** @internal */
evalIs(expectedValue: undefined | null | 0): boolean {
if (
expectedValue === undefined ||
Expand Down
3 changes: 3 additions & 0 deletions grafast/grafast/src/steps/__inputList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export class __InputListStep<
return itemPlan;
}

/** @internal */
eval(): any[] | null {
if (this.inputValues?.kind === "NullValue") {
return null;
Expand All @@ -113,6 +114,7 @@ export class __InputListStep<
return list;
}

/** @internal */
evalIs(value: null | undefined | 0): boolean {
if (value === undefined) {
return this.inputValues === value;
Expand All @@ -125,6 +127,7 @@ export class __InputListStep<
}
}

/** @internal */
evalLength(): number | null {
if (this.inputValues === undefined) {
return null;
Expand Down
5 changes: 5 additions & 0 deletions grafast/grafast/src/steps/__inputObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export class __InputObjectStep<
return step;
}

/** @internal */
eval(): any {
if (this.inputValues?.kind === "NullValue") {
return null;
Expand All @@ -140,6 +141,7 @@ export class __InputObjectStep<
return resultValues;
}

/** @internal */
evalIs(value: null | undefined | 0): boolean {
if (value === undefined) {
return this.inputValues === value;
Expand All @@ -156,6 +158,7 @@ export class __InputObjectStep<
}
}

/** @internal */
evalIsEmpty(): boolean {
return (
this.inputValues?.kind === "ObjectValue" &&
Expand All @@ -164,6 +167,7 @@ export class __InputObjectStep<
}

// Written without consulting spec.
/** @internal */
evalHas(attrName: string): boolean {
if (!this.inputValues) {
return false;
Expand All @@ -177,6 +181,7 @@ export class __InputObjectStep<
return !this.inputFields[attrName].step.evalIs(undefined);
}

/** @internal */
evalKeys(): ReadonlyArray<keyof TInputType & string> | null {
if (this.inputValues === undefined) {
return null;
Expand Down
2 changes: 2 additions & 0 deletions grafast/grafast/src/steps/__inputStaticLeaf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ export class __InputStaticLeafStep<TLeaf = any> extends UnbatchedStep<TLeaf> {
return constant(this.coercedValue, false);
}

/** @internal */
eval(): TLeaf {
return this.coercedValue;
}

/** @internal */
evalIs(expectedValue: unknown): boolean {
return this.coercedValue === expectedValue;
}
Expand Down
11 changes: 11 additions & 0 deletions grafast/grafast/src/steps/__trackedValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -324,6 +328,7 @@ export class __TrackedValueStep<
return pass;
}

/** @internal */
evalIsEmpty() {
const { value, path } = this;
const isEmpty =
Expand All @@ -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;
Expand Down Expand Up @@ -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<keyof TData & string> | null {
const { value, path } = this;
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions grafast/grafast/src/steps/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,17 @@ export class ConstantStep<TData> extends UnbatchedStep<TData> {
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" &&
Expand All @@ -87,10 +90,12 @@ export class ConstantStep<TData> extends UnbatchedStep<TData> {
);
}

/** @internal */
evalLength() {
return Array.isArray(this.data) ? this.data.length : null;
}

/** @internal */
evalKeys(): ReadonlyArray<keyof TData & string> | null {
if (this.data == null || typeof this.data !== "object") {
return null;
Expand Down