-
Notifications
You must be signed in to change notification settings - Fork 293
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Expose parseGid and use it internally #845
Conversation
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 agree with this approach over the alternatives we discussed in Slack. Left a few initial comments, let me know when its ready for a closer look 🥇
Co-authored-by: Matt Seccafien <matt.seccafien@shopify.com>
Ok, I don't think we have to change cli's dependence on hydrogen-react from This is ready to go. [edit] one moment while I validate docs, actually |
Ah dang; tests are failing because cli now needs hydrogen-react to build. So... I can set it up so that hydrogen-react builds before the cli's tests, or we can just not worry about single-sourcing this function for now. (Or other ideas?) |
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.
Happy with this approach ✅
One pending question for me, is how much does this change the bundle size 🤔
Co-authored-by: Daniel Rios <daniel.riospavia@shopify.com>
@frehner Maybe the CLI should use its own to avoid hard dependencies? I think we should consider even removing the peerDeps in the CLI that are just for types in virtual-routes (they should be devDeps because they're only useful to us) 🤔 I guess ideally we'd have a "common stuff" package where we import this kind of utility from. Maybe not even published, just a place to import things from and then they get bundled in each package. The final app bundle won't have 2 versions of this because the one in the CLI is not used in-app. Note that hydrogen and hydrogen-react should use the same, I agree there 100%. |
Honestly that's kind of the direction I'm leaning towards right now -- just letting the cli have its own version. As far as peer vs dev deps, I'm not sure I know enough context to understand which we should use; if they're only used for virtual-routes, and the developer never opens/edits virtual-routes on their own, and the TS compiler doesn't complain if the types aren't present for virtual-routes, then devdeps seems more correct. |
Ok let's do that then 👍
Agree. We can test and change deps in another PR though, no need to block this one. |
I wish you exposed parseGid so we can also use it in the project :) |
@jamalsoueidan Yeah it's now exposed. It will be available in the next release 👍 |
Thank you |
WHY are these changes introduced?
Currently we have 2 implementations of
parseGid()
in separate packages; one of them is a basic implementation, and one is more advanced. On top of that, there's still actually additional work we need to do to be able to parse complex GIDs (see this section on "Parameterized Global IDs" https://shopify.dev/docs/api/usage/gids#parameterized-global-ids) and it would be nice to implement that once and have everywhere updated.Additionally, there's also a need to use that helper in some work I'm doing for https://github.com/Shopify/hydrogen-internal/issues/36 where I'll need to get the raw Shop ID (not the GID).
Maybe we should also consider parsing any params out of the
ID
and having them as a separate item in the returned object? For example: https://github.com/Shopify/quilt/blob/42b7dd366d60c0ad0e165e0dd526a4c6a6054046/packages/admin-graphql-api-utilities/src/index.ts#L28-L44However, if this is actually too much headache, then I don't mind having two implementations. We can just update both at the same time or something. We can still expose
parseGid()
from hydrogen-react and hydrogen and use it all there, but keep thecli
's version as-is.WHAT is this pull request doing?
Single-sources
parseId()
Post-merge steps
Checklist