-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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): migrate store cart endpoints to zod #7130
Conversation
🦋 Changeset detectedLatest commit: 8664360 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 |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
2 Ignored Deployments
|
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
remoteQueryObjectFromString, | ||
} from "@medusajs/utils" | ||
|
||
export const refetchCart = async ( |
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.
comment: I have noticed these refetch-helpers do not accept filters. I think we should add that going forward, so that you can also pass params on a POST request.
cc @sradevski
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.
This could also be a single generic entity:
export const refetchEntity = async (
entryPoint: string,
idOrFilter: string | object,
scope: MedusaContainer,
fields: string[]
) => {
const remoteQuery = scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
const filters = isString(idOrFilter) ? { id: idOrFilter } : idOrFilter
const queryObject = remoteQueryObjectFromString({
entryPoint,
variables: { filters },
fields,
})
const [entity] = await remoteQuery(queryObject)
return entity
}
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.
@riqwan I completely agree, I was thinking about it but I didn't want to do it while doing the cleanup, as it will be pretty easy to refactor it. I think we can still keep eg. refetchProduct
as a method, which instead calls refetchEntity("product", ...args)
.
what:
RESOLVES CORE-2014