Call hydrogen's storefront.graphql directly, drop the compat shim

Completes the migration started in f8c3ef9. That commit put hydrogen
underneath the existing shopifyFetch wrapper; this one removes the
wrapper so every query uses the package's own client API.

- All 22 call sites now call storefront.graphql(DOCUMENT, { variables })
  (cachedStorefront for shop policies) instead of shopifyFetch, which
  emulated the old client's {query, variables} -> {data} shape.
- shopifyFetch is replaced by unwrapStorefrontResult(result, operation),
  which is only an error policy, not a transport wrapper: it returns
  data and throws when Shopify reports GraphQL errors, since hydrogen
  returns those rather than throwing. Naming the operation means a
  failure points at the call site instead of just at "Shopify".
- Environment reads move to services/shopify/config, so client.ts is
  only the hydrogen clients and shop-pay-button no longer imports from
  a query module just to get the store domain.
- Removes @shopify/storefront-api-client, the superseded client. It had
  no importers.

The SHOPIFY_STOREFRONT_API_URL export is gone too — hydrogen builds the
endpoint from storeDomain and apiVersion, and nothing else used it.

No behaviour change intended: same documents, same env var names, same
2025-07 API pin, same caching split between the two clients.

yarn typecheck passes with 0 errors. Verified against mock.shop: build
prerenders the policy pages, and in the browser product grid, search,
collection filters, cart restore, quantity update and discount-code
apply all work with no console errors. Customer account flows remain
untested — they need real credentials.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JaxgqPbFxLsSuLPZom2kdC
This commit is contained in:
Rami Bitar
2026-08-08 10:38:12 -04:00
co-authored by Claude Opus 5
parent f8c3ef9e0e
commit fe78293312
9 changed files with 204 additions and 202 deletions
-17
View File
@@ -1881,13 +1881,6 @@ __metadata:
languageName: node
linkType: hard
"@shopify/graphql-client@npm:^1.4.2":
version: 1.4.2
resolution: "@shopify/graphql-client@npm:1.4.2"
checksum: 10c0/f18d898ec3fb12a819b6c2941d9ddaebd1ab7152ffe55450ab9255c11860de9422ba1e9eadee5f44ef314f664fe411c642ba3debd6671851b9cdc647eb85e0be
languageName: node
linkType: hard
"@shopify/hydrogen@npm:0.0.0-preview-116d5d7-20260730141607":
version: 0.0.0-preview-116d5d7-20260730141607
resolution: "@shopify/hydrogen@npm:0.0.0-preview-116d5d7-20260730141607"
@@ -1907,15 +1900,6 @@ __metadata:
languageName: node
linkType: hard
"@shopify/storefront-api-client@npm:^1.0.0":
version: 1.0.10
resolution: "@shopify/storefront-api-client@npm:1.0.10"
dependencies:
"@shopify/graphql-client": "npm:^1.4.2"
checksum: 10c0/e8eff260e91857e87cffb543ca57c8a4a6e549316e0b6ccef2c345b857ef59e4092e92ecd2904706aa386bca1d21af4ef3e7447f9966b8dcceda06b3ad7dadc9
languageName: node
linkType: hard
"@standard-schema/spec@npm:^1.1.0":
version: 1.1.0
resolution: "@standard-schema/spec@npm:1.1.0"
@@ -3486,7 +3470,6 @@ __metadata:
"@radix-ui/react-use-controllable-state": "npm:^1.2.6"
"@remixicon/react": "npm:^4.9.0"
"@shopify/hydrogen": "npm:0.0.0-preview-116d5d7-20260730141607"
"@shopify/storefront-api-client": "npm:^1.0.0"
"@tailwindcss/postcss": "npm:^4"
"@types/hast": "npm:^3.0.5"
"@types/node": "npm:^22"