-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Query step replacement * fix * fix types
- Loading branch information
Showing
8 changed files
with
38 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/core/core-flows/src/cart/steps/get-variant-price-sets.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
packages/core/core-flows/src/common/steps/use-query-graph.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { | ||
GraphResultSet, | ||
RemoteJoinerOptions, | ||
RemoteQueryFunction, | ||
RemoteQueryInput, | ||
} from "@medusajs/framework/types" | ||
import { createStep, StepFunction, StepResponse } from "@medusajs/workflows-sdk" | ||
import { ContainerRegistrationKeys } from "@medusajs/utils" | ||
|
||
type EntryStepInput<TEntry extends string> = RemoteQueryInput<TEntry> & { | ||
options?: RemoteJoinerOptions | ||
} | ||
|
||
const useQueryGraphStepId = "use-query-graph-step" | ||
|
||
const step = createStep( | ||
useQueryGraphStepId, | ||
async (input: EntryStepInput<any>, { container }) => { | ||
const query = container.resolve<RemoteQueryFunction>( | ||
ContainerRegistrationKeys.QUERY | ||
) | ||
const { options, ...queryConfig } = input | ||
|
||
const result = await query.graph(queryConfig as any, options) | ||
return new StepResponse(result) | ||
} | ||
) | ||
|
||
export const useQueryGraphStep = <const TEntry extends string>( | ||
input: EntryStepInput<TEntry> | ||
): ReturnType<StepFunction<EntryStepInput<TEntry>, GraphResultSet<TEntry>>> => | ||
step(input as any) as unknown as ReturnType<StepFunction<EntryStepInput<TEntry>, GraphResultSet<TEntry>>> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters