Access custom metafield of type Money from the GraphQL Admin API

Access custom metafield of type Money from the GraphQL Admin API

nerfologist
Shopify Partner
1 0 0

Hello,

I have a custom metafield of type "Money" set on my market; it's called import_fees.

 

This is a GraphQL query that I'm attempting to use to fetch it

query GetMarketByGeography($countryCode: CountryCode!) {
  marketByGeography(countryCode: $countryCode) {
    import_fees: metafield(namespace: "my_namespace", key: "import_fees") {
      value
    }
}

 

When I run the GraphQL query, what I get is a JSON string as a value:

{
  "data": {
    "marketByGeography": {
      "import_fees": {
        "value": "{\"amount\":\"3.00\",\"currency_code\":\"EUR\"}"
      },
... }

Maybe I'm missing something, but is there a way to parse this Money object inside the query?

 

I'm not looking forward to parsing this after running the query!

 

Thanks for any insight (I'm a newcomer to this Shopify environment).

Replies 0 (0)