Replace storefront client and price formatting with @shopify/hydrogen preview#396
Merged
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
…shopify/hydrogen preview Swap @shopify/storefront-api-client for Hydrogen's createStorefrontClient behind the existing storefront.request<T>() contract, with a per-locale client cache (Hydrogen injects \$country/\$language from creation-time i18n, overriding per-request variables). Update assertStorefrontOk for Hydrogen's GraphQLFormattedError[] shape; transport failures now throw typed StorefrontApiError/StorefrontTimeoutError. Delegate all price formatting (lib/utils formatPrice, markdown formatPrice, Price component) to Hydrogen's formatMoney — output is byte-identical. Vendor the package's 12 agent skills into apps/template/.claude/skills via `hydrogen setup`. Update docs, the shopify-graphql-reference skill table, and add a template-rollout-log entry. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ing per locale The client is a stateless config bundle — no connection pool or handshake — so a module-level Map keyed by locale added a concept without buying anything, and invited misuse as a general cross-request cache. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
31fa562 to
71d6c0f
Compare
These were copied in by the Hydrogen setup flow but shouldn't ship with the template. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
df21431 to
478414f
Compare
# Conflicts: # pnpm-lock.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Evaluates Shopify's new framework-agnostic
@shopify/hydrogenpreview SDK (0.0.0-preview-0c3bff8) by replacing everything in the template it can substitute like-for-like. No new features — pure replacement, so we can measure how it performs before deciding on deeper adoption.Replaced
Storefront API client (
lib/shopify/storefront.ts)createStorefrontClient(type: "public");@shopify/storefront-api-clientremoved from dependencies.storefront.request<T>()call-site contract is unchanged — all ~35 operation call sites, codegen, fragments, and transforms are untouched.$country/$languagefrom its creation-timei18nconfig, overriding per-request variables — so the wrapper caches one client per country/language pair and selects it from the request's variables, preserving the per-call locale flow and the multi-locale upgrade path.StorefrontApiError/StorefrontTimeoutError(30s default timeout); GraphQL errors still resolve to{ data, errors }.assertStorefrontOkupdated for theGraphQLFormattedError[]shape.?operation=debug annotation, brotli header, andDEBUG_SHOPIFYtiming log survive via Hydrogen'sfetchconfig option. Env vars unchanged.All price formatting
formatPrice(lib/utils.ts,lib/markdown/utils.ts) and thePricecomponent now delegate to Hydrogen'sformatMoneywithcurrencyDisplay: "narrowSymbol". Output verified byte-identical to the previousIntl.NumberFormatusage.Evaluated, deliberately not replaced
/api/cartendpoints with a client-readable cookie; swapping would re-architect the server-action + cache-tag cart (discount apply/revert, locale sync,invalidateCartCache), not replace it. Candidate for a follow-up PR.getSelectedProductOptions— doesn't replicate the template's case-insensitive option canonicalization for PDP URLs.parseProductFilters— matches the template's parsing almost exactly but isn't exported from the package's server entry.Also in this PR
apps/template/.claude/skillsviapnpm exec hydrogen setup(their setup CLI works when run from the app root).reference/storefront-api.mdx,shopify/writing-shopify-queries.mdx), theshopify-graphql-referenceskill file table, and added atemplate-rollout-logentry (hydrogen-preview-client).Testing
tsc --noEmit,oxlint,oxfmt --checkpass.pnpm buildpasses — partial-prerender pages (PDP, collections) made live SFAPI calls through the Hydrogen client at build time./,/products/[handle],/collections/all,/cart,/search?q=jacketall 200 with prices rendering throughformatMoney.🤖 Generated with Claude Code