-
Notifications
You must be signed in to change notification settings - Fork 354
Description
What is the location of your example repository?
No response
Which package or tool is having this issue?
Hydrogen
What version of that package or tool are you using?
2025.5.0
What version of Remix are you using?
react router 7.6.0
Steps to Reproduce
Query the product metafield like this:
const QUERY = `#graphql
bundle: product(handle: "my-bundle") {
originalPrice: metafield( namespace: "custom", key: "my_audiobook_bundle_original_price") {
value
type
}
selectedOrFirstAvailableVariant {
price {
amount
currencyCode
}
}
}
}
` as const;
const {bundle} = await storefront.query(QUERY)
This returns everything as expected:
{
"bundle": {
"originalPrice": {
"value": "{\"amount\":\"30.0\",\"currency_code\":\"USD\"}",
"type": "money"
},
"selectedOrFirstAvailableVariant": {
"price": {
"amount": "20.0",
"currencyCode": "USD"
}
}
}
}
Now try parsing the metafield with parseMetafield
from '@shopify/hydrogen'
:
const parsedOriginalPrice = parseMetafield<ParsedMetafields['money']>({
...bundle.originalPrice,
}).parsedValue;
parsedOriginalPrice
is inferred as MoneyV2
, but it actually looks like this:
{
"amount": "20.0",
"currency_code": "USD"
}
Expected Behavior
currency_code
is parsed to currencyCode
on the object if it gets inferred as MoneyV2
.
Actual Behavior
bundle.price
is correctly inferred as MoneyV2
, and it has the currencyCode
property.
parsedOriginalPrice
is incorrectly inferred as MoneyV2
, since currency_code
is not parsed to currencyCode
by parseMetafield
.
juanpprieto
Metadata
Metadata
Assignees
Labels
No labels