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: Create the Medusa API SDK as js-sdk package #7276
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
3 Ignored Deployments
|
🦋 Changeset detectedLatest commit: 507a54a 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 |
}, | ||
} | ||
|
||
public product = { |
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 these can be extracted into their own files, rather than implementing them inline, but I'll refrain from doing that until we decide on the few points I listed in the description.
9ac34c5
to
69f3446
Compare
Most of the time this SDK will be used for storefront implementations. I, therefore, suggest we stick to the old approach. I.e. do
JSON is probably what people want 99/100 times. So, think it makes sense to convert to JSON. That said being able to opt-out of that would be nifty.
Three things come to mind:
|
Don't have any strong opinion this. But for the sake of getting all the arguments out there - I do agree with Seb that the majority of people will be using the SDK for storefront implementations. With that in mind returning them as a flat list is slightly easier to type out. On the other hand, I have seen a couple of issues/discord over the years of people not understanding why
I think we should convert to JSON by default, with an escape hatch if the user needs another format, since JSON conversion will be needed in 99% of cases. Also think we should do something like Axios for errors, as it makes for a better DX. We could also export a safeguard function similar to Axios' +1 for allowing users to extend the SDK with their own domains, eg. |
Hey @srindom @kasperkristensen thanks for the comments guys!
I was a bit concerned about what Kasper said where people mix the two up. Do you think it would be a better UX for both admin and store builders if we export So if you are building a storefront, you'll do This would be the only thing that gets impacted, but it will solve the concern that Kasper brought up, without compromising anything really. WDYT? Otherwise:
Let me know if you have any comments, but I think for now we have a consensus on how to proceed on the points I raised, except of how we should expose |
I think I am leaning toward having:
This is not a strong opinion, so I am keen on another approach, too. But I think this gives us a clear separation between store and admin APIs, AND it ships a single entry point, which can be nifty in case you want to wrap it in a context, similar to what we did with |
69f3446
to
4c11195
Compare
4c11195
to
8e45b76
Compare
8e45b76
to
507a54a
Compare
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, pending a few more approvals from discussion participants
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.
Might be added later, but what are we doing with the auth
namespace?
@kasperkristensen we will indeed add it later, and that can be its own scope. But basically the Fetch Client will have a couple of methods to manage the lifecycle of authentication, I just didn't go into that yet, I want to get the basic setup in place first |
@srindom I'll get this merged now, but if you have any comments please leave them and I will address them in another PR. |
The implementation focuses on the client, and less on the Store and Admin endpoints. Those will be implemented in follow-up PRs