Open noubase opened 3 weeks ago
Hello @noubase 👋
Can you please share this custom route or a repo that I can use to reproduce the issue?
Closing since no response from the issue reporter and not actionable as well. However, feel free to leave a comment if you are still having the same issue and can provide a reproduction of the same :)
There is absolutely no need in custom repo
Create a route like this
type AdminGetOrdersParamsType = z.infer<typeof AdminGetOrdersParams>;
const AdminGetOrdersParams = createFindParams({
limit: 15,
offset: 0,
})
export async function GET(
req: MedusaRequest<AdminGetOrdersParamsType>,
res: MedusaResponse
): Promise<void> {
const q = req.scope.resolve(ContainerRegistrationKeys.QUERY)
const {data} = await q.graph({
entity: 'order',
fields: req.remoteQueryConfig.fields,
filters: {
id: req.params.id
}
}, {throwIfKeyNotFound: true, throwIfRelationNotFound: true})
res.json(data)
}
And you will immediately get an error
That's because fields
is always just an array of strings
And fields
in RemoteQueryInput
is a sophisticated generic type
@thetutlage Can confirm that on the newest 2.0 version MedusaRequest
generic do not populate with correct fields
type
Package.json file
Node.js version
v20.18.0
Database and its version
postgres (PostgreSQL) 16.3
Operating system name and version
Mac OS X
Browser name
No response
What happended?
You now get an error when trying to use
fields
from aremoteQueryConfig
request within theRemoteQuery
graph.Expected behavior
fields
should resolve the correct type from the generic body.Actual behavior
It's just a
string[]
array. I have to use@ts-ignore
to avoid errors during the build.Link to reproduction repo
No need for