fix: Add count to stock-locations response (#6965)

This commit is contained in:
Oli Juhl authored and GitHub committed 2024-04-05 18:28:03 +02:00
1 parent 8a5c6928f7
commit 8ecfa4b6f5
1 file changed
+6 -6
@@ -4,8 +4,8 @@ import {
} from "@medusajs/utils" } from "@medusajs/utils"
import { MedusaRequest, MedusaResponse } from "../../../types/routing" import { MedusaRequest, MedusaResponse } from "../../../types/routing"
import { AdminPostStockLocationsReq } from "./validators"
import { createStockLocationsWorkflow } from "@medusajs/core-flows" import { createStockLocationsWorkflow } from "@medusajs/core-flows"
import { AdminPostStockLocationsReq } from "./validators"
// Create stock location // Create stock location
export const POST = async ( export const POST = async (
@@ -34,14 +34,12 @@ export const POST = async (
export const GET = async (req: MedusaRequest, res: MedusaResponse) => { export const GET = async (req: MedusaRequest, res: MedusaResponse) => {
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY) const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
const { rows: stock_locations } = await remoteQuery( const { rows: stock_locations, metadata } = await remoteQuery(
remoteQueryObjectFromString({ remoteQueryObjectFromString({
entryPoint: "stock_locations", entryPoint: "stock_locations",
variables: { variables: {
filters: req.filterableFields, filters: req.filterableFields,
order: req.listConfig.order, ...req.remoteQueryConfig.pagination,
skip: req.listConfig.skip,
take: req.listConfig.take,
}, },
fields: req.remoteQueryConfig.fields, fields: req.remoteQueryConfig.fields,
}) })
@@ -49,6 +47,8 @@ export const GET = async (req: MedusaRequest, res: MedusaResponse) => {
res.status(200).json({ res.status(200).json({
stock_locations, stock_locations,
...req.remoteQueryConfig.pagination, count: metadata.count,
offset: metadata.skip,
limit: metadata.take,
}) })
} }