Closed DonielMoins closed 1 day ago
@DonielMoins can you please provide more info on where this happens, what you are calling, what you've modified? There are quite a few commits, and we want to make sure if this is an issue with what you've implemented or something else.
@DonielMoins can you please provide more info on where this happens, what you are calling, what you've modified? There are quite a few commits, and we want to make sure if this is an issue with what you've implemented or something else.
This happens in this file: /home/donielmoins/dev/medusa-eats/backend/src/api/uber/delivery/route.ts
Specifically, under the GET function below when we run the query.graph
Heres the snippet of code:
import type { MedusaRequest, MedusaResponse } from "@medusajs/framework";
import { ContainerRegistrationKeys, Modules } from "@medusajs/utils";
import zod from "zod";
import { handleUberDeliveryWorkflow } from "src/workflows/uber-delivery/workflows/handle-uber-delivery";
import { createUberDeliveryWorkflow } from "src/workflows/uber-delivery/workflows/create-uber-delivery";
import { UBER_DELIVERY_MODULE } from "src/modules/uber-delivery";
import type UberDeliveryModuleService from "src/modules/uber-delivery/service";
const schema = zod.object({
cart_id: zod.string().startsWith("cart_"),
restaurant_id: zod.string().startsWith("res_"),
});
export async function POST(req: MedusaRequest, res: MedusaResponse) {
const validatedBody = schema.parse(req.body);
const { result: delivery } = await createUberDeliveryWorkflow(req.scope).run({
input: {
cart_id: validatedBody.cart_id,
restaurant_id: validatedBody.restaurant_id,
},
});
const { transaction } = await handleUberDeliveryWorkflow(req.scope).run({
input: {
delivery_id: delivery.id,
},
});
return res
.status(200)
.json({ message: "Delivery created", delivery, transaction });
}
export async function GET(req: MedusaRequest, res: MedusaResponse) {
const query = req.scope.resolve(ContainerRegistrationKeys.QUERY);
const { take = null, skip, ...queryFilters } = req.query;
const uberDeliveryQuery = {
entity: "uber_delivery",
fields: ["*", "cart.*", "cart.items.*", "order.*", "order.items.*"],
filters: queryFilters,
pagination: {
take: Number.parseInt(take as string) || null,
skip: Number.parseInt(req.query.skip as string) || 0,
},
};
const { data: deliveries } = await query.graph(uberDeliveryQuery);
return res.status(200).json({ deliveries });
}
Ok I see, so this is some custom code you've implemented. As it is not really an issue with the repo I'll close the repo. It is likely an issue with how you've defined your module, check it against our docs: https://docs.medusajs.com/learn/basics/modules
Package.json file
Node.js version
v22.9.0
Database and its version
PostgreSQL 16.4 (Debian 16.4-1.pgdg120+1)
Operating system name and version
6.8.0-45-generic #45-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug 30 12:02:04 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
Browser name
No response
What happended?
When trying to access the service's objects using the query tool I am getting an error related to getting a fresh instance to the manager
Expected behavior
Return a list of all the service's objects that I am requesting
Actual behavior
` error: Cannot read properties of undefined (reading 'getFreshManager')
TypeError: Cannot read properties of undefined (reading 'getFreshManager') at UberDeliveryService.descriptor.value [as listAndCountUberDeliveries] (/home/donielmoins/medusa-eats/backend/node_modules/@medusajs/utils/src/modules-sdk/decorators/inject-manager.ts:44:56) at RemoteQuery.remoteFetchData (/home/donielmoins/medusa-eats/backend/node_modules/@medusajs/modules-sdk/src/remote-query/remote-query.ts:257:41) at RemoteJoiner.fetchData (/home/donielmoins/medusa-eats/backend/node_modules/@medusajs/orchestration/src/joiner/remote-joiner.ts:477:33) at RemoteJoiner.query (/home/donielmoins/medusa-eats/backend/node_modules/@medusajs/orchestration/src/joiner/remote-joiner.ts:1230:33) at RemoteQuery.query (/home/donielmoins/medusa-eats/backend/node_modules/@medusajs/modules-sdk/src/remote-query/remote-query.ts:289:36) at Query.graph (/home/donielmoins/medusa-eats/backend/node_modules/@medusajs/modules-sdk/src/remote-query/query.ts:166:42) at GET (/home/donielmoins/medusa-eats/backend/src/api/uber/delivery/route.ts:48:44) at /home/donielmoins/medusa-eats/backend/node_modules/@medusajs/utils/src/common/wrap-handler.ts:17:20 at Layer.handle [as handle_request] (/home/donielmoins/medusa-eats/backend/node_modules/express/lib/router/layer.js:95:5) at next (/home/donielmoins/medusa-eats/backend/node_modules/express/lib/router/route.js:149:13 `
Link to reproduction repo
https://github.com/DonielMoins/medusa-eats