chore(core-flows,types): add TSDocs for useQueryGraphStep (#10042)

This commit is contained in:
Shahed Nasser
2024-11-19 18:31:33 +02:00
committed by GitHub
parent be700e31f2
commit 5fb73e6698
3 changed files with 116 additions and 1 deletions

View File

@@ -26,6 +26,91 @@ const step = createStep(
}
)
/**
* This step fetches data across modules using the Query.
*
* Learn more in the [Query documentation](https://docs.medusajs.com/learn/advanced-development/module-links/query).
*
* @example
* To retrieve a list of records of a data model:
*
* ```ts
* import {
* createWorkflow
* } from "@medusajs/framework/workflows-sdk"
* import {
* useQueryGraphStep
* } from "@medusajs/medusa/core-flows"
*
* const helloWorldWorkflow = createWorkflow(
* "hello-world",
* () => {
* const { data: products } = useQueryGraphStep({
* entity: "product",
* fields: [
* "*",
* "variants.*"
* ]
* })
* }
* )
* ```
*
* To retrieve a single item instead of a an array:
*
* ```ts
* const { data: products } = useQueryGraphStep({
* entity: "product",
* fields: [
* "*",
* "variants.*"
* ],
* filters: {
* id: "123"
* }
* })
* ```
*
* To throw an error if a record isn't found matching the specified ID:
*
* ```ts
* const { data: products } = useQueryGraphStep({
* entity: "product",
* fields: [
* "*",
* "variants.*"
* ],
* filters: {
* id: "123"
* },
* options: {
* throwIfKeyNotFound: true
* }
* })
* ```
*
* To set pagination configurations:
*
* ```ts
* const { data: products } = useQueryGraphStep({
* entity: "product",
* fields: [
* "*",
* "variants.*"
* ],
* filters: {
* id: "123"
* },
* pagination: {
* take: 10,
* skip: 10,
* order: {
* created_at: "DESC"
* }
* }
* })
* ```
*/
export const useQueryGraphStep = <const TEntry extends string>(
input: UseQueryGraphStepInput<TEntry>
): ReturnType<StepFunction<UseQueryGraphStepInput<TEntry>, GraphResultSet<TEntry>>> =>

View File

@@ -50,7 +50,13 @@ export const useRemoteQueryStepId = "use-remote-query"
/**
* This step fetches data across modules using the remote query.
*
* Learn more in the [Remote Query documentation](https://docs.medusajs.com/advanced-development/modules/remote-query).
* Learn more in the [Remote Query documentation](https://docs.medusajs.com/learn/advanced-development/module-links/query).
*
* :::note
*
* This step is deprecated. Use {@link useQueryGraphStep} instead.
*
* :::
*
* @example
*