-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(medusa): Use remote query in get cart API route (#6285)
- Loading branch information
1 parent
2cebadc
commit d5e4707
Showing
8 changed files
with
12 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,19 @@ | ||
import { ModuleRegistrationName } from "@medusajs/modules-sdk" | ||
import { ICartModuleService } from "@medusajs/types" | ||
import { MedusaRequest, MedusaResponse } from "../../../../types/routing" | ||
import { defaultStoreCartRemoteQueryObject } from "../query-config" | ||
|
||
export const GET = async (req: MedusaRequest, res: MedusaResponse) => { | ||
const cartModuleService: ICartModuleService = req.scope.resolve( | ||
ModuleRegistrationName.CART | ||
) | ||
const remoteQuery = req.scope.resolve("remoteQuery") | ||
|
||
// TODO: Replace with remoteQuery | ||
const cart = await cartModuleService.retrieve(req.params.id, { | ||
select: req.retrieveConfig.select, | ||
relations: req.retrieveConfig.relations, | ||
}) | ||
const variables = { id: req.params.id } | ||
|
||
// const remoteQuery = req.scope.resolve("remoteQuery") | ||
const query = { | ||
cart: { | ||
__args: variables, | ||
...defaultStoreCartRemoteQueryObject, | ||
}, | ||
} | ||
|
||
// const variables = { id: req.params.id } | ||
|
||
// const query = { | ||
// cart: { | ||
// __args: variables, | ||
// ...defaultStoreCartRemoteQueryObject, | ||
// }, | ||
// } | ||
|
||
// const [cart] = await remoteQuery(query) | ||
const [cart] = await remoteQuery(query) | ||
|
||
res.json({ cart }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
export * as cart from "./cart-service" | ||
export * as customer from "./customer-service" | ||
export * as publishableApiKey from "./publishable-api-key-service" | ||
export * as region from "./region-service" | ||
export * as shippingProfile from "./shipping-profile-service" | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.