docs: change useRemoteQueryStep to useQueryGraphStep (#10051)
* docs: change useRemoteQueryStep to useQueryGraphStep * fix lint errors
This commit is contained in:
@@ -349,7 +349,7 @@ You add a step that deletes the manager using the `deleteManagers` method of the
|
||||
Next, in the same file, add the workflow that deletes a manager:
|
||||
|
||||
export const deleteHighlights = [
|
||||
["30", "manager_id", "If your actor type has a different name, such as vendor, change it to be `{actor_type}_id`."]
|
||||
["29", "manager_id", "If your actor type has a different name, such as vendor, change it to be `{actor_type}_id`."]
|
||||
]
|
||||
|
||||
```ts title="src/workflows/delete-manager.ts" collapsibleLines="1-15" expandButtonLabel="Show Imports" highlights={deleteHighlights}
|
||||
@@ -363,7 +363,7 @@ import {
|
||||
} from "@medusajs/framework/workflows-sdk"
|
||||
import {
|
||||
setAuthAppMetadataStep,
|
||||
useRemoteQueryStep,
|
||||
useQueryGraphStep,
|
||||
} from "@medusajs/medusa/core-flows"
|
||||
|
||||
// ...
|
||||
@@ -375,17 +375,15 @@ export const deleteManagerWorkflow = createWorkflow(
|
||||
): WorkflowResponse<string> => {
|
||||
deleteManagerStep(input)
|
||||
|
||||
const authIdentities = useRemoteQueryStep({
|
||||
entry_point: "auth_identity",
|
||||
const { data: authIdentities } = useQueryGraphStep({
|
||||
entity: "auth_identity",
|
||||
fields: ["id"],
|
||||
variables: {
|
||||
filters: {
|
||||
app_metadata: {
|
||||
// the ID is of the format `{actor_type}_id`.
|
||||
manager_id: input.id,
|
||||
},
|
||||
},
|
||||
},
|
||||
filters: {
|
||||
app_metadata: {
|
||||
// the ID is of the format `{actor_type}_id`.
|
||||
manager_id: input.id,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const authIdentity = transform(
|
||||
|
||||
@@ -492,7 +492,7 @@ Finally, you'll create the workflow. Create the file `src/workflows/update-custo
|
||||
```ts title="src/workflows/update-custom-from-cart/index.ts" collapsibleLines="1-9" expandButtonLabel="Show Imports"
|
||||
import { CartDTO } 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"
|
||||
@@ -509,15 +509,12 @@ export type UpdateCustomFromCartStepInput = {
|
||||
export const updateCustomFromCartWorkflow = createWorkflow(
|
||||
"update-custom-from-cart",
|
||||
(input: UpdateCustomFromCartStepInput) => {
|
||||
const cartData = useRemoteQueryStep({
|
||||
entry_point: "cart",
|
||||
const { data: carts } = useQueryGraphStep({
|
||||
entity: "cart",
|
||||
fields: ["custom.*"],
|
||||
variables: {
|
||||
filters: {
|
||||
id: input.cart.id,
|
||||
},
|
||||
},
|
||||
list: false,
|
||||
filters: {
|
||||
id: input.cart.id
|
||||
}
|
||||
})
|
||||
|
||||
// TODO create, update, or delete Custom record
|
||||
@@ -534,9 +531,9 @@ Next, replace the `TODO` with the following:
|
||||
```ts title="src/workflows/update-custom-from-cart/index.ts"
|
||||
const created = when({
|
||||
input,
|
||||
cartData,
|
||||
carts,
|
||||
}, (data) =>
|
||||
!data.cartData.custom &&
|
||||
!data.carts[0].custom &&
|
||||
data.input.additional_data?.custom_name?.length > 0
|
||||
)
|
||||
.then(() => {
|
||||
@@ -568,25 +565,25 @@ Next, replace the new `TODO` with the following:
|
||||
```ts title="src/workflows/update-custom-from-cart/index.ts"
|
||||
const deleted = when({
|
||||
input,
|
||||
cartData,
|
||||
carts,
|
||||
}, (data) =>
|
||||
data.cartData.custom && (
|
||||
data.carts[0].custom && (
|
||||
data.input.additional_data?.custom_name === null ||
|
||||
data.input.additional_data?.custom_name.length === 0
|
||||
)
|
||||
)
|
||||
.then(() => {
|
||||
deleteCustomStep({
|
||||
custom: cartData.custom,
|
||||
custom: carts[0].custom,
|
||||
})
|
||||
|
||||
dismissRemoteLinkStep({
|
||||
[HELLO_MODULE]: {
|
||||
custom_id: cartData.custom.id,
|
||||
custom_id: carts[0].custom.id,
|
||||
},
|
||||
})
|
||||
|
||||
return cartData.custom.id
|
||||
return carts[0].custom.id
|
||||
})
|
||||
|
||||
// TODO delete Custom record
|
||||
@@ -599,11 +596,11 @@ Finally, replace the new `TODO` with the following:
|
||||
```ts title="src/workflows/update-custom-from-cart/index.ts"
|
||||
const updated = when({
|
||||
input,
|
||||
cartData,
|
||||
}, (data) => data.cartData.custom && data.input.additional_data?.custom_name?.length > 0)
|
||||
carts,
|
||||
}, (data) => data.carts[0].custom && data.input.additional_data?.custom_name?.length > 0)
|
||||
.then(() => {
|
||||
const custom = updateCustomStep({
|
||||
id: cartData.custom.id,
|
||||
id: carts[0].custom.id,
|
||||
custom_name: input.additional_data.custom_name,
|
||||
})
|
||||
|
||||
|
||||
@@ -504,7 +504,7 @@ Finally, you'll create the workflow. Create the file `src/workflows/update-custo
|
||||
```ts title="src/workflows/update-custom-from-customer/index.ts" collapsibleLines="1-9" expandButtonLabel="Show Imports"
|
||||
import { CustomerDTO } 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-customer/steps/create-custom"
|
||||
import { Modules } from "@medusajs/framework/utils"
|
||||
import { HELLO_MODULE } from "../../modules/hello"
|
||||
@@ -521,15 +521,12 @@ export type UpdateCustomFromCustomerStepInput = {
|
||||
export const updateCustomFromCustomerWorkflow = createWorkflow(
|
||||
"update-custom-from-customer",
|
||||
(input: UpdateCustomFromCustomerStepInput) => {
|
||||
const customerData = useRemoteQueryStep({
|
||||
entry_point: "customer",
|
||||
const { data: customers } = useQueryGraphStep({
|
||||
entity: "customer",
|
||||
fields: ["custom.*"],
|
||||
variables: {
|
||||
filters: {
|
||||
id: input.customer.id,
|
||||
},
|
||||
},
|
||||
list: false,
|
||||
filters: {
|
||||
id: input.customer.id,
|
||||
}
|
||||
})
|
||||
|
||||
// TODO create, update, or delete Custom record
|
||||
@@ -546,9 +543,9 @@ Next, replace the `TODO` with the following:
|
||||
```ts title="src/workflows/update-custom-from-customer/index.ts"
|
||||
const created = when({
|
||||
input,
|
||||
customerData,
|
||||
customers,
|
||||
}, (data) =>
|
||||
!data.customerData.custom &&
|
||||
!data.customers[0].custom &&
|
||||
data.input.additional_data?.custom_name?.length > 0
|
||||
)
|
||||
.then(() => {
|
||||
@@ -580,25 +577,25 @@ Next, replace the new `TODO` with the following:
|
||||
```ts title="src/workflows/update-custom-from-customer/index.ts"
|
||||
const deleted = when({
|
||||
input,
|
||||
customerData,
|
||||
customers,
|
||||
}, (data) =>
|
||||
data.customerData.custom && (
|
||||
data.customers[0].custom && (
|
||||
data.input.additional_data?.custom_name === null ||
|
||||
data.input.additional_data?.custom_name.length === 0
|
||||
)
|
||||
)
|
||||
.then(() => {
|
||||
deleteCustomStep({
|
||||
custom: customerData.custom,
|
||||
custom: customers[0].custom,
|
||||
})
|
||||
|
||||
dismissRemoteLinkStep({
|
||||
[HELLO_MODULE]: {
|
||||
custom_id: customerData.custom.id,
|
||||
custom_id: customers[0].custom.id,
|
||||
},
|
||||
})
|
||||
|
||||
return customerData.custom.id
|
||||
return customers[0].custom.id
|
||||
})
|
||||
|
||||
// TODO delete Custom record
|
||||
@@ -611,11 +608,11 @@ Finally, replace the new `TODO` with the following:
|
||||
```ts title="src/workflows/update-custom-from-customer/index.ts"
|
||||
const updated = when({
|
||||
input,
|
||||
customerData,
|
||||
}, (data) => data.customerData.custom && data.input.additional_data?.custom_name?.length > 0)
|
||||
customers,
|
||||
}, (data) => data.customers[0].custom && data.input.additional_data?.custom_name?.length > 0)
|
||||
.then(() => {
|
||||
const custom = updateCustomStep({
|
||||
id: customerData.custom.id,
|
||||
id: customers[0].custom.id,
|
||||
custom_name: input.additional_data.custom_name,
|
||||
})
|
||||
|
||||
|
||||
@@ -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
|
||||
})
|
||||
|
||||
|
||||
@@ -516,7 +516,7 @@ Finally, you'll create the workflow. Create the file `src/workflows/update-custo
|
||||
```ts title="src/workflows/update-custom-from-promotion/index.ts" collapsibleLines="1-9" expandButtonLabel="Show Imports"
|
||||
import { PromotionDTO } 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"
|
||||
@@ -533,15 +533,12 @@ export type UpdateCustomFromPromotionStepInput = {
|
||||
export const updateCustomFromPromotionWorkflow = createWorkflow(
|
||||
"update-custom-from-promotion",
|
||||
(input: UpdateCustomFromPromotionStepInput) => {
|
||||
const promotionData = useRemoteQueryStep({
|
||||
entry_point: "promotion",
|
||||
const { data: promotions } = useQueryGraphStep({
|
||||
entity: "promotion",
|
||||
fields: ["custom.*"],
|
||||
variables: {
|
||||
filters: {
|
||||
id: input.promotion.id
|
||||
}
|
||||
},
|
||||
list: false
|
||||
filters: {
|
||||
id: input.promotion.id,
|
||||
}
|
||||
})
|
||||
|
||||
// TODO create, update, or delete Custom record
|
||||
@@ -558,9 +555,9 @@ Next, replace the `TODO` with the following:
|
||||
```ts title="src/workflows/update-custom-from-promotion/index.ts"
|
||||
const created = when({
|
||||
input,
|
||||
promotionData
|
||||
promotions
|
||||
}, (data) =>
|
||||
!data.promotionData.custom &&
|
||||
!data.promotions[0].custom &&
|
||||
data.input.additional_data?.custom_name?.length > 0
|
||||
)
|
||||
.then(() => {
|
||||
@@ -592,25 +589,25 @@ Next, replace the new `TODO` with the following:
|
||||
```ts title="src/workflows/update-custom-from-promotion/index.ts"
|
||||
const deleted = when({
|
||||
input,
|
||||
promotionData
|
||||
promotions
|
||||
}, (data) =>
|
||||
data.promotionData.custom && (
|
||||
data.promotions[0].custom && (
|
||||
data.input.additional_data?.custom_name === null ||
|
||||
data.input.additional_data?.custom_name.length === 0
|
||||
)
|
||||
)
|
||||
.then(() => {
|
||||
deleteCustomStep({
|
||||
custom: promotionData.custom
|
||||
custom: promotions[0].custom
|
||||
})
|
||||
|
||||
dismissRemoteLinkStep({
|
||||
[HELLO_MODULE]: {
|
||||
custom_id: promotionData.custom.id
|
||||
custom_id: promotions[0].custom.id
|
||||
}
|
||||
})
|
||||
|
||||
return promotionData.custom.id
|
||||
return promotions[0].custom.id
|
||||
})
|
||||
|
||||
// TODO delete Custom record
|
||||
@@ -623,11 +620,11 @@ Finally, replace the new `TODO` with the following:
|
||||
```ts title="src/workflows/update-custom-from-promotion/index.ts"
|
||||
const updated = when({
|
||||
input,
|
||||
promotionData
|
||||
}, (data) => data.promotionData.custom && data.input.additional_data?.custom_name?.length > 0)
|
||||
promotions
|
||||
}, (data) => data.promotions[0].custom && data.input.additional_data?.custom_name?.length > 0)
|
||||
.then(() => {
|
||||
const custom = updateCustomStep({
|
||||
id: promotionData.custom.id,
|
||||
id: promotions[0].custom.id,
|
||||
custom_name: input.additional_data.custom_name
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user