-
-
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(medusa): Retrieve (service + controller) a product category #3004
Conversation
🦋 Changeset detectedLatest commit: bd5dc41 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
7c5f89d
to
8718a6c
Compare
packages/medusa/src/api/routes/store/product-categories/get-product-category.ts
Show resolved
Hide resolved
d3c54ae
to
e6c91bd
Compare
e6c91bd
to
b6ecce9
Compare
|
||
const productCategory = await productCategoryService.retrieve( | ||
id, | ||
retrieveConfig |
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.
hmm, now that i look at this, i do need to add a { where: { is_internal: false, is_active: true } }
scope to the store endpoints. How is this typically done? Do i create a new repo method that accepts the extra scope arg? Because ExtendedFindConfig
is used exclusively for list endpoints. @adrien2p @pKorsholm
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.
You can create a method in the service retrieveActiveNonInternal or something like that (can't find a good name)
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.
sometimes what I do is the following:
- create a protected retrieve method that accept
selector
,config
- create a retrieveById that accept the actual retrieve arguments, call the protected method
- create a retrieveInternalActive, call the protected method
you can look at the product service as an example
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.
Would it make sense to add fixed filter params for store endpoint instead of a dedicated method?
E.g. in /store/products
we add "published"
as a fixed filter in the controllers.
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 we shouldn't create dedicated retrieve methods for what is just a filter. That does not scale super well 🤔
Wdyt?
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 creating a retrieve method that takes a selector
(maybe string | selector
, where string is just an id) as @adrien2p suggested is a good approach, then you could add the parameters as a where
object.
In that way you get all the retrieveByEmail etc. we have elsewhere as well and can create the filter in the controller as Oli suggests 😄
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, few minors
const [process, connection] = await startServerWithEnvironment({ | ||
cwd, | ||
env: { MEDUSA_FF_PRODUCT_CATEGORIES: true }, | ||
verbose: true, |
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.
todo: rm
packages/medusa/src/api/routes/store/product-categories/get-product-category.ts
Show resolved
Hide resolved
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 💪
I like the approach with transformTreeNodesWithConfig
!
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! Just a reminder to add tests for the additional where 😄
|
||
const productCategory = await productCategoryService.retrieve( | ||
id, | ||
retrieveConfig |
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 creating a retrieve method that takes a selector
(maybe string | selector
, where string is just an id) as @adrien2p suggested is a good approach, then you could add the parameters as a where
object.
In that way you get all the retrieveByEmail etc. we have elsewhere as well and can create the filter in the controller as Oli suggests 😄
packages/medusa/src/api/routes/store/product-categories/get-product-category.ts
Show resolved
Hide resolved
ade8d7f
to
3f27cf9
Compare
packages/medusa/src/api/routes/store/product-categories/get-product-category.ts
Outdated
Show resolved
Hide resolved
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.
It is missing the test on the handler and it is good to go
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!
…3023) **What:** Introduces a store endpoint to retrieve a list of product categories **Why:** This is part of a greater goal of allowing products to be added to multiple categories. **How:** - Creates an endpoint in store routes RESOLVES CORE-968
What:
Introduces a store endpoint to retrieve a product category
Why:
This is part of a greater goal of allowing products to be added to multiple categories.
How:
RESOLVES CORE-967