docs: remove usages of ts-ignore in examples (#12839)

This commit is contained in:
Shahed Nasser authored and GitHub committed 2025-06-26 17:51:49 +03:00
1 parent 7d95eb73d3
commit f7e4a80c30
25 files changed
+17689 -169

No files matched your search

@@ -518,8 +518,8 @@ Create the file `src/workflows/add-custom-to-cart.ts` with the following content
![The directory structure after adding the workflow file.](https://res.cloudinary.com/dza7lstvk/image/upload/v1738251380/Medusa%20Resources/custom-item-price-5_zorahv.jpg)
export const workflowHighlights = [
["18", "useQueryGraphStep", "Retrieve the cart's details."],
["24", "useQueryGraphStep", "Retrieve the variant's details."],
["17", "useQueryGraphStep", "Retrieve the cart's details."],
["23", "useQueryGraphStep", "Retrieve the variant's details."],
]
```ts title="src/workflows/add-custom-to-cart.ts" highlights={workflowHighlights}
@@ -539,7 +539,6 @@ type AddCustomToCartWorkflowInput = {
export const addCustomToCartWorkflow = createWorkflow(
"add-custom-to-cart",
({ cart_id, item }: AddCustomToCartWorkflowInput) => {
// @ts-ignore
const { data: carts } = useQueryGraphStep({
entity: "cart",
filters: { id: cart_id },
@@ -651,7 +650,6 @@ import { WorkflowResponse } from "@medusajs/framework/workflows-sdk"
And replace the last `TODO` in the workflow with the following:
```ts title="src/workflows/add-custom-to-cart.ts"
// @ts-ignore
const { data: updatedCarts } = useQueryGraphStep({
entity: "cart",
filters: { id: cart_id },
@@ -635,8 +635,8 @@ You can now create the workflow using the steps provided by Medusa and your cust
To create the workflow, create the file `src/workflows/create-request-for-quote.ts` with the following content:
export const createRequestForQuoteHighlights = [
["25", "useQueryGraphStep", "Retrieve the cart's details."],
["46", "useQueryGraphStep", "Retrieve the customer's details."]
["24", "useQueryGraphStep", "Retrieve the cart's details."],
["45", "useQueryGraphStep", "Retrieve the customer's details."]
]
```ts title="src/workflows/create-request-for-quote.ts" highlights={createRequestForQuoteHighlights} collapsibleLines="1-20" expandButtonLabel="Show Imports"
@@ -663,7 +663,6 @@ type WorkflowInput = {
export const createRequestForQuoteWorkflow = createWorkflow(
"create-request-for-quote",
(input: WorkflowInput) => {
// @ts-ignore
const { data: carts } = useQueryGraphStep({
entity: "cart",
fields: [
@@ -2584,9 +2583,9 @@ You can now implement the merchant-rejection workflow. Create the file `src/work
![Diagram showcasing the directory structure after adding the merchant reject quote workflow file](https://res.cloudinary.com/dza7lstvk/image/upload/v1741159969/Medusa%20Resources/quote-36_l1ffxm.jpg)
export const merchantRejectionWorkflowHighlights = [
["15", "useQueryGraphStep", "Retrieve the quote's details."],
["24", "validateQuoteNotAccepted", "Validate that the quote isn't already accepted by the customer."],
["29", "updateQuotesStep", "Update the quote's status to `merchant_rejected`."]
["14", "useQueryGraphStep", "Retrieve the quote's details."],
["23", "validateQuoteNotAccepted", "Validate that the quote isn't already accepted by the customer."],
["28", "updateQuotesStep", "Update the quote's status to `merchant_rejected`."]
]
```ts title="src/workflows/merchant-reject-quote.ts" highlights={merchantRejectionWorkflowHighlights}
@@ -2603,7 +2602,6 @@ type WorkflowInput = {
export const merchantRejectQuoteWorkflow = createWorkflow(
"merchant-reject-quote-workflow",
(input: WorkflowInput) => {
// @ts-ignore
const { data: quotes } = useQueryGraphStep({
entity: "quote",
fields: ["id", "status"],
@@ -2905,7 +2903,6 @@ type WorkflowInput = {
export const merchantSendQuoteWorkflow = createWorkflow(
"merchant-send-quote-workflow",
(input: WorkflowInput) => {
// @ts-ignore
const { data: quotes } = useQueryGraphStep({
entity: "quote",
fields: ["id", "status"],
@@ -3282,9 +3279,9 @@ Create the file `src/workflows/customer-reject-quote.ts` with the following cont
![Directory structure after adding the customer reject quote workflow file](https://res.cloudinary.com/dza7lstvk/image/upload/v1741164371/Medusa%20Resources/quote-41_fgpqhz.jpg)
export const customerRejectQuoteHighlights = [
["16", "useQueryGraphStep", "Retrieve the quote's details."],
["25", "validateQuoteNotAccepted", "Validate that the quote isn't already accepted by the customer."],
["30", "updateQuotesStep", "Update the quote's status to `customer_rejected`."]
["15", "useQueryGraphStep", "Retrieve the quote's details."],
["24", "validateQuoteNotAccepted", "Validate that the quote isn't already accepted by the customer."],
["29", "updateQuotesStep", "Update the quote's status to `customer_rejected`."]
]
```ts title="src/workflows/customer-reject-quote.ts" highlights={customerRejectQuoteHighlights}
@@ -3302,7 +3299,6 @@ type WorkflowInput = {
export const customerRejectQuoteWorkflow = createWorkflow(
"customer-reject-quote-workflow",
(input: WorkflowInput) => {
// @ts-ignore
const { data: quotes } = useQueryGraphStep({
entity: "quote",
fields: ["id", "status"],
@@ -3511,11 +3507,11 @@ You can now implement the workflow that accepts a quote for a customer. Create t
![Directory structure after adding the customer accept quote workflow file](https://res.cloudinary.com/dza7lstvk/image/upload/v1741166025/Medusa%20Resources/quote-44_c09ts9.jpg)
export const customerAcceptQuoteHighlights = [
["21", "useQueryGraphStep", "Retrieve the quote's details."],
["30", "validateQuoteCanAcceptStep", "Validate that the quote can be accepted."],
["35", "updateQuotesStep", "Update the quote's status to `accepted`."],
["40", "confirmOrderEditRequestWorkflow", "Confirm the changes made on the draft order, such as changes to item quantities and prices."],
["47", "updateOrderWorkflow", "Update the draft order to change its status and convert it into an order."]
["20", "useQueryGraphStep", "Retrieve the quote's details."],
["29", "validateQuoteCanAcceptStep", "Validate that the quote can be accepted."],
["34", "updateQuotesStep", "Update the quote's status to `accepted`."],
["39", "confirmOrderEditRequestWorkflow", "Confirm the changes made on the draft order, such as changes to item quantities and prices."],
["46", "updateOrderWorkflow", "Update the draft order to change its status and convert it into an order."]
]
```ts title="src/workflows/customer-accept-quote.ts" highlights={customerAcceptQuoteHighlights}
@@ -3538,7 +3534,6 @@ type WorkflowInput = {
export const customerAcceptQuoteWorkflow = createWorkflow(
"customer-accept-quote-workflow",
(input: WorkflowInput) => {
// @ts-ignore
const { data: quotes } = useQueryGraphStep({
entity: "quote",
fields: ["id", "draft_order_id", "status"],
@@ -558,11 +558,9 @@ const {
updated_at: {
$lt: oneDayAgo,
},
// @ts-ignore
email: {
$ne: null,
},
// @ts-ignore
completed_at: null,
},
pagination: {
@@ -202,12 +202,12 @@ To create the workflow, create the file `src/workflows/apply-first-purchase-prom
export const workflowHighlights = [
["7", "cart_id", "Receive cart ID as input."],
["14", "carts", "Retrieve the cart's details."],
["23", "promotions", "Retrieve the first-purchase promotion's details."],
["32", "when", "Check if the first-purchase promotion can be applied."],
["42", "updateCartPromotionsStep", "Add the first-purchase promotion to the cart."],
["51", "updatedCarts", "Retrieve the updated cart's details."],
["59", "WorkflowResponse", "Return the updated cart's details."]
["13", "carts", "Retrieve the cart's details."],
["21", "promotions", "Retrieve the first-purchase promotion's details."],
["29", "when", "Check if the first-purchase promotion can be applied."],
["39", "updateCartPromotionsStep", "Add the first-purchase promotion to the cart."],
["47", "updatedCarts", "Retrieve the updated cart's details."],
["55", "WorkflowResponse", "Return the updated cart's details."]
]
```ts title="src/workflows/apply-first-purchase-promo.ts" highlights={workflowHighlights}
@@ -223,7 +223,6 @@ type WorkflowInput = {
export const applyFirstPurchasePromoWorkflow = createWorkflow(
"apply-first-purchase-promo",
(input: WorkflowInput) => {
// @ts-ignore
const { data: carts } = useQueryGraphStep({
entity: "cart",
fields: ["promotions.*", "customer.*", "customer.orders.*"],
@@ -232,12 +231,10 @@ export const applyFirstPurchasePromoWorkflow = createWorkflow(
}
})
// @ts-ignore
const { data: promotions } = useQueryGraphStep({
entity: "promotion",
fields: ["code"],
filters: {
// @ts-ignore
code: FIRST_PURCHASE_PROMOTION_CODE
}
}).config({ name: "retrieve-promotions" })
@@ -260,7 +257,6 @@ export const applyFirstPurchasePromoWorkflow = createWorkflow(
})
// retrieve updated cart
// @ts-ignore
const { data: updatedCarts } = useQueryGraphStep({
entity: "cart",
fields: ["*", "promotions.*"],
@@ -835,14 +835,14 @@ Now that you have all the steps, you can create the workflow that uses them.
To create the workflow, create the file `src/workflows/handle-order-points.ts` with the following content:
export const handleOrderPointsHighlights = [
["18", "useQueryGraphStep", "Retrieve the order's details."],
["38", "validateCustomerExistsStep", "Validate that the customer is registered."],
["42", "getCartLoyaltyPromoStep", "Retrieve the cart's loyalty promotion."],
["46", "when", "Check whether the order's cart has a loyalty promotion."],
["51", "deductPurchasePointsStep", "Deduct points from the customer's loyalty points."],
["56", "updatePromotionsStep", "Deactivate the cart's loyalty promotion."],
["65", "when", "Check whether the order's cart doesn't have a loyalty promotion."],
["70", "addPurchaseAsPointsStep", "Add points to the customer's loyalty points."],
["17", "useQueryGraphStep", "Retrieve the order's details."],
["37", "validateCustomerExistsStep", "Validate that the customer is registered."],
["41", "getCartLoyaltyPromoStep", "Retrieve the cart's loyalty promotion."],
["45", "when", "Check whether the order's cart has a loyalty promotion."],
["50", "deductPurchasePointsStep", "Deduct points from the customer's loyalty points."],
["55", "updatePromotionsStep", "Deactivate the cart's loyalty promotion."],
["64", "when", "Check whether the order's cart doesn't have a loyalty promotion."],
["69", "addPurchaseAsPointsStep", "Add points to the customer's loyalty points."],
]
```ts title="src/workflows/handle-order-points.ts" highlights={handleOrderPointsHighlights} collapsibleLines="1-9" expandButtonLabel="Show Imports"
@@ -862,7 +862,6 @@ type WorkflowInput = {
export const handleOrderPointsWorkflow = createWorkflow(
"handle-order-points",
({ order_id }: WorkflowInput) => {
// @ts-ignore
const { data: orders } = useQueryGraphStep({
entity: "order",
fields: [
@@ -1394,10 +1393,10 @@ You can now create the workflow that applies a loyalty promotion to the cart.
To create the workflow, create the file `src/workflows/apply-loyalty-on-cart.ts` with the following content:
export const applyLoyaltyOnCartWorkflowHighlights = [
["45", "useQueryGraphStep", "Retrieve the cart's details."],
["56", "validateCustomerExistsStep", "Validate that the customer is registered."],
["60", "getCartLoyaltyPromoStep", "Retrieve the cart's loyalty promotion."],
["65", "getCartLoyaltyPromoAmountStep", "Get the amount to be discounted based on the loyalty points."],
["44", "useQueryGraphStep", "Retrieve the cart's details."],
["55", "validateCustomerExistsStep", "Validate that the customer is registered."],
["59", "getCartLoyaltyPromoStep", "Retrieve the cart's loyalty promotion."],
["64", "getCartLoyaltyPromoAmountStep", "Get the amount to be discounted based on the loyalty points."],
]
```ts title="src/workflows/apply-loyalty-on-cart.ts" highlights={applyLoyaltyOnCartWorkflowHighlights} collapsibleLines="1-24" expandButtonLabel="Show Imports"
@@ -1444,7 +1443,6 @@ const fields = [
export const applyLoyaltyOnCartWorkflow = createWorkflow(
"apply-loyalty-on-cart",
(input: WorkflowInput) => {
// @ts-ignore
const { data: carts } = useQueryGraphStep({
entity: "cart",
fields,
@@ -1559,7 +1557,7 @@ export const createLoyaltyPromoStepHighlights = [
["5", "transform", "Prepare the data to update the cart's promotions."],
["25", "updateCartPromotionsWorkflow", "Update the cart's promotions with the new loyalty promotion."],
["29", "updateCartsStep", "Update the cart to store the ID of the loyalty promotion in the metadata."],
["38", "useQueryGraphStep", "Retrieve the cart's details again."],
["37", "useQueryGraphStep", "Retrieve the cart's details again."],
]
```ts title="src/workflows/apply-loyalty-on-cart.ts" highlights={createLoyaltyPromoStepHighlights}
@@ -1599,7 +1597,6 @@ updateCartsStep([
])
// retrieve cart with updated promotions
// @ts-ignore
const { data: updatedCarts } = useQueryGraphStep({
entity: "cart",
fields,
@@ -1800,13 +1797,13 @@ Since you already have all the steps, you can create the workflow.
To create the workflow, create the file `src/workflows/remove-loyalty-from-cart.ts` with the following content:
export const removeLoyaltyFromCartWorkflowHighlights = [
["36", "useQueryGraphStep", "Retrieve the cart's details."],
["44", "getCartLoyaltyPromoStep", "Retrieve the cart's loyalty promotion."],
["49", "updateCartPromotionsWorkflow", "Update the cart's promotions to remove the loyalty promotion."],
["57", "transform", "Prepare the new metadata to remove the loyalty promotion ID."],
["68", "updateCartsStep", "Update the cart to remove the loyalty promotion ID from the metadata."],
["75", "updatePromotionsStep", "Deactivate the loyalty promotion."],
["84", "useQueryGraphStep", "Retrieve the cart's details again."],
["35", "useQueryGraphStep", "Retrieve the cart's details."],
["43", "getCartLoyaltyPromoStep", "Retrieve the cart's loyalty promotion."],
["48", "updateCartPromotionsWorkflow", "Update the cart's promotions to remove the loyalty promotion."],
["56", "transform", "Prepare the new metadata to remove the loyalty promotion ID."],
["67", "updateCartsStep", "Update the cart to remove the loyalty promotion ID from the metadata."],
["74", "updatePromotionsStep", "Deactivate the loyalty promotion."],
["82", "useQueryGraphStep", "Retrieve the cart's details again."],
]
```ts title="src/workflows/remove-loyalty-from-cart.ts" collapsibleLines="1-15" expandButtonLabel="Show Imports" highlights={removeLoyaltyFromCartWorkflowHighlights}
@@ -1844,7 +1841,6 @@ const fields = [
export const removeLoyaltyFromCartWorkflow = createWorkflow(
"remove-loyalty-from-cart",
(input: WorkflowInput) => {
// @ts-ignore
const { data: carts } = useQueryGraphStep({
entity: "cart",
fields,
@@ -1892,7 +1888,6 @@ export const removeLoyaltyFromCartWorkflow = createWorkflow(
])
// retrieve cart with updated promotions
// @ts-ignore
const { data: updatedCarts } = useQueryGraphStep({
entity: "cart",
fields,
@@ -505,7 +505,6 @@ export const createReviewWorkflow = createWorkflow(
"create-review",
(input: CreateReviewInput) => {
// Check product exists
// @ts-ignore
useQueryGraphStep({
entity: "product",
fields: ["id"],
@@ -520,7 +519,6 @@ export const createReviewWorkflow = createWorkflow(
// Create the review
const review = createReviewStep(input)
// @ts-ignore
return new WorkflowResponse({
review,
})
@@ -1522,8 +1520,8 @@ export const GetStoreReviewsHighlights = [
["10", "GetStoreReviewsSchema", "Define the query parameters schema."],
["12", "GET", "Expose a GET API route."],
["26", "query.graph", "Retrieve reviews with pagination."],
["31", "status", "Only retrieve approved reviews."],
["41", "average_rating", "Retrieve the average rating of the product."],
["30", "status", "Only retrieve approved reviews."],
["40", "average_rating", "Retrieve the average rating of the product."],
]
```ts title="src/api/store/products/[id]/reviews/route.ts" highlights={GetStoreReviewsHighlights} collapsibleLines="1-9" expandButtonLabel="Show Imports"
@@ -1556,7 +1554,6 @@ export const GET = async (
entity: "review",
filters: {
product_id: id,
// @ts-ignore
status: "approved",
},
...req.queryConfig,
@@ -179,7 +179,7 @@ This workflow uses steps from Medusa's `@medusajs/medusa/core-flows` package. So
To create the workflow, create the file `src/workflows/reorder.ts` with the following content:
export const workflowHighlights1 = [
["20", "useQueryGraphStep", "Retrieve the order's details."],
["19", "useQueryGraphStep", "Retrieve the order's details."],
]
```ts title="src/workflows/reorder.ts" highlights={workflowHighlights1}
@@ -201,7 +201,6 @@ type ReorderWorkflowInput = {
export const reorderWorkflow = createWorkflow(
"reorder",
({ order_id }: ReorderWorkflowInput) => {
// @ts-ignore
const { data: orders } = useQueryGraphStep({
entity: "order",
fields: [
@@ -359,12 +358,11 @@ Finally, you need to retrieve the cart's details and return them as the workflow
Replace the `TODO` in the workflow with the following:
export const workflowHighlights4 = [
["2", "useQueryGraphStep", "Retrieve the cart's details."],
["28", "WorkflowResponse", "Return the cart's details."],
["1", "useQueryGraphStep", "Retrieve the cart's details."],
["27", "WorkflowResponse", "Return the cart's details."],
]
```ts title="src/workflows/reorder.ts" highlights={workflowHighlights4}
// @ts-ignore
const { data: carts } = useQueryGraphStep({
entity: "cart",
fields: [
@@ -533,7 +533,6 @@ type SyncProductsWorkflowInput = {
export const syncProductsWorkflow = createWorkflow(
"sync-products",
({ filters, limit, offset }: SyncProductsWorkflowInput) => {
// @ts-ignore
const { data, metadata } = useQueryGraphStep({
entity: "product",
fields: ["id", "title", "description", "handle", "thumbnail", "categories.*", "tags.*"],
@@ -542,7 +541,6 @@ export const syncProductsWorkflow = createWorkflow(
skip: offset,
},
filters: {
// @ts-ignore
status: "published",
...filters,
},
@@ -1405,7 +1405,6 @@ type WorkflowInput = {
export const createProductsContentfulWorkflow = createWorkflow(
{ name: "create-products-contentful-workflow" },
(input: WorkflowInput) => {
// @ts-ignore
const { data } = useQueryGraphStep({
entity: "product",
fields: [
@@ -1172,9 +1172,9 @@ You'll create a workflow that retrieves the latest products added to your Medusa
Create the file `src/workflows/send-newsletter.ts` with the following content:
export const workflowHighlights = [
["15", "useQueryGraphStep", "Retrieve the products created in the last 7 days."],
["32", "when", "Check whether there are new products."],
["34", "sendNotificationsStep", "Create a notification with the new products data."],
["14", "useQueryGraphStep", "Retrieve the products created in the last 7 days."],
["31", "when", "Check whether there are new products."],
["33", "sendNotificationsStep", "Create a notification with the new products data."],
]
```ts title="src/workflows/send-newsletter.ts" highlights={workflowHighlights}
@@ -1191,7 +1191,6 @@ import {
export const sendNewProductsNewsletter = createWorkflow(
"send-new-products-newsletter",
(input) => {
// @ts-ignore
const { data: products } = useQueryGraphStep({
entity: "product",
fields: [
@@ -1199,9 +1199,9 @@ You'll now create the workflow that uses the `sendNotificationStep` to send the
Create the file `src/workflows/send-order-confirmation.ts` with the following content:
export const workflowHighlights = [
["12", "sendOrderConfirmationWorkflow", "Create the workflow that sends an order confirmation email."],
["16", "useQueryGraphStep", "Retrieve the order's details."],
["44", "sendNotificationStep", "Send the order confirmation email."]
["13", "sendOrderConfirmationWorkflow", "Create the workflow that sends an order confirmation email."],
["15", "useQueryGraphStep", "Retrieve the order's details."],
["43", "sendNotificationStep", "Send the order confirmation email."]
]
```ts title="src/workflows/send-order-confirmation.ts" highlights={workflowHighlights}
@@ -1219,7 +1219,6 @@ type WorkflowInput = {
export const sendOrderConfirmationWorkflow = createWorkflow(
"send-order-confirmation",
({ id }: WorkflowInput) => {
// @ts-ignore
const { data: orders } = useQueryGraphStep({
entity: "order",
fields: [
@@ -722,7 +722,6 @@ export const syncStep = createStep(
fields: [
"id",
"title",
// @ts-ignore
"sanity_product.*",
],
filters,
@@ -507,9 +507,9 @@ Next, you'll create the workflow that tracks the order placement event.
To create the workflow, create the file `src/workflows/track-order-placed.ts` with the following content:
export const workflowHighlights = [
["16", "useQueryGraphStep", "Retrieve the order's details."],
["35", "transform", "Prepare data for tracking."],
["58", "trackEventStep", "Track the order placement event in Segment."]
["15", "useQueryGraphStep", "Retrieve the order's details."],
["34", "transform", "Prepare data for tracking."],
["57", "trackEventStep", "Track the order placement event in Segment."]
]
```ts title="src/workflows/track-order-placed.ts" highlights={workflowHighlights}
@@ -527,7 +527,6 @@ type WorkflowInput = {
export const trackOrderPlacedWorkflow = createWorkflow(
"track-order-placed",
({ id }: WorkflowInput) => {
// @ts-ignore
const { data: orders } = useQueryGraphStep({
entity: "order",
fields: [
@@ -557,8 +557,8 @@ Medusa provides both steps in its `@medusajs/medusa/core-flows` package.
So, to create the workflow, create the file `src/workflows/order-placed-notification.ts` with the following content:
export const orderPlacedNotificationWorkflowHighlights = [
["14", "useQueryGraphStep", "Retrieve the order details using the Query Graph."],
["35", "sendNotificationsStep", "Send a notification to Slack with the order details."]
["13", "useQueryGraphStep", "Retrieve the order details using the Query Graph."],
["34", "sendNotificationsStep", "Send a notification to Slack with the order details."]
]
```ts title="src/workflows/order-placed-notification.ts" highlights={orderPlacedNotificationWorkflowHighlights}
@@ -574,7 +574,6 @@ type WorkflowInput = {
export const orderPlacedNotificationWorkflow = createWorkflow(
"order-placed-notification",
({ id }: WorkflowInput) => {
// @ts-ignore
const { data: orders } = useQueryGraphStep({
entity: "order",
fields: [
@@ -622,7 +622,7 @@ export const createBundledProductWorkflowHighlights = [
["38", "createRemoteLinkStep", "Create a link between the bundle and the Medusa product."],
["47", "transform", "Prepare the data to create links between bundle items and Medusa products."],
["61", "createRemoteLinkStep", "Create the links between the bundle items and the Medusa products."],
["67", "useQueryGraphStep", "Retrieve the created bundle and its items."],
["66", "useQueryGraphStep", "Retrieve the created bundle and its items."],
]
```ts title="src/workflows/create-bundled-product.ts" highlights={createBundledProductWorkflowHighlights}
@@ -691,7 +691,6 @@ export const createBundledProductWorkflow = createWorkflow(
})
// retrieve bundled product with items
// @ts-ignore
const { data } = useQueryGraphStep({
entity: "bundle",
fields: ["*", "items.*"],
@@ -1890,10 +1889,10 @@ You can now create the workflow with the custom add-to-cart logic.
To create the workflow, create the file `src/workflows/add-bundle-to-cart.ts` with the following content:
export const addBundleToCartWorkflowHighlights = [
["29", "useQueryGraphStep", "Retrieve the bundle, its items, and their products and variants."],
["45", "prepareBundleCartDataStep", "Validate and prepare the items to be added to the cart."],
["51", "addToCartWorkflow", "Add the items in the bundle to the cart."],
["59", "useQueryGraphStep", "Retrieve the updated cart."],
["28", "useQueryGraphStep", "Retrieve the bundle, its items, and their products and variants."],
["44", "prepareBundleCartDataStep", "Validate and prepare the items to be added to the cart."],
["50", "addToCartWorkflow", "Add the items in the bundle to the cart."],
["57", "useQueryGraphStep", "Retrieve the updated cart."],
]
```ts title="src/workflows/add-bundle-to-cart.ts" highlights={addBundleToCartWorkflowHighlights} collapsibleLines="1-14" expandButtonLabel="Show Imports"
@@ -1924,7 +1923,6 @@ type AddBundleToCartWorkflowInput = {
export const addBundleToCartWorkflow = createWorkflow(
"add-bundle-to-cart",
({ cart_id, bundle_id, quantity, items }: AddBundleToCartWorkflowInput) => {
// @ts-ignore
const { data } = useQueryGraphStep({
entity: "bundle",
fields: [
@@ -1954,7 +1952,6 @@ export const addBundleToCartWorkflow = createWorkflow(
},
})
// @ts-ignore
const { data: updatedCarts } = useQueryGraphStep({
entity: "cart",
filters: { id: cart_id },
@@ -2804,7 +2801,7 @@ export const removeBundleFromCartWorkflowHighlights = [
["19", "useQueryGraphStep", "Retrieve the details of the cart and its items."],
["33", "transform", "Prepare the IDs of the items to remove."],
["42", "deleteLineItemsWorkflow", "Remove the items in the bundle from the cart."],
["51", "useQueryGraphStep", "Retrieve the updated cart."],
["50", "useQueryGraphStep", "Retrieve the updated cart."],
]
```ts title="src/workflows/remove-bundle-from-cart.ts" collapsibleLines="1-10" expandButtonLabel="Show Imports" highlights={removeBundleFromCartWorkflowHighlights}
@@ -2857,7 +2854,6 @@ export const removeBundleFromCartWorkflow = createWorkflow(
})
// retrieve cart again
// @ts-ignore
const { data: updatedCarts } = useQueryGraphStep({
entity: "cart",
fields: [
@@ -612,7 +612,7 @@ export const subscriptionWorkflow1Highlights = [
["16", "createWorkflow", "Create a workflow."],
["23", "transform", "Set the customer ID to an empty string if not provided."],
["28", "when", "If email is not set, try to retrieve customer by its ID."],
["48", "transform", "Set the email either to the one in the input or the specified customer's email."],
["47", "transform", "Set the email either to the one in the input or the specified customer's email."],
]
```ts title="src/workflows/create-restock-subscription/index.ts" highlights={subscriptionWorkflow1Highlights}
@@ -650,7 +650,6 @@ export const createRestockSubscriptionWorkflow = createWorkflow(
return !customer.email
}
).then(() => {
// @ts-ignore
const { data } = useQueryGraphStep({
entity: "customer",
fields: ["email"],
@@ -693,13 +692,13 @@ Next, replace the `TODO` with the following:
export const subscriptionWorkflow2Highlights = [
["1", "validateVariantOutOfStockStep", "Validate that the variant is out of stock in the specified sales channel."],
["7", "useQueryGraphStep", "Get the restock subscription to check if it already exists."],
["17", "when", "Perform an action if the restock subscription doesn't exist."],
["21", "createRestockSubscriptionStep", "Create the restock subscription if it doesn't exist."],
["29", "when", "Perform an action if the restock subscription exists."],
["33", "updateRestockSubscriptionStep", "Update the restock subscription if it exists."],
["40", "useQueryGraphStep", "Retrieve the restock subscription again to return it."],
["50", "WorkflowResponse", "Return the restock subscription."]
["6", "useQueryGraphStep", "Get the restock subscription to check if it already exists."],
["16", "when", "Perform an action if the restock subscription doesn't exist."],
["20", "createRestockSubscriptionStep", "Create the restock subscription if it doesn't exist."],
["28", "when", "Perform an action if the restock subscription exists."],
["32", "updateRestockSubscriptionStep", "Update the restock subscription if it exists."],
["38", "useQueryGraphStep", "Retrieve the restock subscription again to return it."],
["48", "WorkflowResponse", "Return the restock subscription."]
]
```ts title="src/workflows/create-restock-subscription/index.ts" highlights={subscriptionWorkflow2Highlights}
@@ -708,7 +707,6 @@ validateVariantOutOfStockStep({
sales_channel_id,
})
// @ts-ignore
const { data: restockSubscriptions } = useQueryGraphStep({
entity: "restock_subscription",
fields: ["*"],
@@ -741,7 +739,6 @@ when({ restockSubscriptions }, ({ restockSubscriptions }) => {
})
})
// @ts-ignore
const { data: restockSubscription } = useQueryGraphStep({
entity: "restock_subscription",
fields: ["*"],
@@ -1365,7 +1362,6 @@ export const sendRestockNotificationsWorkflow = createWorkflow(
return filters
})
// @ts-ignore
const { data: restockedSubscriptionsWithEmails } = useQueryGraphStep({
entity: "restock_subscription",
fields: ["*", "product_variant.*"],
@@ -1,5 +1,11 @@
import { CodeTab, CodeTabs } from "docs-ui"
<Note type="success" title="Issue Resolved">
This issue has been resolved in [Medusa v2.8.5+](https://github.com/medusajs/medusa/releases/tag/v2.8.5). If you're facing this error, please [update your Medusa application](!docs!/learn/update) and run the `dev` command. If the issue persists, please [report it on GitHub](https://github.com/medusajs/medusa/issues/new/choose).
</Note>
If you get the following error while using `query.graph` or `useQueryGraphStep`:
```bash