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

This commit is contained in:
Oli Juhl
2024-04-05 18:28:03 +02:00
committed by GitHub
parent 8a5c6928f7
commit 8ecfa4b6f5

View File

@@ -4,8 +4,8 @@ import {
} from "@medusajs/utils"
import { MedusaRequest, MedusaResponse } from "../../../types/routing"
import { AdminPostStockLocationsReq } from "./validators"
import { createStockLocationsWorkflow } from "@medusajs/core-flows"
import { AdminPostStockLocationsReq } from "./validators"
// Create stock location
export const POST = async (
@@ -34,14 +34,12 @@ export const POST = async (
export const GET = async (req: MedusaRequest, res: MedusaResponse) => {
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
const { rows: stock_locations } = await remoteQuery(
const { rows: stock_locations, metadata } = await remoteQuery(
remoteQueryObjectFromString({
entryPoint: "stock_locations",
variables: {
filters: req.filterableFields,
order: req.listConfig.order,
skip: req.listConfig.skip,
take: req.listConfig.take,
...req.remoteQueryConfig.pagination,
},
fields: req.remoteQueryConfig.fields,
})
@@ -49,6 +47,8 @@ export const GET = async (req: MedusaRequest, res: MedusaResponse) => {
res.status(200).json({
stock_locations,
...req.remoteQueryConfig.pagination,
count: metadata.count,
offset: metadata.skip,
limit: metadata.take,
})
}