Skip to content

Commit

Permalink
Give users a way to access the tracked context.
Browse files Browse the repository at this point in the history
  • Loading branch information
benjie committed Jan 29, 2024
1 parent d6d1fb0 commit 60f1ac5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
6 changes: 6 additions & 0 deletions grafast/grafast/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ import {
reverseArray,
ReverseStep,
rootValue,
trackedContext,
trackedRootValue,
setter,
SetterCapableStep,
SetterStep,
Expand Down Expand Up @@ -410,6 +412,8 @@ export {
reverseArray,
ReverseStep,
rootValue,
trackedContext,
trackedRootValue,
SafeError,
ScalarPlanResolver,
ScalarPlans,
Expand Down Expand Up @@ -469,6 +473,8 @@ exportAsMany("grafast", {
ConstantStep,
context,
rootValue,
trackedContext,
trackedRootValue,
isGrafastError,
debugPlans,
each,
Expand Down
12 changes: 11 additions & 1 deletion grafast/grafast/src/steps/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,21 @@ export function operationPlan(): OperationPlan {

export function context<
TContext extends Grafast.Context = Grafast.Context,
>(): __ValueStep<TContext> {
return operationPlan().contextStep as __ValueStep<any>;
}

export function rootValue(): __ValueStep<Record<string, any>> {
return operationPlan().rootValueStep as __ValueStep<any>;
}

export function trackedContext<
TContext extends Grafast.Context = Grafast.Context,
>(): __TrackedValueStep<TContext> {
return operationPlan().trackedContextStep as __TrackedValueStep<any>;
}

export function rootValue(): __TrackedValueStep<Record<string, any>> {
export function trackedRootValue(): __TrackedValueStep<Record<string, any>> {
return operationPlan().trackedRootValueStep as __TrackedValueStep<any>;
}

Expand Down

0 comments on commit 60f1ac5

Please sign in to comment.