1 import { ModuleJoinerConfig } from "@medusajs/framework/types"
2 import { Modules } from "@medusajs/framework/utils"
3
4 export const CartProduct: ModuleJoinerConfig = {
5 isLink: true,
6 isReadOnlyLink: true,
7 extends: [
8 {
9 serviceName: Modules.CART,
10 entity: "LineItem",
11 relationship: {
12 serviceName: Modules.PRODUCT,
13 entity: "Product",
14 primaryKey: "id",
15 foreignKey: "items.product_id",
16 alias: "product",
17 args: {
18 methodSuffix: "Products",
19 },
20 },
21 },
22 {
23 serviceName: Modules.CART,
24 entity: "LineItem",
25 relationship: {
26 serviceName: Modules.PRODUCT,
27 entity: "ProductVariant",
28 primaryKey: "id",
29 foreignKey: "items.variant_id",
30 alias: "variant",
31 args: {
32 methodSuffix: "ProductVariants",
33 },
34 },
35 },
36 {
37 serviceName: Modules.PRODUCT,
38 relationship: {
39 serviceName: Modules.CART,
40 entity: "LineItem",
41 primaryKey: "variant_id",
42 foreignKey: "id",
43 alias: "cart_items",
44 isList: true,
45 args: {
46 methodSuffix: "LineItems",
47 },
48 },
49 },
50 ],
51 }