docs: change useRemoteQueryStep to useQueryGraphStep (#10051)

* docs: change useRemoteQueryStep to useQueryGraphStep

* fix lint errors
This commit is contained in:
Shahed Nasser authored and GitHub committed 2024-11-13 11:00:55 +02:00
1 parent 823552ecd9
commit 868b1c190f
17 files changed
+241 -266

No files matched your search

@@ -510,7 +510,7 @@ Finally, you'll create the workflow. Create the file `src/workflows/update-custo
```ts title="src/workflows/update-custom-from-product/index.ts" collapsibleLines="1-9" expandButtonLabel="Show Imports"
import { ProductDTO } from "@medusajs/framework/types"
import { createWorkflow, when, WorkflowResponse } from "@medusajs/framework/workflows-sdk"
import { createRemoteLinkStep, dismissRemoteLinkStep, useRemoteQueryStep } from "@medusajs/medusa/core-flows"
import { createRemoteLinkStep, dismissRemoteLinkStep, useQueryGraphStep } from "@medusajs/medusa/core-flows"
import { createCustomStep } from "../create-custom-from-cart/steps/create-custom"
import { Modules } from "@medusajs/framework/utils"
import { HELLO_MODULE } from "../../modules/hello"
@@ -527,15 +527,12 @@ export type UpdateCustomFromProductStepInput = {
export const updateCustomFromProductWorkflow = createWorkflow(
"update-custom-from-product",
(input: UpdateCustomFromProductStepInput) => {
const productData = useRemoteQueryStep({
entry_point: "product",
const { data: products } = useQueryGraphStep({
entity: "product",
fields: ["custom.*"],
variables: {
filters: {
id: input.product.id
}
},
list: false
filters: {
id: input.product.id,
}
})
// TODO create, update, or delete Custom record
@@ -552,9 +549,9 @@ Next, replace the `TODO` with the following:
```ts title="src/workflows/update-custom-from-product/index.ts"
const created = when({
input,
productData
products
}, (data) =>
!data.productData.custom &&
!data.products[0].custom &&
data.input.additional_data?.custom_name?.length > 0
)
.then(() => {
@@ -586,25 +583,25 @@ Next, replace the new `TODO` with the following:
```ts title="src/workflows/update-custom-from-product/index.ts"
const deleted = when({
input,
productData
products
}, (data) =>
data.productData.custom && (
data.products[0].custom && (
data.input.additional_data?.custom_name === null ||
data.input.additional_data?.custom_name.length === 0
)
)
.then(() => {
deleteCustomStep({
custom: productData.custom
custom: products[0].custom
})
dismissRemoteLinkStep({
[HELLO_MODULE]: {
custom_id: productData.custom.id
custom_id: products[0].custom.id
}
})
return productData.custom.id
return products[0].custom.id
})
// TODO delete Custom record
@@ -617,11 +614,11 @@ Finally, replace the new `TODO` with the following:
```ts title="src/workflows/update-custom-from-product/index.ts"
const updated = when({
input,
productData
}, (data) => data.productData.custom && data.input.additional_data?.custom_name?.length > 0)
products
}, (data) => data.products[0].custom && data.input.additional_data?.custom_name?.length > 0)
.then(() => {
const custom = updateCustomStep({
id: productData.custom.id,
id: products[0].custom.id,
custom_name: input.additional_data.custom_name
})