-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(customer): list customer #6206
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
3 Ignored Deployments
|
d17a86d
to
711a7ad
Compare
bf08d01
to
89ec9d0
Compare
274f47e
to
c393740
Compare
c393740
to
254183f
Compare
baeccb9
to
c37b269
Compare
import { MedusaRequest, MedusaResponse } from "../../../types/routing" | ||
|
||
export const GET = async (req: MedusaRequest, res: MedusaResponse) => { | ||
const customerModuleService = req.scope.resolve<ICustomerModuleService>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can align how we want to build the GET endpoints.
I believe we should use the remoteQuery to be able to easily expand relations from here.
We have 2 utils that can help on that:
remoteQueryObjectFromString and remoteQueryObjectToString
we can discuss it on Monday and come up with a pattern to follow in all the api-v2 endpoints. cc: @adrien2p @olivermrbl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree remote query should be the way to go - do we have an example implementation of the approach somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have mixed examples that we need to normalize from now on.
I believe this test is a good starting point, where we have a list of all default fields and relations to be listed. We need to think about and implement how to have a list of "allowed" relations to be expanded, and how to customize this list, adding custom relations to it.
from there it is used like this:
const remoteQuery = container.resolve("remoteQuery")
const query = remoteQueryObjectFromString({
entryPoint: "product",
variables: {},
fields,
})
const results = await remoteQuery(query)
variables are handled here before calling module.list(filters, options)
We can send all the filters and options needed to the service from here.
As this will be replicate in most GET endpoints, I think it worth spending some time in it, even if in another PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I will need to see an example with filters and expands applied - I wasn't able to get this to work for these.
I suggest that we merge PRs without RemoteQuery until we have its feature set more standardized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What